semantic_logger 4.2.0 → 4.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/Rakefile +1 -1
  4. data/lib/semantic_logger/ansi_colors.rb +11 -12
  5. data/lib/semantic_logger/appender.rb +4 -5
  6. data/lib/semantic_logger/appender/async.rb +24 -16
  7. data/lib/semantic_logger/appender/async_batch.rb +1 -4
  8. data/lib/semantic_logger/appender/bugsnag.rb +67 -63
  9. data/lib/semantic_logger/appender/elasticsearch.rb +154 -157
  10. data/lib/semantic_logger/appender/elasticsearch_http.rb +59 -55
  11. data/lib/semantic_logger/appender/file.rb +1 -3
  12. data/lib/semantic_logger/appender/graylog.rb +114 -110
  13. data/lib/semantic_logger/appender/honeybadger.rb +54 -51
  14. data/lib/semantic_logger/appender/http.rb +194 -190
  15. data/lib/semantic_logger/appender/kafka.rb +152 -149
  16. data/lib/semantic_logger/appender/mongodb.rb +3 -3
  17. data/lib/semantic_logger/appender/new_relic.rb +52 -49
  18. data/lib/semantic_logger/appender/sentry.rb +59 -54
  19. data/lib/semantic_logger/appender/splunk.rb +108 -103
  20. data/lib/semantic_logger/appender/splunk_http.rb +82 -79
  21. data/lib/semantic_logger/appender/syslog.rb +4 -5
  22. data/lib/semantic_logger/appender/tcp.rb +8 -29
  23. data/lib/semantic_logger/appender/udp.rb +2 -3
  24. data/lib/semantic_logger/appender/wrapper.rb +2 -2
  25. data/lib/semantic_logger/base.rb +18 -16
  26. data/lib/semantic_logger/concerns/compatibility.rb +0 -1
  27. data/lib/semantic_logger/core_ext/thread.rb +0 -1
  28. data/lib/semantic_logger/formatters.rb +3 -5
  29. data/lib/semantic_logger/formatters/base.rb +2 -3
  30. data/lib/semantic_logger/formatters/color.rb +29 -12
  31. data/lib/semantic_logger/formatters/default.rb +10 -10
  32. data/lib/semantic_logger/formatters/json.rb +0 -2
  33. data/lib/semantic_logger/formatters/one_line.rb +2 -2
  34. data/lib/semantic_logger/formatters/raw.rb +7 -10
  35. data/lib/semantic_logger/formatters/signalfx.rb +3 -5
  36. data/lib/semantic_logger/formatters/syslog.rb +2 -3
  37. data/lib/semantic_logger/formatters/syslog_cee.rb +2 -3
  38. data/lib/semantic_logger/jruby/garbage_collection_logger.rb +8 -5
  39. data/lib/semantic_logger/log.rb +17 -17
  40. data/lib/semantic_logger/loggable.rb +6 -9
  41. data/lib/semantic_logger/logger.rb +0 -1
  42. data/lib/semantic_logger/metric/new_relic.rb +58 -55
  43. data/lib/semantic_logger/metric/signalfx.rb +108 -106
  44. data/lib/semantic_logger/metric/statsd.rb +2 -3
  45. data/lib/semantic_logger/processor.rb +9 -9
  46. data/lib/semantic_logger/semantic_logger.rb +50 -30
  47. data/lib/semantic_logger/subscriber.rb +0 -1
  48. data/lib/semantic_logger/utils.rb +37 -37
  49. data/lib/semantic_logger/version.rb +2 -2
  50. data/test/appender/async_batch_test.rb +0 -1
  51. data/test/appender/async_test.rb +0 -1
  52. data/test/appender/bugsnag_test.rb +7 -8
  53. data/test/appender/elasticsearch_http_test.rb +5 -6
  54. data/test/appender/elasticsearch_test.rb +14 -10
  55. data/test/appender/file_test.rb +5 -6
  56. data/test/appender/graylog_test.rb +8 -8
  57. data/test/appender/honeybadger_test.rb +6 -7
  58. data/test/appender/http_test.rb +4 -5
  59. data/test/appender/kafka_test.rb +5 -6
  60. data/test/appender/mongodb_test.rb +11 -13
  61. data/test/appender/new_relic_test.rb +8 -9
  62. data/test/appender/newrelic_rpm.rb +1 -1
  63. data/test/appender/sentry_test.rb +7 -8
  64. data/test/appender/splunk_http_test.rb +4 -4
  65. data/test/appender/splunk_test.rb +1 -3
  66. data/test/appender/syslog_test.rb +3 -5
  67. data/test/appender/tcp_test.rb +4 -5
  68. data/test/appender/udp_test.rb +4 -5
  69. data/test/appender/wrapper_test.rb +2 -3
  70. data/test/concerns/compatibility_test.rb +0 -1
  71. data/test/debug_as_trace_logger_test.rb +0 -1
  72. data/test/formatters/color_test.rb +5 -6
  73. data/test/formatters/default_test.rb +16 -17
  74. data/test/formatters/one_line_test.rb +1 -2
  75. data/test/formatters/signalfx_test.rb +8 -11
  76. data/test/formatters_test.rb +3 -3
  77. data/test/in_memory_appender.rb +0 -1
  78. data/test/in_memory_appender_helper.rb +1 -1
  79. data/test/in_memory_batch_appender.rb +0 -1
  80. data/test/in_memory_metrics_appender.rb +0 -1
  81. data/test/loggable_test.rb +2 -3
  82. data/test/logger_test.rb +11 -14
  83. data/test/measure_test.rb +13 -15
  84. data/test/metric/new_relic_test.rb +2 -3
  85. data/test/metric/signalfx_test.rb +4 -5
  86. data/test/semantic_logger_test.rb +28 -3
  87. data/test/test_helper.rb +6 -7
  88. metadata +34 -34
