slack_log_device 5.1.2 → 5.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eba340374298e2296f5ca22cfdad6b96b7590a0d69359cdfd8393dc07c42a7a5
4
- data.tar.gz: 2b53706938364ca14d6a50b852135eb04124d2a0dae29c97ed5fbeff927f9c04
3
+ metadata.gz: f341ad9a62ebfc4b35e66667ea30f6004938e90a281945c43ac86718a00ebafa
4
+ data.tar.gz: 6fe8289362507dc6a1c96215b11f15114ed3f72b2270d9f738cce1aeccd8570a
5
5
  SHA512:
6
- metadata.gz: 575e3412f21bc9c8985642478612674d5ace56652398df981ef745592ab65e00bf684da7c0187091e8e3e8cf4d28d005d0ed8ec4458ed9ffe5372456a2414e2d
7
- data.tar.gz: 320c850a654bf1f115658c5c2466a0549a2ee7a4a4bf58ee4767e2191a9c55b2d82314bd40423f8b42d83f1bc0e8451490b2e1c9ecc2f1fbe7d08a04e80a355e
6
+ metadata.gz: 7a7c93726e522eaa5787420f980f167bfe44c03389ec52e97c66a2f50614ff757b16fe1ec8013b93c05ef66ff63ae9017bcef4621310ff3296960ed938d6f57c
7
+ data.tar.gz: 77db6c7b401bbeed0effdc46705ae29ee5fe93d1dc1993bb07822cccc6b6dd1e3458234e6f7656fa3694a31c0596df7114857b377f524520bde51ffca7bae8a3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.1.2
1
+ 5.1.3
@@ -10,6 +10,7 @@ class SlackLogDevice
10
10
  'FATAL' => ':fire:',
11
11
  'UNKNOWN' => ':interrobang:',
12
12
  }.freeze
13
+ ENCODING = 'UTF-8'
13
14
  MAX_MESSAGE_LENGTH = 4000
14
15
 
15
16
  attr_reader :extra_metadata, :max_backtrace_lines
@@ -29,7 +30,7 @@ class SlackLogDevice
29
30
 
30
31
  def call(severity, datetime, progname, message)
31
32
  text = "*`#{severity}`*"
32
- text << " (*#{progname}*)" if progname.present?
33
+ text << " (*#{progname.encode(ENCODING)}*)" if progname.present?
33
34
  text << ':'
34
35
  if message.is_a?(Exception)
35
36
  exception = message
@@ -97,7 +98,7 @@ class SlackLogDevice
97
98
  return text if cause.nil?
98
99
  message = "\n\nCaused by `#{cause.class}`"
99
100
  return text if (text + message).size > MAX_MESSAGE_LENGTH
100
- text = truncate("#{text}#{message}: #{cause.message}")
101
+ text = truncate("#{text}#{message}: #{cause.message.try(:encode, ENCODING)}")
101
102
  text = append_exception_backtrace(text, cause)
102
103
  append_exception_cause(text, cause)
103
104
  end
@@ -108,7 +109,7 @@ class SlackLogDevice
108
109
  end
109
110
 
110
111
  def convert_message(message)
111
- @message_converter.call(message.to_s.strip).to_s.strip
112
+ @message_converter.call(message.to_s.strip).to_s.strip.encode(ENCODING)
112
113
  end
113
114
 
114
115
  def default_metadata(request)
@@ -134,7 +135,7 @@ class SlackLogDevice
134
135
 
135
136
  def format_backtrace(exception, size_available)
136
137
  return nil if max_backtrace_lines == 0 || size_available < 7
137
- backtrace = (exception.backtrace || []).select(&:present?).compact
138
+ backtrace = (exception.backtrace || []).select(&:present?).compact.map { |line| line.encode(ENCODING) }
138
139
  return nil if backtrace.empty?
139
140
  if max_backtrace_lines < 0
140
141
  text = backtrace.join("\n")
@@ -153,7 +154,7 @@ class SlackLogDevice
153
154
  options[:request] = request if request.present?
154
155
  text = default_metadata(request).merge(extra_metadata).map do |name, value|
155
156
  value = value.call(options) if value.respond_to?(:call)
156
- value.present? ? "• *#{name.strip}*: #{value.strip}" : nil
157
+ value.present? ? "• *#{name.encode(ENCODING).strip}*: #{value.encode(ENCODING).strip}" : nil
157
158
  end.compact.join("\n")
158
159
  return nil if text.blank?
159
160
  truncate(text, size_available)
@@ -169,7 +170,7 @@ class SlackLogDevice
169
170
  message = message.strip
170
171
  return message if message.size <= max_length
171
172
  return message[0, max_length] if max_length < 3
172
- "#{message[0, max_length - 3]}..."
173
+ "#{message[0, max_length - 3]}...".encode(ENCODING)
173
174
  end
174
175
 
175
176
  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: 5.1.2
4
+ version: 5.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis Toulotte
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-10 00:00:00.000000000 Z
11
+ date: 2019-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport