semantic_logger 2.16.0 → 2.17.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,27 +9,31 @@ class LoggerTest < Minitest::Test
9
9
  before do
10
10
  # Use a mock logger that just keeps the last logged entry in an instance
11
11
  # variable
12
- SemanticLogger.default_level = :trace
13
- @mock_logger = MockLogger.new
14
- appender = SemanticLogger.add_appender(@mock_logger)
15
- appender.filter = filter
12
+ SemanticLogger.default_level = :trace
13
+ SemanticLogger.backtrace_level = nil
14
+ @mock_logger = MockLogger.new
15
+ @appender = SemanticLogger.add_appender(@mock_logger)
16
+ @appender.filter = filter
16
17
 
17
18
  # Add mock metric subscriber
18
- $last_metric = nil
19
+ $last_metric = nil
19
20
  SemanticLogger.on_metric do |log_struct|
20
21
  $last_metric = log_struct.dup
21
22
  end
22
23
 
23
24
  # Use this test's class name as the application name in the log output
24
- @logger = SemanticLogger[LoggerTest]
25
- @hash = {session_id: 'HSSKLEU@JDK767', tracking_number: 12345}
26
- @hash_str = @hash.inspect.sub("{", "\\{").sub("}", "\\}")
25
+ @logger = SemanticLogger[LoggerTest]
26
+ @hash = {session_id: 'HSSKLEU@JDK767', tracking_number: 12345}
27
+ @hash_str = @hash.inspect.sub("{", "\\{").sub("}", "\\}")
28
+ @thread_name = Thread.current.name
29
+ @file_name_reg_exp = RUBY_VERSION.to_f <= 2.0 ? ' (mock|logger_test).rb:\d+' : ' logger_test.rb:\d+'
30
+
27
31
  assert_equal [], @logger.tags
32
+ assert_equal 65535, SemanticLogger.backtrace_level_index
28
33
  end
29
34
 
30
35
  after do
31
- # Remove all appenders
32
- SemanticLogger.appenders.each { |appender| SemanticLogger.remove_appender(appender) }
36
+ SemanticLogger.remove_appender(@appender)
33
37
  end
34
38
 
35
39
  # Ensure that any log level can be logged
@@ -37,47 +41,55 @@ class LoggerTest < Minitest::Test
37
41
  level_char = level.to_s.upcase[0]
38
42
 
39
43
  describe level do
40
- it "log" do
41
- @logger.send(level, 'hello world', @hash) { "Calculations" }
44
+ it 'logs' do
45
+ @logger.send(level, 'hello world', @hash) { 'Calculations' }
42
46
  SemanticLogger.flush
43
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:.+\] LoggerTest -- hello world -- Calculations -- #{@hash_str}/, @mock_logger.message
47
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:#{@thread_name}\] LoggerTest -- hello world -- Calculations -- #{@hash_str}/, @mock_logger.message
44
48
  end
45
49
 
46
- it "exclude log messages using Proc filter" do
50
+ it 'exclude log messages using Proc filter' do
47
51
  if filter.is_a?(Proc)
48
- @logger.send(level, 'Exclude this log message', @hash) { "Calculations" }
52
+ @logger.send(level, 'Exclude this log message', @hash) { 'Calculations' }
49
53
  SemanticLogger.flush
50
54
  assert_nil @mock_logger.message
51
55
  end
52
56
  end
53
57
 
54
- it "exclude log messages using RegExp filter" do
58
+ it 'exclude log messages using RegExp filter' do
55
59
  if filter.is_a?(Regexp)
56
60
  logger = SemanticLogger::Logger.new('NotLogger', :trace, filter)
57
- logger.send(level, 'Ignore all log messages from this class', @hash) { "Calculations" }
61
+ logger.send(level, 'Ignore all log messages from this class', @hash) { 'Calculations' }
58
62
  SemanticLogger.flush
59
63
  assert_nil @mock_logger.message
60
64
  end
61
65
  end
62
66
 
67
+ it "logs #{level} info with backtrace" do
68
+ SemanticLogger.stub(:backtrace_level_index, 0) do
69
+ @logger.send(level, 'hello world', @hash) { 'Calculations' }
70
+ SemanticLogger.flush
71
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:#{@thread_name}#{@file_name_reg_exp}\] LoggerTest -- hello world -- Calculations -- #{@hash_str}/, @mock_logger.message
72
+ end
73
+ end
74
+
63
75
  end
64
76
  end
65
77
 
66
- describe "tagged logging" do
67
- it "add tags to log entries" do
78
+ describe 'tagged logging' do
79
+ it 'add tags to log entries' do
68
80
  @logger.tagged('12345', 'DJHSFK') do
69
81
  @logger.info('Hello world')
70
82
  SemanticLogger.flush
71
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ I \[\d+:.+\] \[12345\] \[DJHSFK\] LoggerTest -- Hello world/, @mock_logger.message
83
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ I \[\d+:#{@thread_name}\] \[12345\] \[DJHSFK\] LoggerTest -- Hello world/, @mock_logger.message
72
84
  end
73
85
  end
74
86
 
75
- it "add embedded tags to log entries" do
87
+ it 'add embedded tags to log entries' do
76
88
  @logger.tagged('First Level', 'tags') do
77
89
  @logger.tagged('Second Level') do
78
90
  @logger.info('Hello world')
79
91
  SemanticLogger.flush
80
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ I \[\d+:.+\] \[First Level\] \[tags\] \[Second Level\] LoggerTest -- Hello world/, @mock_logger.message
92
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ I \[\d+:#{@thread_name}\] \[First Level\] \[tags\] \[Second Level\] LoggerTest -- Hello world/, @mock_logger.message
81
93
  end
82
94
  assert_equal 2, @logger.tags.count, @logger.tags
83
95
  assert_equal 'First Level', @logger.tags.first
@@ -85,20 +97,20 @@ class LoggerTest < Minitest::Test
85
97
  end
86
98
  end
87
99
 
88
- it "add payload to log entries" do
100
+ it 'add payload to log entries' do
89
101
  hash = {tracking_number: "123456", even: 2, more: "data"}
90
102
  hash_str = hash.inspect.sub("{", "\\{").sub("}", "\\}")
91
103
  @logger.with_payload(tracking_number: '123456') do
92
104
  @logger.with_payload(even: 2, more: 'data') do
93
105
  @logger.info('Hello world')
94
106
  SemanticLogger.flush
95
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ I \[\d+:.+\] LoggerTest -- Hello world -- #{hash_str}/, @mock_logger.message
107
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ I \[\d+:#{@thread_name}\] LoggerTest -- Hello world -- #{hash_str}/, @mock_logger.message
96
108
  end
97
109
  end
98
110
  end
99
111
  end
100
112
 
101
- describe "Ruby Logger" do
113
+ describe 'Ruby Logger' do
102
114
  # Ensure that any log level can be logged
103
115
  Logger::Severity.constants.each do |level|
104
116
  it "log Ruby logger #{level} info" do
@@ -112,34 +124,34 @@ class LoggerTest < Minitest::Test
112
124
  end
113
125
  end
114
126
 
115
- describe "benchmark" do
127
+ describe 'benchmark' do
116
128
  # Ensure that any log level can be benchmarked and logged
117
129
  SemanticLogger::LEVELS.each do |level|
118
130
  level_char = level.to_s.upcase[0]
119
131
 
120
132
  describe 'direct method' do
121
133
  it "log #{level} info" do
122
- assert_equal "result", @logger.send("benchmark_#{level}".to_sym, 'hello world') { "result" } # Measure duration of the supplied block
134
+ assert_equal 'result', @logger.send("benchmark_#{level}".to_sym, 'hello world') { 'result' } # Measure duration of the supplied block
123
135
  SemanticLogger.flush
124
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:.+\] \(\d+\.\dms\) LoggerTest -- hello world/, @mock_logger.message
136
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:#{@thread_name}\] \(\d+\.\dms\) LoggerTest -- hello world/, @mock_logger.message
125
137
  end
126
138
 
127
139
  it "log #{level} info with payload" do
128
- assert_equal "result", @logger.send("benchmark_#{level}".to_sym, 'hello world', payload: @hash) { "result" } # Measure duration of the supplied block
140
+ assert_equal 'result', @logger.send("benchmark_#{level}".to_sym, 'hello world', payload: @hash) { 'result' } # Measure duration of the supplied block
129
141
  SemanticLogger.flush
130
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:.+\] \(\d+\.\dms\) LoggerTest -- hello world -- #{@hash_str}/, @mock_logger.message
142
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:#{@thread_name}\] \(\d+\.\dms\) LoggerTest -- hello world -- #{@hash_str}/, @mock_logger.message
131
143
  end
132
144
 
133
145
  it "not log #{level} info when block is faster than :min_duration" do
134
- assert_equal "result", @logger.send("benchmark_#{level}".to_sym, 'hello world', min_duration: 500) { "result" } # Measure duration of the supplied block
146
+ assert_equal 'result', @logger.send("benchmark_#{level}".to_sym, 'hello world', min_duration: 500) { 'result' } # Measure duration of the supplied block
135
147
  SemanticLogger.flush
136
148
  assert_nil @mock_logger.message
137
149
  end
138
150
 
139
151
  it "log #{level} info when block duration exceeds :min_duration" do
140
- assert_equal "result", @logger.send("benchmark_#{level}".to_sym, 'hello world', min_duration: 200, payload: @hash) { sleep 0.5; "result" } # Measure duration of the supplied block
152
+ assert_equal 'result', @logger.send("benchmark_#{level}".to_sym, 'hello world', min_duration: 200, payload: @hash) { sleep 0.5; 'result' } # Measure duration of the supplied block
141
153
  SemanticLogger.flush
142
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:.+\] \(\d+\.\dms\) LoggerTest -- hello world -- #{@hash_str}/, @mock_logger.message
154
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:#{@thread_name}\] \(\d+\.\dms\) LoggerTest -- hello world -- #{@hash_str}/, @mock_logger.message
143
155
  end
144
156
 
145
157
  it "log #{level} info with an exception" do
@@ -147,7 +159,7 @@ class LoggerTest < Minitest::Test
147
159
  @logger.send("benchmark_#{level}", 'hello world', payload: @hash) { raise RuntimeError.new("Test") } # Measure duration of the supplied block
148
160
  end
149
161
  SemanticLogger.flush
150
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:.+\] \(\d+\.\dms\) LoggerTest -- hello world -- Exception: RuntimeError: Test -- #{@hash_str}/, @mock_logger.message
162
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:#{@thread_name}#{@file_name_reg_exp}\] \(\d+\.\dms\) LoggerTest -- hello world -- Exception: RuntimeError: Test -- #{@hash_str}/, @mock_logger.message
151
163
  end
152
164
 
153
165
  it "change log #{level} info with an exception" do
@@ -155,65 +167,81 @@ class LoggerTest < Minitest::Test
155
167
  @logger.send("benchmark_#{level}", 'hello world', payload: @hash, on_exception_level: :fatal) { raise RuntimeError.new("Test") } # Measure duration of the supplied block
156
168
  end
157
169
  SemanticLogger.flush
158
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ F \[\d+:.+\] \(\d+\.\dms\) LoggerTest -- hello world -- Exception: RuntimeError: Test -- #{@hash_str}/, @mock_logger.message
170
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ F \[\d+:#{@thread_name}#{@file_name_reg_exp}\] \(\d+\.\dms\) LoggerTest -- hello world -- Exception: RuntimeError: Test -- #{@hash_str}/, @mock_logger.message
159
171
  end
160
172
 
161
173
  it "log #{level} info with metric" do
162
174
  metric_name = '/my/custom/metric'
163
- assert_equal "result", @logger.send("benchmark_#{level}".to_sym, 'hello world', metric: metric_name) { "result" } # Measure duration of the supplied block
175
+ assert_equal 'result', @logger.send("benchmark_#{level}".to_sym, 'hello world', metric: metric_name) { 'result' } # Measure duration of the supplied block
164
176
  SemanticLogger.flush
165
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:.+\] \(\d+\.\dms\) LoggerTest -- hello world/, @mock_logger.message
177
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:#{@thread_name}\] \(\d+\.\dms\) LoggerTest -- hello world/, @mock_logger.message
166
178
  assert metric_name, $last_metric.metric
167
179
  end
180
+
181
+ it "log #{level} info with backtrace" do
182
+ SemanticLogger.stub(:backtrace_level_index, 0) do
183
+ assert_equal 'result', @logger.send("benchmark_#{level}".to_sym, 'hello world') { 'result' }
184
+ SemanticLogger.flush
185
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:#{@thread_name}#{@file_name_reg_exp}\] \(\d+\.\dms\) LoggerTest -- hello world/, @mock_logger.message
186
+ end
187
+ end
168
188
  end
169
189
 
170
190
  describe 'generic method' do
171
191
  it "log #{level} info" do
172
- assert_equal "result", @logger.benchmark(level, 'hello world') { "result" } # Measure duration of the supplied block
192
+ assert_equal 'result', @logger.benchmark(level, 'hello world') { 'result' } # Measure duration of the supplied block
173
193
  SemanticLogger.flush
174
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:.+\] \(\d+\.\dms\) LoggerTest -- hello world/, @mock_logger.message
194
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:#{@thread_name}\] \(\d+\.\dms\) LoggerTest -- hello world/, @mock_logger.message
175
195
  end
176
196
 
177
197
  it "log #{level} info with payload" do
178
- assert_equal "result", @logger.benchmark(level, 'hello world', payload: @hash) { "result" } # Measure duration of the supplied block
198
+ assert_equal 'result', @logger.benchmark(level, 'hello world', payload: @hash) { 'result' } # Measure duration of the supplied block
179
199
  SemanticLogger.flush
180
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:.+\] \(\d+\.\dms\) LoggerTest -- hello world -- #{@hash_str}/, @mock_logger.message
200
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:#{@thread_name}\] \(\d+\.\dms\) LoggerTest -- hello world -- #{@hash_str}/, @mock_logger.message
181
201
  end
182
202
 
183
203
  it "not log #{level} info when block is faster than :min_duration" do
184
- assert_equal "result", @logger.benchmark(level, 'hello world', min_duration: 500) { "result" } # Measure duration of the supplied block
204
+ assert_equal 'result', @logger.benchmark(level, 'hello world', min_duration: 500) { 'result' } # Measure duration of the supplied block
185
205
  SemanticLogger.flush
186
206
  assert_nil @mock_logger.message
187
207
  end
188
208
 
189
209
  it "log #{level} info when block duration exceeds :min_duration" do
190
- assert_equal "result", @logger.benchmark(level, 'hello world', min_duration: 200, payload: @hash) { sleep 0.5; "result" } # Measure duration of the supplied block
210
+ assert_equal 'result', @logger.benchmark(level, 'hello world', min_duration: 200, payload: @hash) { sleep 0.5; 'result' } # Measure duration of the supplied block
191
211
  SemanticLogger.flush
192
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:.+\] \(\d+\.\dms\) LoggerTest -- hello world -- #{@hash_str}/, @mock_logger.message
212
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:#{@thread_name}\] \(\d+\.\dms\) LoggerTest -- hello world -- #{@hash_str}/, @mock_logger.message
193
213
  end
194
214
 
195
215
  it "log #{level} info with an exception" do
196
216
  assert_raises RuntimeError do
197
- @logger.benchmark(level, 'hello world', payload: @hash) { raise RuntimeError.new("Test") } # Measure duration of the supplied block
217
+ @logger.benchmark(level, 'hello world', payload: @hash) { raise RuntimeError.new('Test') } # Measure duration of the supplied block
198
218
  end
199
219
  SemanticLogger.flush
200
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:.+\] \(\d+\.\dms\) LoggerTest -- hello world -- Exception: RuntimeError: Test -- #{@hash_str}/, @mock_logger.message
220
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:#{@thread_name}#{@file_name_reg_exp}\] \(\d+\.\dms\) LoggerTest -- hello world -- Exception: RuntimeError: Test -- #{@hash_str}/, @mock_logger.message
201
221
  end
202
222
 
203
223
  it "log #{level} info with metric" do
204
224
  metric_name = '/my/custom/metric'
205
- assert_equal "result", @logger.benchmark(level, 'hello world', metric: metric_name) { "result" } # Measure duration of the supplied block
225
+ assert_equal 'result', @logger.benchmark(level, 'hello world', metric: metric_name) { 'result' } # Measure duration of the supplied block
206
226
  SemanticLogger.flush
207
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:.+\] \(\d+\.\dms\) LoggerTest -- hello world/, @mock_logger.message
227
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:#{@thread_name}\] \(\d+\.\dms\) LoggerTest -- hello world/, @mock_logger.message
208
228
  assert metric_name, $last_metric.metric
209
229
  end
230
+
231
+ it "log #{level} info with backtrace" do
232
+ SemanticLogger.stub(:backtrace_level_index, 0) do
233
+ assert_equal 'result', @logger.benchmark(level, 'hello world') { 'result' }
234
+ SemanticLogger.flush
235
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:#{@thread_name}#{@file_name_reg_exp}\] \(\d+\.\dms\) LoggerTest -- hello world/, @mock_logger.message
236
+ end
237
+ end
210
238
  end
211
239
  end
212
240
 
213
- it "log when the block performs a return" do
214
- assert_equal "Good", function_with_return(@logger)
241
+ it 'log when the block performs a return' do
242
+ assert_equal 'Good', function_with_return(@logger)
215
243
  SemanticLogger.flush
216
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ I \[\d+:.+\] \(\d+\.\dms\) LoggerTest -- hello world -- #{@hash_str}/, @mock_logger.message
244
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ I \[\d+:#{@thread_name}\] \(\d+\.\dms\) LoggerTest -- hello world -- #{@hash_str}/, @mock_logger.message
217
245
  end
218
246
 
219
247
  it 'not log at a level below the silence level' do
@@ -222,21 +250,21 @@ class LoggerTest < Minitest::Test
222
250
  @logger.warn "don't log me"
223
251
  end
224
252
  SemanticLogger.flush
225
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ I \[\d+:.+\] \(\d+\.\dms\) LoggerTest -- hello world/, @mock_logger.message
253
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ I \[\d+:#{@thread_name}\] \(\d+\.\dms\) LoggerTest -- hello world/, @mock_logger.message
226
254
  end
227
255
 
228
256
  it 'log at a silence level below the default level' do
229
257
  SemanticLogger.default_level = :info
230
258
  first_message = nil
231
259
  @logger.benchmark_info('hello world', silence: :trace) do
232
- @logger.debug('hello world', @hash) { "Calculations" }
260
+ @logger.debug('hello world', @hash) { 'Calculations' }
233
261
  SemanticLogger.flush
234
262
  first_message = @mock_logger.message
235
263
  end
236
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:.+\] LoggerTest -- hello world -- Calculations -- #{@hash_str}/, first_message
264
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:#{@thread_name}\] LoggerTest -- hello world -- Calculations -- #{@hash_str}/, first_message
237
265
  SemanticLogger.flush
238
266
  # Only the last log message is kept in mock logger
239
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ I \[\d+:.+\] \(\d+\.\dms\) LoggerTest -- hello world/, @mock_logger.message
267
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ I \[\d+:#{@thread_name}\] \(\d+\.\dms\) LoggerTest -- hello world/, @mock_logger.message
240
268
  end
241
269
  end
242
270
 
@@ -248,7 +276,7 @@ class LoggerTest < Minitest::Test
248
276
  it 'not log at a level below the global default' do
249
277
  assert_equal :debug, SemanticLogger.default_level
250
278
  assert_equal :debug, @logger.level
251
- @logger.trace('hello world', @hash) { "Calculations" }
279
+ @logger.trace('hello world', @hash) { 'Calculations' }
252
280
  SemanticLogger.flush
253
281
  assert_nil @mock_logger.message
254
282
  end
@@ -257,16 +285,16 @@ class LoggerTest < Minitest::Test
257
285
  assert_equal :debug, SemanticLogger.default_level
258
286
  @logger.level = :trace
259
287
  assert_equal :trace, @logger.level
260
- @logger.trace('hello world', @hash) { "Calculations" }
288
+ @logger.trace('hello world', @hash) { 'Calculations' }
261
289
  SemanticLogger.flush
262
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ T \[\d+:.+\] LoggerTest -- hello world -- Calculations -- #{@hash_str}/, @mock_logger.message
290
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ T \[\d+:#{@thread_name}\] LoggerTest -- hello world -- Calculations -- #{@hash_str}/, @mock_logger.message
263
291
  end
264
292
 
265
293
  it 'not log at a level below the instance level' do
266
294
  assert_equal :debug, SemanticLogger.default_level
267
295
  @logger.level = :warn
268
296
  assert_equal :warn, @logger.level
269
- @logger.debug('hello world', @hash) { "Calculations" }
297
+ @logger.debug('hello world', @hash) { 'Calculations' }
270
298
  SemanticLogger.flush
271
299
  assert_nil @mock_logger.message
272
300
  end
@@ -281,10 +309,10 @@ class LoggerTest < Minitest::Test
281
309
  assert_equal :info, SemanticLogger.default_level
282
310
  assert_equal :info, @logger.level
283
311
  @logger.silence do
284
- @logger.warn('hello world', @hash) { "Calculations" }
285
- @logger.info('hello world', @hash) { "Calculations" }
286
- @logger.debug('hello world', @hash) { "Calculations" }
287
- @logger.trace('hello world', @hash) { "Calculations" }
312
+ @logger.warn('hello world', @hash) { 'Calculations' }
313
+ @logger.info('hello world', @hash) { 'Calculations' }
314
+ @logger.debug('hello world', @hash) { 'Calculations' }
315
+ @logger.trace('hello world', @hash) { 'Calculations' }
288
316
  end
289
317
  SemanticLogger.flush
290
318
  assert_nil @mock_logger.message
@@ -294,20 +322,20 @@ class LoggerTest < Minitest::Test
294
322
  @logger.level = :trace
295
323
  assert_equal :trace, @logger.level
296
324
  @logger.silence do
297
- @logger.trace('hello world', @hash) { "Calculations" }
325
+ @logger.trace('hello world', @hash) { 'Calculations' }
298
326
  end
299
327
  SemanticLogger.flush
300
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ T \[\d+:.+\] LoggerTest -- hello world -- Calculations -- #{@hash_str}/, @mock_logger.message
328
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ T \[\d+:#{@thread_name}\] LoggerTest -- hello world -- Calculations -- #{@hash_str}/, @mock_logger.message
301
329
  end
302
330
 
303
331
  it 'log at a silence level below the default level' do
304
332
  assert_equal :info, SemanticLogger.default_level
305
333
  assert_equal :info, @logger.level
306
334
  @logger.silence(:debug) do
307
- @logger.debug('hello world', @hash) { "Calculations" }
335
+ @logger.debug('hello world', @hash) { 'Calculations' }
308
336
  end
309
337
  SemanticLogger.flush
310
- assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:.+\] LoggerTest -- hello world -- Calculations -- #{@hash_str}/, @mock_logger.message
338
+ assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:#{@thread_name}\] LoggerTest -- hello world -- Calculations -- #{@hash_str}/, @mock_logger.message
311
339
  end
312
340
  end
313
341
 
@@ -355,9 +383,9 @@ class LoggerTest < Minitest::Test
355
383
  # a function
356
384
  def function_with_return(logger)
357
385
  logger.benchmark_info('hello world', payload: @hash) do
358
- return "Good"
386
+ return 'Good'
359
387
  end
360
- "Bad"
388
+ 'Bad'
361
389
  end
362
390
 
363
391
  end
@@ -10,5 +10,6 @@ require 'minitest/stub_any_instance'
10
10
  require 'semantic_logger'
11
11
  require 'logger'
12
12
  require_relative 'mock_logger'
13
+ require 'awesome_print'
13
14
 
14
- Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
15
+ #Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semantic_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.16.0
4
+ version: 2.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reid Morrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-26 00:00:00.000000000 Z
11
+ date: 2015-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sync_attr
@@ -66,18 +66,18 @@ files:
66
66
  - lib/semantic_logger/logger.rb
67
67
  - lib/semantic_logger/semantic_logger.rb
68
68
  - lib/semantic_logger/version.rb
69
- - test/appender_bugsnag_test.rb
70
- - test/appender_file_test.rb
71
- - test/appender_mongodb_test.rb
72
- - test/appender_new_relic_test.rb
73
- - test/appender_splunk_test.rb
74
- - test/appender_syslog_test.rb
75
- - test/appender_wrapper_test.rb
69
+ - test/appender/bugsnag_test.rb
70
+ - test/appender/file_test.rb
71
+ - test/appender/mongodb_test.rb
72
+ - test/appender/new_relic_test.rb
73
+ - test/appender/newrelic_rpm.rb
74
+ - test/appender/splunk_test.rb
75
+ - test/appender/syslog_test.rb
76
+ - test/appender/wrapper_test.rb
76
77
  - test/debug_as_trace_logger_test.rb
77
78
  - test/loggable_test.rb
78
79
  - test/logger_test.rb
79
80
  - test/mock_logger.rb
80
- - test/newrelic_rpm.rb
81
81
  - test/test_helper.rb
82
82
  homepage: https://github.com/rocketjob/semantic_logger
83
83
  licenses:
@@ -104,16 +104,16 @@ signing_key:
104
104
  specification_version: 4
105
105
  summary: Scalable, next generation enterprise logging for Ruby
106
106
  test_files:
107
- - test/appender_bugsnag_test.rb
108
- - test/appender_file_test.rb
109
- - test/appender_mongodb_test.rb
110
- - test/appender_new_relic_test.rb
111
- - test/appender_splunk_test.rb
112
- - test/appender_syslog_test.rb
113
- - test/appender_wrapper_test.rb
107
+ - test/appender/bugsnag_test.rb
108
+ - test/appender/file_test.rb
109
+ - test/appender/mongodb_test.rb
110
+ - test/appender/new_relic_test.rb
111
+ - test/appender/newrelic_rpm.rb
112
+ - test/appender/splunk_test.rb
113
+ - test/appender/syslog_test.rb
114
+ - test/appender/wrapper_test.rb
114
115
  - test/debug_as_trace_logger_test.rb
115
116
  - test/loggable_test.rb
116
117
  - test/logger_test.rb
117
118
  - test/mock_logger.rb
118
- - test/newrelic_rpm.rb
119
119
  - test/test_helper.rb