@@ -12,7 +12,7 @@ module Appender
12
12
  SemanticLogger::LEVELS.each do |level|
13
13
  it "send #{level}" do
14
14
  data = nil
15
- @appender.socket.stub(:send, -> d, flags { data = d }) do
15
+ @appender.socket.stub(:send, ->(d, _flags) { data = d }) do
16
16
  @appender.send(level, @message)
17
17
  end
18
18
  hash = JSON.parse(data)
@@ -29,7 +29,7 @@ module Appender
29
29
  exc = e
30
30
  end
31
31
  data = nil
32
- @appender.socket.stub(:send, -> d, flags { data = d }) do
32
+ @appender.socket.stub(:send, ->(d, _flags) { data = d }) do
33
33
  @appender.send(level, 'Reading File', exc)
34
34
  end
35
35
  hash = JSON.parse(data)
@@ -42,8 +42,8 @@ module Appender
42
42
 
43
43
  it "send #{level} custom attributes" do
44
44
  data = nil
45
- @appender.socket.stub(:send, -> d, flags { data = d }) do
46
- @appender.send(level, @message, {key1: 1, key2: 'a'})
45
+ @appender.socket.stub(:send, ->(d, _flags) { data = d }) do
46
+ @appender.send(level, @message, key1: 1, key2: 'a')
47
47
  end
48
48
  hash = JSON.parse(data)
49
49
  assert_equal @message, hash['message']
@@ -53,7 +53,6 @@ module Appender
53
53
  assert_equal 1, payload['key1'], payload
54
54
  assert_equal 'a', payload['key2'], payload
55
55
  end
56
-
57
56
  end
58
57
  end
59
58
  end
@@ -41,8 +41,8 @@ module Appender
41
41
  @time = Time.new
42
42
  @mock_logger = MockLogger.new
43
43
  @appender = SemanticLogger::Appender::Wrapper.new(logger: @mock_logger)
44
- @hash = {session_id: 'HSSKLEU@JDK767', tracking_number: 12345}
45
- @hash_str = @hash.inspect.sub("{", "\\{").sub("}", "\\}")
44
+ @hash = {session_id: 'HSSKLEU@JDK767', tracking_number: 12_345}
45
+ @hash_str = @hash.inspect.sub('{', '\\{').sub('}', '\\}')
46
46
  @thread_name = Thread.current.name
47
47
  @file_name_reg_exp = ' wrapper_test.rb:\d+'
48
48
  end
@@ -90,7 +90,6 @@ module Appender
90
90
  end
91
91
  end
92
92
  end
93
-
94
93
  end
95
94
  end
96
95
  end
@@ -113,6 +113,5 @@ class TestLogger < Minitest::Test
113
113
  assert_equal 'hello world', log.message
114
114
  assert_equal :info, log.level
115
115
  end
116
-
117
116
  end
118
117
  end
@@ -77,6 +77,5 @@ class DebugAsTraceLoggerTest < Minitest::Test
77
77
  assert_equal :trace, log.level
78
78
  end
79
79
  end
80
-
81
80
  end
82
81
  end
@@ -70,7 +70,7 @@ module SemanticLogger
70
70
 
71
71
  describe 'tags' do
72
72
  it 'logs tags' do
73
- log.tags = %w(first second third)
73
+ log.tags = %w[first second third]
74
74
  assert_equal "[#{color}first#{clear}] [#{color}second#{clear}] [#{color}third#{clear}]", formatter.tags
75
75
  end
76
76
  end
@@ -131,23 +131,22 @@ module SemanticLogger
131
131
 
132
132
  describe 'call' do
133
133
  it 'returns minimal elements' do
134
- assert_equal "#{expected_time} #{color}D#{clear} [#{$$}:#{Thread.current.name}] #{color}ColorTest#{clear}", formatter.call(log, nil)
134
+ assert_equal "#{expected_time} #{color}D#{clear} [#{$PROCESS_ID}:#{Thread.current.name}] #{color}ColorTest#{clear}", formatter.call(log, nil)
135
135
  end
136
136
 
137
137
  it 'retuns all elements' do
138
- log.tags = %w(first second third)
138
+ log.tags = %w[first second third]
139
139
  log.named_tags = {first: 1, second: 2, third: 3}
140
140
  log.duration = 1.34567
141
- log.message = "Hello World"
141
+ log.message = 'Hello World'
142
142
  log.payload = {first: 1, second: 2, third: 3}
143
143
  log.backtrace = backtrace
144
144
  set_exception
145
145
  duration = SemanticLogger::Formatters::Base::PRECISION == 3 ? '1' : '1.346'
146
- str = "#{expected_time} #{color}D#{clear} [#{$$}:#{Thread.current.name} default_test.rb:35] [#{color}first#{clear}] [#{color}second#{clear}] [#{color}third#{clear}] {#{color}first: 1#{clear}, #{color}second: 2#{clear}, #{color}third: 3#{clear}} (#{bold}#{duration}ms#{clear}) #{color}ColorTest#{clear} -- Hello World -- #{{:first => 1, :second => 2, :third => 3}.ai(multiline: false)} -- Exception: #{color}RuntimeError: Oh no#{clear}\n"
146
+ str = "#{expected_time} #{color}D#{clear} [#{$PROCESS_ID}:#{Thread.current.name} default_test.rb:35] [#{color}first#{clear}] [#{color}second#{clear}] [#{color}third#{clear}] {#{color}first: 1#{clear}, #{color}second: 2#{clear}, #{color}third: 3#{clear}} (#{bold}#{duration}ms#{clear}) #{color}ColorTest#{clear} -- Hello World -- #{{first: 1, second: 2, third: 3}.ai(multiline: false)} -- Exception: #{color}RuntimeError: Oh no#{clear}\n"
147
147
  assert_equal str, formatter.call(log, nil).lines.first
148
148
  end
149
149
  end
150
-
151
150
  end
152
151
  end
153
152
  end
@@ -56,7 +56,7 @@ module SemanticLogger
56
56
  end
57
57
 
58
58
  it 'supports time_format' do
59
- formatter = SemanticLogger::Formatters::Default.new(time_format: "%H:%M:%S")
59
+ formatter = SemanticLogger::Formatters::Default.new(time_format: '%H:%M:%S')
60
60
  formatter.call(log, nil)
61
61
  assert_equal '08:32:05', formatter.time
62
62
  end
@@ -70,53 +70,53 @@ module SemanticLogger
70
70
 
71
71
  describe 'process_info' do
72
72
  it 'logs pid and thread name' do
73
- assert_equal "[#{$$}:#{Thread.current.name}]", formatter.process_info
73
+ assert_equal "[#{$PROCESS_ID}:#{Thread.current.name}]", formatter.process_info
74
74
  end
75
75
 
76
76
  it 'logs pid, thread name, and file name' do
77
77
  set_exception
78
78
  log.backtrace = backtrace
79
- assert_equal "[#{$$}:#{Thread.current.name} default_test.rb:99]", formatter.process_info
79
+ assert_equal "[#{$PROCESS_ID}:#{Thread.current.name} default_test.rb:99]", formatter.process_info
80
80
  end
81
81
  end
82
82
 
83
83
  describe 'tags' do
84
84
  it 'logs tags' do
85
- log.tags = %w(first second third)
86
- assert_equal "[first] [second] [third]", formatter.tags
85
+ log.tags = %w[first second third]
86
+ assert_equal '[first] [second] [third]', formatter.tags
87
87
  end
88
88
  end
89
89
 
90
90
  describe 'named_tags' do
91
91
  it 'logs named tags' do
92
92
  log.named_tags = {first: 1, second: 2, third: 3}
93
- assert_equal "{first: 1, second: 2, third: 3}", formatter.named_tags
93
+ assert_equal '{first: 1, second: 2, third: 3}', formatter.named_tags
94
94
  end
95
95
  end
96
96
 
97
97
  describe 'duration' do
98
98
  it 'logs long duration' do
99
99
  log.duration = 1_000_000.34567
100
- assert_equal "(16m 40s)", formatter.duration
100
+ assert_equal '(16m 40s)', formatter.duration
101
101
  end
102
102
 
103
103
  it 'logs short duration' do
104
104
  log.duration = 1.34567
105
- duration = SemanticLogger::Formatters::Base::PRECISION == 3 ? "(1ms)" : "(1.346ms)"
105
+ duration = SemanticLogger::Formatters::Base::PRECISION == 3 ? '(1ms)' : '(1.346ms)'
106
106
  assert_equal duration, formatter.duration
107
107
  end
108
108
  end
109
109
 
110
110
  describe 'name' do
111
111
  it 'logs name' do
112
- assert_equal "DefaultTest", formatter.name
112
+ assert_equal 'DefaultTest', formatter.name
113
113
  end
114
114
  end
115
115
 
116
116
  describe 'message' do
117
117
  it 'logs message' do
118
- log.message = "Hello World"
119
- assert_equal "-- Hello World", formatter.message
118
+ log.message = 'Hello World'
119
+ assert_equal '-- Hello World', formatter.message
120
120
  end
121
121
 
122
122
  it 'skips empty message' do
@@ -127,7 +127,7 @@ module SemanticLogger
127
127
  describe 'payload' do
128
128
  it 'logs hash payload' do
129
129
  log.payload = {first: 1, second: 2, third: 3}
130
- assert_equal "-- {:first=>1, :second=>2, :third=>3}", formatter.payload
130
+ assert_equal '-- {:first=>1, :second=>2, :third=>3}', formatter.payload
131
131
  end
132
132
 
133
133
  it 'skips nil payload' do
@@ -153,23 +153,22 @@ module SemanticLogger
153
153
 
154
154
  describe 'call' do
155
155
  it 'returns minimal elements' do
156
- assert_equal "#{expected_time} D [#{$$}:#{Thread.current.name}] DefaultTest", formatter.call(log, nil)
156
+ assert_equal "#{expected_time} D [#{$PROCESS_ID}:#{Thread.current.name}] DefaultTest", formatter.call(log, nil)
157
157
  end
158
158
 
159
159
  it 'retuns all elements' do
160
- log.tags = %w(first second third)
160
+ log.tags = %w[first second third]
161
161
  log.named_tags = {first: 1, second: 2, third: 3}
162
162
  log.duration = 1.34567
163
- log.message = "Hello World"
163
+ log.message = 'Hello World'
164
164
  log.payload = {first: 1, second: 2, third: 3}
165
165
  log.backtrace = backtrace
166
166
  set_exception
167
167
  duration = SemanticLogger::Formatters::Base::PRECISION == 3 ? '1' : '1.346'
