slack_log_device 5.1.3 → 6.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/slack_log_device/formatter.rb +18 -14
- data/lib/slack_log_device.rb +7 -4
- data/slack_log_device.gemspec +10 -7
- metadata +77 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8cf57d3cec462d6f71fc712a028d98cd6e8670244b8f2c5a904d1afb7832535
|
4
|
+
data.tar.gz: '047883fd1fa893a828ad245cd4d8dfb302bd6114811b76040237ef321c895ef7'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27a9b2b9fb885de47b713141d5e72fe61808b48e848adc5fc9b45dd7849626f0e4cdadd78f05f44416889bddb546f4c94c061ff404252432dc65f6f92a444085
|
7
|
+
data.tar.gz: 64789b2fdd1be785d8b3e2b4abaa0fc6a07f6eed76ef192f9982569ee4170f686cb07a1f134cf3ee812a41f59e155385b62992340a9c5c93f60776acc5197aba
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
6.0.1
|
@@ -10,7 +10,6 @@ class SlackLogDevice
|
|
10
10
|
'FATAL' => ':fire:',
|
11
11
|
'UNKNOWN' => ':interrobang:',
|
12
12
|
}.freeze
|
13
|
-
ENCODING = 'UTF-8'
|
14
13
|
MAX_MESSAGE_LENGTH = 4000
|
15
14
|
|
16
15
|
attr_reader :extra_metadata, :max_backtrace_lines
|
@@ -28,9 +27,9 @@ class SlackLogDevice
|
|
28
27
|
@message_converter = block_given? ? Proc.new(&block) : -> (message) { message }
|
29
28
|
end
|
30
29
|
|
31
|
-
def call(severity,
|
30
|
+
def call(severity, _datetime, progname, message)
|
32
31
|
text = "*`#{severity}`*"
|
33
|
-
text << " (*#{progname
|
32
|
+
text << " (*#{to_utf8(progname)}*)" if progname.present?
|
34
33
|
text << ':'
|
35
34
|
if message.is_a?(Exception)
|
36
35
|
exception = message
|
@@ -64,7 +63,7 @@ class SlackLogDevice
|
|
64
63
|
|
65
64
|
def icon_emoji=(value)
|
66
65
|
value = value.to_s.strip.presence
|
67
|
-
@icon_emojis.
|
66
|
+
@icon_emojis.each_key do |severity|
|
68
67
|
@icon_emojis[severity] = value
|
69
68
|
end
|
70
69
|
end
|
@@ -77,7 +76,6 @@ class SlackLogDevice
|
|
77
76
|
values.each do |severity, emoji|
|
78
77
|
@icon_emojis[parse_severity(severity)] = emoji.to_s.strip.presence
|
79
78
|
end
|
80
|
-
@icon_emojis
|
81
79
|
end
|
82
80
|
|
83
81
|
def max_backtrace_lines=(value)
|
@@ -90,26 +88,27 @@ class SlackLogDevice
|
|
90
88
|
|
91
89
|
def append_exception_backtrace(text, exception)
|
92
90
|
backtrace = format_backtrace(exception, MAX_MESSAGE_LENGTH - text.size - 2)
|
93
|
-
backtrace.present? ? "#{text}\n\n#{backtrace}" : text
|
91
|
+
backtrace.present? ? "#{to_utf8(text)}\n\n#{backtrace}" : text
|
94
92
|
end
|
95
93
|
|
96
94
|
def append_exception_cause(text, exception)
|
97
95
|
cause = exception.cause
|
96
|
+
text = to_utf8(text)
|
98
97
|
return text if cause.nil?
|
99
98
|
message = "\n\nCaused by `#{cause.class}`"
|
100
99
|
return text if (text + message).size > MAX_MESSAGE_LENGTH
|
101
|
-
text = truncate("#{text}#{message}: #{cause.message
|
100
|
+
text = truncate("#{text}#{message}: #{to_utf8(cause.message)}")
|
102
101
|
text = append_exception_backtrace(text, cause)
|
103
102
|
append_exception_cause(text, cause)
|
104
103
|
end
|
105
104
|
|
106
105
|
def append_metadata(text, message)
|
107
106
|
metadata = format_metadata(message, MAX_MESSAGE_LENGTH - text.size - 2)
|
108
|
-
metadata.present? ? "#{text}\n\n#{metadata}" : text
|
107
|
+
metadata.present? ? "#{to_utf8(text)}\n\n#{metadata}" : text
|
109
108
|
end
|
110
109
|
|
111
110
|
def convert_message(message)
|
112
|
-
@message_converter.call(message.to_s.strip).to_s.strip
|
111
|
+
to_utf8(@message_converter.call(to_utf8(message.to_s.strip)).to_s.strip)
|
113
112
|
end
|
114
113
|
|
115
114
|
def default_metadata(request)
|
@@ -126,16 +125,16 @@ class SlackLogDevice
|
|
126
125
|
'Machine' => Socket.gethostname,
|
127
126
|
'PID' => Process.pid,
|
128
127
|
})
|
129
|
-
metadata.
|
128
|
+
metadata.each_key do |key|
|
130
129
|
value = metadata[key]
|
131
|
-
metadata[key] = "`#{value.to_s.strip}`" if value.present?
|
130
|
+
metadata[key] = "`#{to_utf8(value.to_s.strip)}`" if value.present?
|
132
131
|
end
|
133
132
|
metadata
|
134
133
|
end
|
135
134
|
|
136
135
|
def format_backtrace(exception, size_available)
|
137
136
|
return nil if max_backtrace_lines == 0 || size_available < 7
|
138
|
-
backtrace = (exception.backtrace || []).select(&:present?).compact.map { |line| line
|
137
|
+
backtrace = (exception.backtrace || []).select(&:present?).compact.map { |line| to_utf8(line) }
|
139
138
|
return nil if backtrace.empty?
|
140
139
|
if max_backtrace_lines < 0
|
141
140
|
text = backtrace.join("\n")
|
@@ -154,7 +153,7 @@ class SlackLogDevice
|
|
154
153
|
options[:request] = request if request.present?
|
155
154
|
text = default_metadata(request).merge(extra_metadata).map do |name, value|
|
156
155
|
value = value.call(options) if value.respond_to?(:call)
|
157
|
-
value.present? ? "• *#{name
|
156
|
+
value.present? ? "• *#{to_utf8(name).strip}*: #{to_utf8(value).strip}" : nil
|
158
157
|
end.compact.join("\n")
|
159
158
|
return nil if text.blank?
|
160
159
|
truncate(text, size_available)
|
@@ -170,7 +169,12 @@ class SlackLogDevice
|
|
170
169
|
message = message.strip
|
171
170
|
return message if message.size <= max_length
|
172
171
|
return message[0, max_length] if max_length < 3
|
173
|
-
"#{message[0, max_length - 3]}..."
|
172
|
+
to_utf8("#{message[0, max_length - 3]}...")
|
173
|
+
end
|
174
|
+
|
175
|
+
def to_utf8(text)
|
176
|
+
return text if text.nil? || text.encoding == Encoding::UTF_8
|
177
|
+
text.encode(Encoding::UTF_8) rescue text.dup.force_encoding(Encoding::UTF_8)
|
174
178
|
end
|
175
179
|
|
176
180
|
end
|
data/lib/slack_log_device.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'active_support/isolated_execution_state'
|
1
2
|
require 'active_support/core_ext/hash'
|
2
3
|
require 'active_support/core_ext/string'
|
3
4
|
require 'httparty'
|
@@ -53,7 +54,7 @@ class SlackLogDevice
|
|
53
54
|
end
|
54
55
|
|
55
56
|
def flush
|
56
|
-
|
57
|
+
until @buffer.empty?
|
57
58
|
message = nil
|
58
59
|
@mutex.synchronize do
|
59
60
|
message = @buffer.pop
|
@@ -65,9 +66,11 @@ class SlackLogDevice
|
|
65
66
|
data['icon_emoji'] = message.icon_emoji if message.respond_to?(:icon_emoji) && message.icon_emoji.present?
|
66
67
|
data['username'] = username if username.present?
|
67
68
|
begin
|
68
|
-
HTTParty.post(webhook_url, body: data.to_json, headers: { 'Content-Type' => 'application/json' }, timeout:
|
69
|
+
HTTParty.post(webhook_url, body: data.to_json, headers: { 'Content-Type' => 'application/json' }, timeout:)
|
70
|
+
# rubocop:disable Lint/RescueException
|
69
71
|
rescue Exception => e
|
70
|
-
|
72
|
+
# rubocop:enable Lint/RescueException
|
73
|
+
warn(e)
|
71
74
|
end
|
72
75
|
end
|
73
76
|
nil
|
@@ -111,7 +114,7 @@ class SlackLogDevice
|
|
111
114
|
@mutex.synchronize do
|
112
115
|
@buffer << message
|
113
116
|
end
|
114
|
-
@flush_thread
|
117
|
+
@flush_thread&.kill
|
115
118
|
if flush?
|
116
119
|
flush
|
117
120
|
else
|
data/slack_log_device.gemspec
CHANGED
@@ -9,16 +9,19 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.description = 'LogDevice implementation that post logs on a Slack channel'
|
10
10
|
s.license = 'MIT'
|
11
11
|
|
12
|
-
s.files =
|
13
|
-
s.executables =
|
12
|
+
s.files = %x(git ls-files | grep -vE '^(spec/|test/|\\.|Gemfile|Rakefile)').split("\n")
|
13
|
+
s.executables = %x(git ls-files -- bin/*).split("\n").map { |f| File.basename(f) }
|
14
14
|
s.require_paths = ['lib']
|
15
15
|
|
16
|
-
s.required_ruby_version = '>=
|
16
|
+
s.required_ruby_version = '>= 3.1.0'
|
17
17
|
|
18
|
-
s.add_dependency 'activesupport', '>=
|
19
|
-
s.add_dependency 'httparty', '>= 0.14.0', '< 0.
|
18
|
+
s.add_dependency 'activesupport', '>= 7.0.0', '< 8.0.0'
|
19
|
+
s.add_dependency 'httparty', '>= 0.14.0', '< 0.21.0'
|
20
20
|
|
21
21
|
s.add_development_dependency 'byebug', '>= 9.0.0', '< 12.0.0'
|
22
|
-
s.add_development_dependency 'rake', '>= 12.0.0', '<
|
23
|
-
s.add_development_dependency 'rspec', '>= 3.5.0', '< 3.
|
22
|
+
s.add_development_dependency 'rake', '>= 12.0.0', '< 14.0.0'
|
23
|
+
s.add_development_dependency 'rspec', '>= 3.5.0', '< 3.11.0'
|
24
|
+
s.add_development_dependency 'rubocop', '>= 1.25.0', '< 2.0.0'
|
25
|
+
s.add_development_dependency 'rubocop-rake', '>= 0.6.0', '< 1.0.0'
|
26
|
+
s.add_development_dependency 'rubocop-rspec', '>= 2.8.0', '< 3.0.0'
|
24
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack_log_device
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexis Toulotte
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 7.0.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 8.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 7.0.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 8.0.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: httparty
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: 0.14.0
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.
|
42
|
+
version: 0.21.0
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: 0.14.0
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 0.
|
52
|
+
version: 0.21.0
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: byebug
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -79,7 +79,7 @@ dependencies:
|
|
79
79
|
version: 12.0.0
|
80
80
|
- - "<"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 14.0.0
|
83
83
|
type: :development
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -89,7 +89,7 @@ dependencies:
|
|
89
89
|
version: 12.0.0
|
90
90
|
- - "<"
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version:
|
92
|
+
version: 14.0.0
|
93
93
|
- !ruby/object:Gem::Dependency
|
94
94
|
name: rspec
|
95
95
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,7 +99,7 @@ dependencies:
|
|
99
99
|
version: 3.5.0
|
100
100
|
- - "<"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 3.
|
102
|
+
version: 3.11.0
|
103
103
|
type: :development
|
104
104
|
prerelease: false
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -109,7 +109,67 @@ dependencies:
|
|
109
109
|
version: 3.5.0
|
110
110
|
- - "<"
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version: 3.
|
112
|
+
version: 3.11.0
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: rubocop
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: 1.25.0
|
120
|
+
- - "<"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 2.0.0
|
123
|
+
type: :development
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: 1.25.0
|
130
|
+
- - "<"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 2.0.0
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: rubocop-rake
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: 0.6.0
|
140
|
+
- - "<"
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: 1.0.0
|
143
|
+
type: :development
|
144
|
+
prerelease: false
|
145
|
+
version_requirements: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: 0.6.0
|
150
|
+
- - "<"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 1.0.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop-rspec
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 2.8.0
|
160
|
+
- - "<"
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: 3.0.0
|
163
|
+
type: :development
|
164
|
+
prerelease: false
|
165
|
+
version_requirements: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: 2.8.0
|
170
|
+
- - "<"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: 3.0.0
|
113
173
|
description: LogDevice implementation that post logs on a Slack channel
|
114
174
|
email: al@alweb.org
|
115
175
|
executables: []
|
@@ -129,7 +189,7 @@ homepage: https://github.com/alexistoulotte/slack_log_device
|
|
129
189
|
licenses:
|
130
190
|
- MIT
|
131
191
|
metadata: {}
|
132
|
-
post_install_message:
|
192
|
+
post_install_message:
|
133
193
|
rdoc_options: []
|
134
194
|
require_paths:
|
135
195
|
- lib
|
@@ -137,15 +197,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
197
|
requirements:
|
138
198
|
- - ">="
|
139
199
|
- !ruby/object:Gem::Version
|
140
|
-
version:
|
200
|
+
version: 3.1.0
|
141
201
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
202
|
requirements:
|
143
203
|
- - ">="
|
144
204
|
- !ruby/object:Gem::Version
|
145
205
|
version: '0'
|
146
206
|
requirements: []
|
147
|
-
rubygems_version: 3.
|
148
|
-
signing_key:
|
207
|
+
rubygems_version: 3.3.3
|
208
|
+
signing_key:
|
149
209
|
specification_version: 4
|
150
210
|
summary: LogDevice for Slack
|
151
211
|
test_files: []
|