168
- str = "#{expected_time} D [#{$$}:#{Thread.current.name} default_test.rb:99] [first] [second] [third] {first: 1, second: 2, third: 3} (#{duration}ms) DefaultTest -- Hello World -- {:first=>1, :second=>2, :third=>3} -- Exception: RuntimeError: Oh no\n"
168
+ str = "#{expected_time} D [#{$PROCESS_ID}:#{Thread.current.name} default_test.rb:99] [first] [second] [third] {first: 1, second: 2, third: 3} (#{duration}ms) DefaultTest -- Hello World -- {:first=>1, :second=>2, :third=>3} -- Exception: RuntimeError: Oh no\n"
169
169
  assert_equal str, formatter.call(log, nil).lines.first
170
170
  end
171
171
  end
172
-
173
172
  end
174
173
  end
175
174
  end
@@ -36,7 +36,7 @@ module SemanticLogger
36
36
  describe 'message' do
37
37
  it 'logs message' do
38
38
  log.message = "Hello \nWorld\n"
39
- assert_equal "-- Hello World", formatter.message
39
+ assert_equal '-- Hello World', formatter.message
40
40
  end
41
41
 
42
42
  it 'skips empty message' do
@@ -54,7 +54,6 @@ module SemanticLogger
54
54
  refute formatter.exception
55
55
  end
56
56
  end
57
-
58
57
  end
59
58
  end
60
59
  end
@@ -23,15 +23,15 @@ module SemanticLogger
23
23
  let :logs do
24
24
  3.times.collect do |i|
25
25
  l = log.dup
26
- l.metric = "/user/login#{i+1}"
26
+ l.metric = "/user/login#{i + 1}"
27
27
  l
28
28
  end
29
29
  end
30
30
 
31
31
  let :same_logs do
32
- 3.times.collect do |i|
32
+ 3.times.collect do |_i|
33
33
  l = log.dup
34
- l.metric = "/user/login"
34
+ l.metric = '/user/login'
35
35
  l
36
36
  end
37
37
  end
@@ -73,7 +73,7 @@ module SemanticLogger
73
73
  assert_equal counter_metric_name, counter['metric'], counter
74
74
  assert_equal 1, counter['value'], counter
75
75
  assert_equal (log.time.to_i * 1_000).to_i, counter['timestamp'], counter
76
- assert counter.has_key?('dimensions')
76
+ assert counter.key?('dimensions')
77
77
  end
78
78
 
79
79
  it 'send gauge metric when log includes duration' do
@@ -84,7 +84,7 @@ module SemanticLogger
84
84
  assert_equal average_metric_name, counter['metric'], counter
85
85
  assert_equal 1234, counter['value'], counter
86
86
  assert_equal (log.time.to_i * 1_000).to_i, counter['timestamp'], counter
87
- assert counter.has_key?('dimensions')
87
+ assert counter.key?('dimensions')
88
88
  end
89
89
 
90
90
  it 'also sends counter metric when gauge metric is sent' do
@@ -95,12 +95,12 @@ module SemanticLogger
95
95
  assert_equal counter_metric_name, counter['metric'], counter
96
96
  assert_equal 1, counter['value'], counter
97
97
  assert_equal (log.time.to_i * 1_000).to_i, counter['timestamp'], counter
98
- assert counter.has_key?('dimensions')
98
+ assert counter.key?('dimensions')
99
99
  end
100
100
 
101
101
  it 'only forwards whitelisted dimensions from named_tags' do
102
102
  log.named_tags = {user_id: 47, tracking_number: 7474, session_id: 'hsdhngsd'}
103
- formatter.dimensions = [:user_id, :application]
103
+ formatter.dimensions = %i[user_id application]
104
104
  hash = result
105
105
  assert counters = hash['counter'], hash
106
106
  assert counter = counters.first, hash
@@ -156,7 +156,7 @@ module SemanticLogger
156
156
 
157
157
  describe 'send custom' do
158
158
  let :logs do
159
- 3.times.collect do |i|
159
+ 3.times.collect do |_i|
160
160
  l = log.dup
161
161
  l.metric = 'Filter/count'
162
162
  l.dimensions = dimensions
@@ -175,7 +175,6 @@ module SemanticLogger
175
175
  assert_equal all_dimensions, counter['dimensions']
176
176
  end
177
177
  end
178
-
179
178
  end
180
179
 
181
180
  describe 'format batch logs with aggregation' do
@@ -192,9 +191,7 @@ module SemanticLogger
192
191
  assert_equal 3, counters[0]['value']
193
192
  end
194
193
  end
195
-
196
194
  end
197
-
198
195
  end
199
196
  end
200
197
  end
@@ -18,15 +18,15 @@ class FormattersTest < Minitest::Test
18
18
  end
19
19
 
20
20
  it 'from a Hash (Symbol with options)' do
21
- assert formatter = SemanticLogger::Formatters.factory(raw: {time_format: "%Y%m%d"})
21
+ assert formatter = SemanticLogger::Formatters.factory(raw: {time_format: '%Y%m%d'})
22
22
  assert formatter.is_a?(SemanticLogger::Formatters::Raw)
23
23
  assert result = formatter.call(log, appender)
24
24
  assert_equal 'Test', result[:name]
25
- assert_equal Time.now.strftime("%Y%m%d"), result[:time]
25
+ assert_equal Time.now.strftime('%Y%m%d'), result[:time]
26
26
  end
27
27
 
28
28
  it 'from block' do
29
- my_formatter = -> log, appender { log.name }
29
+ my_formatter = ->(log, _appender) { log.name }
30
30
  assert formatter = SemanticLogger::Formatters.factory(my_formatter)
31
31
  assert formatter.is_a?(Proc)
32
32
  assert_equal 'Test', formatter.call(log, appender)
@@ -6,4 +6,3 @@ class InMemoryAppender < SemanticLogger::Subscriber
6
6
  self.message = log
7
7
  end
8
8
  end
9
-
@@ -15,7 +15,7 @@ InMemoryAppenderHelper = shared_description do
15
15
  end
16
16
 
17
17
  let :payload do
18
- {session_id: 'HSSKLEU@JDK767', tracking_number: 12345}
18
+ {session_id: 'HSSKLEU@JDK767', tracking_number: 12_345}
19
19
  end
20
20
 
21
21
  let :logger do
@@ -6,4 +6,3 @@ class InMemoryBatchAppender < SemanticLogger::Subscriber
6
6
  self.message = logs
7
7
  end
8
8
  end
9
-
@@ -11,4 +11,3 @@ class InMemoryMetricsAppender < SemanticLogger::Subscriber
11
11
  log.metric && meets_log_level?(log) && !filtered?(log)
12
12
  end
13
13
  end
14
-
@@ -55,7 +55,7 @@ class AppenderFileTest < Minitest::Test
55
55
  base = Base.new
56
56
  base.perform
57
57
  called = false
58
- Base.logger.stub(:info, -> description { called = true if description == 'perform' }) do
58
+ Base.logger.stub(:info, ->(description) { called = true if description == 'perform' }) do
59
59
  base.perform
60
60
  end
61
61
  assert called, 'Did not call the correct logger'
@@ -65,7 +65,7 @@ class AppenderFileTest < Minitest::Test
65
65
  subclass = Subclass.new
66
66
  subclass.process
67
67
  called = false
68
- Subclass.logger.stub(:info, -> description { called = true if description == 'process' }) do
68
+ Subclass.logger.stub(:info, ->(description) { called = true if description == 'process' }) do
69
69
  subclass.process
70
70
  end
71
71
  assert called, 'Did not call the correct logger'
@@ -99,6 +99,5 @@ class AppenderFileTest < Minitest::Test
99
99
  end
100
100
  end
101
101
  end
102
-
103
102
  end
104
103
  end
data/test/logger_test.rb CHANGED
@@ -11,7 +11,6 @@ class LoggerTest < Minitest::Test
11
11
 
12
12
  # Ensure that any log level can be logged
13
13
  SemanticLogger::LEVELS.each do |level|
14
-
15
14
  describe "##{level}" do
16
15
  describe 'positional parameter' do
17
16
  it 'logs message' do
@@ -44,7 +43,7 @@ class LoggerTest < Minitest::Test
44
43
  assert_equal 'hello world -- Calculations', log.message
45
44
  assert_equal payload, log.payload
46
45
  assert log.backtrace
47
- assert log.backtrace.size > 0, log.backtrace
46
+ assert log.backtrace.size.positive?, log.backtrace
48
47
  end
49
48
  end
50
49
 
@@ -56,7 +55,7 @@ class LoggerTest < Minitest::Test
56
55
  assert log = log_message
57
56
  assert_equal 'hello world', log.message
58
57
  assert log.backtrace
59
- assert log.backtrace.size > 0, log.backtrace
58
+ assert log.backtrace.size.positive?, log.backtrace
60
59
 
61
60
  assert log.exception
62
61
  refute log.exception.backtrace
@@ -153,7 +152,7 @@ class LoggerTest < Minitest::Test
153
152
  describe '#filter' do
154
153
  describe 'at the appender level' do
155
154
  it 'Proc' do
156
- appender.filter = -> log { (/\AExclude/ =~ log.message).nil? }
155
+ appender.filter = ->(log) { (/\AExclude/ =~ log.message).nil? }
157
156
  logger.send(level, 'Exclude this log message', @hash) { 'Calculations' }
158
157
 
159
158
  refute log_message
@@ -161,7 +160,7 @@ class LoggerTest < Minitest::Test
161
160
 
162
161
  it 'RegExp' do
163
162
  filter = /\ALogger/
164
- appender.filter = -> log { (/\AExclude/ =~ log.message).nil? }
163
+ appender.filter = ->(log) { (/\AExclude/ =~ log.message).nil? }
165
164
  logger.send(level, 'Exclude this log message', @hash) { 'Calculations' }
166
165
 
167
166
  refute log_message
@@ -170,7 +169,7 @@ class LoggerTest < Minitest::Test
170
169
 
171
170
  describe 'at the logger level' do
172
171
  it 'Proc' do
173
- logger.filter = -> log { (/\AExclude/ =~ log.message).nil? }
172
+ logger.filter = ->(log) { (/\AExclude/ =~ log.message).nil? }
174
173
  logger.send(level, 'Exclude this log message', @hash) { 'Calculations' }
175
174
 
176
175
  refute log_message
@@ -178,13 +177,12 @@ class LoggerTest < Minitest::Test
178
177
 
179
178
  it 'RegExp' do
180
179
  filter = /\ALogger/
181
- logger.filter = -> log { (/\AExclude/ =~ log.message).nil? }
180
+ logger.filter = ->(log) { (/\AExclude/ =~ log.message).nil? }
182
181
  logger.send(level, 'Exclude this log message', @hash) { 'Calculations' }
183
182
 
184
183
  refute log_message
185
184
  end
186
185
  end
187
-
188
186
  end
189
187
  end
190
188
  end
@@ -204,9 +202,9 @@ class LoggerTest < Minitest::Test
204
202
  it "log Ruby logger #{level} info" do
205
203
  logger.level = Logger::Severity.const_get(level)
206
204
  if level.to_s == 'UNKNOWN'
207
- assert_equal Logger::Severity.const_get('ERROR')+1, logger.send(:level_index)
205
+ assert_equal Logger::Severity.const_get('ERROR') + 1, logger.send(:level_index)
208
206
  else
209
- assert_equal Logger::Severity.const_get(level)+1, logger.send(:level_index)
207
+ assert_equal Logger::Severity.const_get(level) + 1, logger.send(:level_index)
210
208
  end
211
209
  end
212
210
  end
@@ -261,7 +259,7 @@ class LoggerTest < Minitest::Test
261
259
 
262
260
  assert log = log_message
263
261
  assert_equal 'hello world', log.message
264
- assert_equal %w(12345 DJHSFK), log.tags
262
+ assert_equal %w[12345 DJHSFK], log.tags
265
263
  end
266
264
  end
267
265
 
@@ -292,15 +290,14 @@ class LoggerTest < Minitest::Test
292
290
  end
293
291
 
294
292
  it 'is compatible with rails logging that uses arrays and nils' do
295
- logger.tagged('', ['12345', 'DJHSFK'], nil) do
293
+ logger.tagged('', %w[12345 DJHSFK], nil) do
296
294
  logger.info('hello world')
297
295
 
298
296
  assert log = log_message
299
297
  assert_equal 'hello world', log.message
300
- assert_equal %w(12345 DJHSFK), log.tags
298
+ assert_equal %w[12345 DJHSFK], log.tags
301
299
  end
302
300
  end
303
301
  end
304
-
305
302
  end
306
303
  end