semantic_logger 3.4.1 → 4.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/Rakefile +4 -8
- data/lib/semantic_logger.rb +2 -31
- data/lib/semantic_logger/appender.rb +76 -0
- data/lib/semantic_logger/appender/bugsnag.rb +3 -8
- data/lib/semantic_logger/appender/file.rb +1 -1
- data/lib/semantic_logger/appender/honeybadger.rb +1 -1
- data/lib/semantic_logger/appender/http.rb +1 -1
- data/lib/semantic_logger/appender/mongodb.rb +30 -28
- data/lib/semantic_logger/appender/sentry.rb +2 -2
- data/lib/semantic_logger/appender/splunk_http.rb +4 -4
- data/lib/semantic_logger/appender/syslog.rb +2 -2
- data/lib/semantic_logger/appender/tcp.rb +9 -5
- data/lib/semantic_logger/appender/udp.rb +1 -0
- data/lib/semantic_logger/base.rb +73 -140
- data/lib/semantic_logger/core_ext/thread.rb +4 -1
- data/lib/semantic_logger/formatters/color.rb +7 -0
- data/lib/semantic_logger/formatters/default.rb +7 -0
- data/lib/semantic_logger/formatters/syslog.rb +1 -1
- data/lib/semantic_logger/log.rb +115 -12
- data/lib/semantic_logger/logger.rb +6 -215
- data/lib/semantic_logger/metrics/new_relic.rb +1 -1
- data/lib/semantic_logger/metrics/statsd.rb +5 -1
- data/lib/semantic_logger/metrics/udp.rb +80 -0
- data/lib/semantic_logger/processor.rb +235 -0
- data/lib/semantic_logger/semantic_logger.rb +36 -65
- data/lib/semantic_logger/subscriber.rb +2 -2
- data/lib/semantic_logger/version.rb +1 -1
- data/test/appender/bugsnag_test.rb +10 -9
- data/test/appender/elasticsearch_test.rb +3 -2
- data/test/appender/graylog_test.rb +4 -3
- data/test/appender/honeybadger_test.rb +2 -2
- data/test/appender/http_test.rb +3 -2
- data/test/appender/mongodb_test.rb +24 -23
- data/test/appender/new_relic_test.rb +15 -8
- data/test/appender/sentry_test.rb +2 -2
- data/test/appender/splunk_http_test.rb +8 -7
- data/test/appender/splunk_test.rb +6 -5
- data/test/appender/tcp_test.rb +3 -4
- data/test/appender/udp_test.rb +4 -5
- data/test/appender/wrapper_test.rb +37 -38
- data/test/concerns/compatibility_test.rb +2 -2
- data/test/loggable_test.rb +1 -1
- data/test/logger_test.rb +149 -528
- data/test/measure_test.rb +249 -0
- data/test/semantic_logger_test.rb +257 -0
- metadata +24 -16
@@ -99,10 +99,10 @@ module SemanticLogger
|
|
99
99
|
def extract_formatter(formatter, &block)
|
100
100
|
case
|
101
101
|
when formatter.is_a?(Symbol)
|
102
|
-
SemanticLogger.constantize_symbol(formatter, 'SemanticLogger::Formatters').new
|
102
|
+
SemanticLogger::Appender.constantize_symbol(formatter, 'SemanticLogger::Formatters').new
|
103
103
|
when formatter.is_a?(Hash) && formatter.size > 0
|
104
104
|
fmt, options = formatter.first
|
105
|
-
SemanticLogger.constantize_symbol(fmt.to_sym, 'SemanticLogger::Formatters').new(options)
|
105
|
+
SemanticLogger::Appender.constantize_symbol(fmt.to_sym, 'SemanticLogger::Formatters').new(options)
|
106
106
|
when formatter.respond_to?(:call)
|
107
107
|
formatter
|
108
108
|
when block
|
@@ -5,7 +5,7 @@ module Appender
|
|
5
5
|
class BugsnagTest < Minitest::Test
|
6
6
|
describe SemanticLogger::Appender::Bugsnag do
|
7
7
|
before do
|
8
|
-
@appender = SemanticLogger::Appender::Bugsnag.new(:info)
|
8
|
+
@appender = SemanticLogger::Appender::Bugsnag.new(level: :info)
|
9
9
|
@message = 'AppenderBugsnagTest log message'
|
10
10
|
end
|
11
11
|
|
@@ -25,8 +25,8 @@ module Appender
|
|
25
25
|
@appender.send(level, @message)
|
26
26
|
end
|
27
27
|
if [:trace, :debug].include?(level)
|
28
|
-
|
29
|
-
|
28
|
+
assert_nil exception
|
29
|
+
assert_nil hash
|
30
30
|
else
|
31
31
|
assert_equal 'RuntimeError', exception.class.to_s
|
32
32
|
assert_equal @message, exception.message
|
@@ -40,13 +40,14 @@ module Appender
|
|
40
40
|
@appender.send(level, @message, {key1: 1, key2: 'a'})
|
41
41
|
end
|
42
42
|
if [:trace, :debug].include?(level)
|
43
|
-
|
44
|
-
|
43
|
+
assert_nil exception
|
44
|
+
assert_nil hash
|
45
45
|
else
|
46
46
|
assert_equal 'RuntimeError', exception.class.to_s
|
47
47
|
assert_equal @message, exception.message
|
48
|
-
|
49
|
-
assert_equal
|
48
|
+
assert payload = hash[:payload], hash
|
49
|
+
assert_equal 1, payload[:key1], payload
|
50
|
+
assert_equal 'a', payload[:key2], payload
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
@@ -57,8 +58,8 @@ module Appender
|
|
57
58
|
@appender.send(level, @message, error)
|
58
59
|
end
|
59
60
|
if [:trace, :debug].include?(level)
|
60
|
-
|
61
|
-
|
61
|
+
assert_nil exception
|
62
|
+
assert_nil hash
|
62
63
|
else
|
63
64
|
assert_equal error.class.to_s, exception.class.to_s
|
64
65
|
assert_equal error.message, exception.message
|
@@ -64,8 +64,9 @@ module Appender
|
|
64
64
|
assert_equal @message, message['message']
|
65
65
|
assert_equal level.to_s, message['level']
|
66
66
|
refute message['stack_trace']
|
67
|
-
|
68
|
-
assert_equal
|
67
|
+
assert payload = message['payload'], message
|
68
|
+
assert_equal 1, payload['key1'], message
|
69
|
+
assert_equal 'a', payload['key2'], message
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
@@ -21,7 +21,7 @@ module Appender
|
|
21
21
|
|
22
22
|
it 'send exception notifications to Graylog with severity' do
|
23
23
|
hash = nil
|
24
|
-
exc
|
24
|
+
exc = nil
|
25
25
|
begin
|
26
26
|
Uh oh
|
27
27
|
rescue Exception => e
|
@@ -55,8 +55,9 @@ module Appender
|
|
55
55
|
assert_equal @message, hash[:short_message]
|
56
56
|
assert_equal 3, hash[:level]
|
57
57
|
refute hash[:stack_trace]
|
58
|
-
|
59
|
-
assert_equal
|
58
|
+
assert payload = hash[:payload], hash
|
59
|
+
assert_equal 1, payload[:key1], payload
|
60
|
+
assert_equal 'a', payload[:key2], payload
|
60
61
|
end
|
61
62
|
end
|
62
63
|
end
|
@@ -5,8 +5,8 @@ module Appender
|
|
5
5
|
class HoneybadgerTest < Minitest::Test
|
6
6
|
describe SemanticLogger::Appender::Honeybadger do
|
7
7
|
before do
|
8
|
-
@appender
|
9
|
-
@message
|
8
|
+
@appender = SemanticLogger::Appender::Honeybadger.new(:trace)
|
9
|
+
@message = 'AppenderHoneybadgerTest log message'
|
10
10
|
SemanticLogger.backtrace_level = :error
|
11
11
|
end
|
12
12
|
|
data/test/appender/http_test.rb
CHANGED
@@ -53,8 +53,9 @@ module Appender
|
|
53
53
|
assert_equal @message, hash['message']
|
54
54
|
assert_equal level.to_s, hash['level']
|
55
55
|
refute hash['stack_trace']
|
56
|
-
|
57
|
-
assert_equal
|
56
|
+
assert payload = hash['payload'], hash
|
57
|
+
assert_equal 1, payload['key1'], payload
|
58
|
+
assert_equal 'a', payload['key2'], payload
|
58
59
|
end
|
59
60
|
|
60
61
|
end
|
@@ -1,14 +1,12 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
|
3
3
|
# Unit Test for SemanticLogger::Appender::MongoDB
|
4
|
-
#
|
5
4
|
module Appender
|
6
5
|
class MongoDBTest < Minitest::Test
|
7
6
|
describe SemanticLogger::Appender::MongoDB do
|
8
7
|
before do
|
9
|
-
@db = Mongo::Connection.new['test']
|
10
8
|
@appender = SemanticLogger::Appender::MongoDB.new(
|
11
|
-
|
9
|
+
uri: 'mongodb://127.0.0.1:27017/test',
|
12
10
|
collection_size: 10*1024**2, # 10MB
|
13
11
|
host: 'test',
|
14
12
|
application: 'test_application',
|
@@ -25,27 +23,28 @@ module Appender
|
|
25
23
|
describe 'format logs into documents' do
|
26
24
|
it 'handle no arguments' do
|
27
25
|
@appender.debug
|
28
|
-
document = @appender.collection.
|
26
|
+
document = @appender.collection.find.first
|
29
27
|
assert_equal :debug, document['level']
|
30
|
-
|
28
|
+
assert_nil document['message']
|
31
29
|
assert_equal 'thread', document['thread']
|
32
30
|
assert document['time'].is_a?(Time)
|
33
|
-
|
31
|
+
assert_nil document['payload']
|
34
32
|
assert_equal $$, document['pid']
|
35
33
|
assert_equal 'test', document['host']
|
36
34
|
assert_equal 'test_application', document['application']
|
37
35
|
end
|
38
36
|
|
39
|
-
it 'handle
|
40
|
-
@appender.debug(@hash)
|
37
|
+
it 'handle named parameters' do
|
38
|
+
@appender.debug(payload: @hash)
|
41
39
|
|
42
|
-
document = @appender.collection.
|
40
|
+
document = @appender.collection.find.first
|
43
41
|
assert_equal :debug, document['level']
|
44
|
-
|
42
|
+
assert_nil document['message']
|
45
43
|
assert_equal 'thread', document['thread']
|
46
44
|
assert document['time'].is_a?(Time)
|
47
|
-
|
48
|
-
assert_equal
|
45
|
+
assert payload = document['payload']
|
46
|
+
assert_equal 12345, payload['tracking_number'], payload
|
47
|
+
assert_equal 'HSSKLEU@JDK767', payload['session_id']
|
49
48
|
assert_equal $$, document['pid']
|
50
49
|
assert_equal 'test', document['host']
|
51
50
|
assert_equal 'test_application', document['application']
|
@@ -54,13 +53,14 @@ module Appender
|
|
54
53
|
it 'handle message and payload' do
|
55
54
|
@appender.debug('hello world', @hash)
|
56
55
|
|
57
|
-
document = @appender.collection.
|
56
|
+
document = @appender.collection.find.first
|
58
57
|
assert_equal :debug, document['level']
|
59
58
|
assert_equal 'hello world', document['message']
|
60
59
|
assert_equal 'thread', document['thread']
|
61
60
|
assert document['time'].is_a?(Time)
|
62
|
-
|
63
|
-
assert_equal
|
61
|
+
assert payload = document['payload']
|
62
|
+
assert_equal 12345, payload['tracking_number'], payload
|
63
|
+
assert_equal 'HSSKLEU@JDK767', payload['session_id']
|
64
64
|
assert_equal $$, document['pid']
|
65
65
|
assert_equal 'test', document['host']
|
66
66
|
assert_equal 'test_application', document['application']
|
@@ -69,7 +69,7 @@ module Appender
|
|
69
69
|
it 'handle message without payload' do
|
70
70
|
@appender.debug('hello world')
|
71
71
|
|
72
|
-
document = @appender.collection.
|
72
|
+
document = @appender.collection.find.first
|
73
73
|
assert_equal :debug, document['level']
|
74
74
|
assert_equal 'hello world', document['message']
|
75
75
|
assert_equal 'thread', document['thread']
|
@@ -80,18 +80,19 @@ module Appender
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
it '
|
83
|
+
# Ensure that any log level can be logged
|
84
|
+
SemanticLogger::LEVELS.each do |level|
|
85
|
+
describe "##{level}" do
|
86
|
+
it 'logs' do
|
87
87
|
@appender.send(level, 'hello world -- Calculations', @hash)
|
88
|
-
document = @appender.collection.
|
88
|
+
document = @appender.collection.find.first
|
89
89
|
assert_equal level, document['level']
|
90
90
|
assert_equal 'hello world -- Calculations', document['message']
|
91
91
|
assert_equal 'thread', document['thread']
|
92
92
|
assert document['time'].is_a?(Time)
|
93
|
-
|
94
|
-
assert_equal
|
93
|
+
assert payload = document['payload']
|
94
|
+
assert_equal 12345, payload['tracking_number'], payload
|
95
|
+
assert_equal 'HSSKLEU@JDK767', payload['session_id']
|
95
96
|
assert_equal $$, document['pid']
|
96
97
|
assert_equal 'test', document['host'], document.ai
|
97
98
|
assert_equal 'test_application', document['application']
|
@@ -44,9 +44,9 @@ module Appender
|
|
44
44
|
it 'send notification to New Relic with custom attributes' do
|
45
45
|
exception = hash = nil
|
46
46
|
NewRelic::Agent.stub(:notice_error, -> exc, h { exception = exc; hash = h }) do
|
47
|
-
|
48
|
-
|
49
|
-
@appender.
|
47
|
+
SemanticLogger.tagged('test') do
|
48
|
+
SemanticLogger.named_tagged(key1: 1, key2: 'a') do
|
49
|
+
@appender.measure_error(message: @message, payload: {key3: 4}) do
|
50
50
|
sleep 0.001
|
51
51
|
end
|
52
52
|
end
|
@@ -54,11 +54,18 @@ module Appender
|
|
54
54
|
end
|
55
55
|
assert_equal 'RuntimeError', exception.class.to_s
|
56
56
|
assert_equal @message, exception.message
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
assert params = hash[:custom_params], hash
|
58
|
+
assert params[:duration], params
|
59
|
+
assert params[:thread], params
|
60
|
+
|
61
|
+
assert_equal ['test'], params[:tags], params
|
62
|
+
|
63
|
+
assert named_tags = params[:named_tags], params
|
64
|
+
assert_equal 1, named_tags[:key1], named_tags
|
65
|
+
assert_equal 'a', named_tags[:key2], named_tags
|
66
|
+
|
67
|
+
assert payload = params[:payload], params
|
68
|
+
assert_equal 4, payload[:key3], payload
|
62
69
|
end
|
63
70
|
end
|
64
71
|
end
|
@@ -5,8 +5,8 @@ module Appender
|
|
5
5
|
class SentryTest < Minitest::Test
|
6
6
|
describe SemanticLogger::Appender::Sentry do
|
7
7
|
before do
|
8
|
-
@appender
|
9
|
-
@message
|
8
|
+
@appender = SemanticLogger::Appender::Sentry.new(:trace)
|
9
|
+
@message = 'AppenderRavenTest log message'
|
10
10
|
SemanticLogger.backtrace_level = :error
|
11
11
|
end
|
12
12
|
|
@@ -13,7 +13,7 @@ module Appender
|
|
13
13
|
token: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
|
14
14
|
)
|
15
15
|
end
|
16
|
-
@message
|
16
|
+
@message = 'AppenderSplunkHttpTest log message'
|
17
17
|
end
|
18
18
|
|
19
19
|
SemanticLogger::LEVELS.each do |level|
|
@@ -57,12 +57,13 @@ module Appender
|
|
57
57
|
end
|
58
58
|
body = decompress_data(request.body)
|
59
59
|
message = JSON.parse(body)
|
60
|
-
assert message['event'], message.ai
|
61
|
-
assert_equal @message,
|
62
|
-
assert_equal level.to_s,
|
63
|
-
refute
|
64
|
-
|
65
|
-
assert_equal(
|
60
|
+
assert event = message['event'], message.ai
|
61
|
+
assert_equal @message, event['message']
|
62
|
+
assert_equal level.to_s, event['level']
|
63
|
+
refute event['stack_trace']
|
64
|
+
assert payload = event['payload'], event
|
65
|
+
assert_equal(1, payload['key1'], message)
|
66
|
+
assert_equal('a', payload['key2'], message)
|
66
67
|
end
|
67
68
|
end
|
68
69
|
|
@@ -61,11 +61,12 @@ module Appender
|
|
61
61
|
end
|
62
62
|
assert_equal @message, mock.message
|
63
63
|
|
64
|
-
assert mock.event[:event], mock.event.ai
|
65
|
-
assert_equal level,
|
66
|
-
refute
|
67
|
-
|
68
|
-
assert_equal(
|
64
|
+
assert event = mock.event[:event], mock.event.ai
|
65
|
+
assert_equal level, event[:level]
|
66
|
+
refute event[:stack_trace]
|
67
|
+
assert payload = event[:payload]
|
68
|
+
assert_equal(1, payload[:key1], payload)
|
69
|
+
assert_equal('a', payload[:key2], payload)
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
data/test/appender/tcp_test.rb
CHANGED
@@ -3,8 +3,6 @@ require_relative '../test_helper'
|
|
3
3
|
# Unit Test for SemanticLogger::Appender::Tcp
|
4
4
|
module Appender
|
5
5
|
class TcpTest < Minitest::Test
|
6
|
-
response_mock = Struct.new(:code, :body)
|
7
|
-
|
8
6
|
describe SemanticLogger::Appender::Tcp do
|
9
7
|
before do
|
10
8
|
Net::TCPClient.stub_any_instance(:connect, true) do
|
@@ -58,8 +56,9 @@ module Appender
|
|
58
56
|
assert_equal @message, hash['message']
|
59
57
|
assert_equal level.to_s, hash['level']
|
60
58
|
refute hash['stack_trace']
|
61
|
-
|
62
|
-
assert_equal
|
59
|
+
assert payload = hash['payload'], hash
|
60
|
+
assert_equal 1, payload['key1'], payload
|
61
|
+
assert_equal 'a', payload['key2'], payload
|
63
62
|
end
|
64
63
|
|
65
64
|
end
|
data/test/appender/udp_test.rb
CHANGED
@@ -3,12 +3,10 @@ require_relative '../test_helper'
|
|
3
3
|
# Unit Test for SemanticLogger::Appender::Tcp
|
4
4
|
module Appender
|
5
5
|
class UdpTest < Minitest::Test
|
6
|
-
response_mock = Struct.new(:code, :body)
|
7
|
-
|
8
6
|
describe SemanticLogger::Appender::Udp do
|
9
7
|
before do
|
10
8
|
@appender = SemanticLogger::Appender::Udp.new(server: 'localhost:8088')
|
11
|
-
@message
|
9
|
+
@message = 'AppenderUdpTest log message'
|
12
10
|
end
|
13
11
|
|
14
12
|
SemanticLogger::LEVELS.each do |level|
|
@@ -51,8 +49,9 @@ module Appender
|
|
51
49
|
assert_equal @message, hash['message']
|
52
50
|
assert_equal level.to_s, hash['level']
|
53
51
|
refute hash['stack_trace']
|
54
|
-
|
55
|
-
assert_equal
|
52
|
+
assert payload = hash['payload'], hash
|
53
|
+
assert_equal 1, payload['key1'], payload
|
54
|
+
assert_equal 'a', payload['key2'], payload
|
56
55
|
end
|
57
56
|
|
58
57
|
end
|
@@ -6,59 +6,58 @@ module Appender
|
|
6
6
|
class WrapperTest < Minitest::Test
|
7
7
|
describe SemanticLogger::Appender::Wrapper do
|
8
8
|
before do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
@
|
13
|
-
@
|
9
|
+
SemanticLogger.default_level = :trace
|
10
|
+
SemanticLogger.backtrace_level = :trace
|
11
|
+
|
12
|
+
@time = Time.new
|
13
|
+
@mock_logger = MockLogger.new
|
14
|
+
@appender = SemanticLogger::Appender::Wrapper.new(@mock_logger)
|
15
|
+
@hash = {session_id: 'HSSKLEU@JDK767', tracking_number: 12345}
|
16
|
+
@hash_str = @hash.inspect.sub("{", "\\{").sub("}", "\\}")
|
17
|
+
@thread_name = Thread.current.name
|
18
|
+
@file_name_reg_exp = ' wrapper_test.rb:\d+'
|
14
19
|
end
|
15
20
|
|
16
21
|
describe 'format logs into text form' do
|
17
|
-
it '
|
18
|
-
|
19
|
-
|
20
|
-
log.level = :debug
|
21
|
-
@appender.log(log)
|
22
|
-
assert_match(/\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:\] /, @mock_logger.message)
|
22
|
+
it 'logs blank data' do
|
23
|
+
@appender.debug
|
24
|
+
assert_match(/\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:#{@thread_name}#{@file_name_reg_exp}\] SemanticLogger::Appender::Wrapper/, @mock_logger.message)
|
23
25
|
end
|
24
26
|
|
25
|
-
it '
|
26
|
-
|
27
|
-
|
28
|
-
log.level = :debug
|
29
|
-
log.name = 'class'
|
30
|
-
@appender.log(log)
|
31
|
-
assert_match(/\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:\] class/, @mock_logger.message)
|
27
|
+
it 'logs message' do
|
28
|
+
@appender.debug('hello world')
|
29
|
+
assert_match(/\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:#{@thread_name}#{@file_name_reg_exp}\] SemanticLogger::Appender::Wrapper -- hello world/, @mock_logger.message)
|
32
30
|
end
|
33
31
|
|
34
|
-
it '
|
35
|
-
|
36
|
-
|
37
|
-
log.level = :debug
|
38
|
-
log.name = 'class'
|
39
|
-
log.message = 'hello world'
|
40
|
-
@appender.log(log)
|
41
|
-
assert_match(/\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:\] class -- hello world/, @mock_logger.message)
|
32
|
+
it 'logs message and payload' do
|
33
|
+
@appender.debug('hello world', @hash)
|
34
|
+
assert_match(/\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:#{@thread_name}#{@file_name_reg_exp}\] SemanticLogger::Appender::Wrapper -- hello world -- #{@hash_str}/, @mock_logger.message)
|
42
35
|
end
|
43
36
|
|
44
|
-
it '
|
45
|
-
|
46
|
-
|
47
|
-
log.level = :debug
|
48
|
-
log.name = 'class'
|
49
|
-
log.message = 'hello world'
|
50
|
-
log.payload = @hash
|
51
|
-
@appender.log(log)
|
52
|
-
assert_match(/\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:\] class -- hello world -- #{@hash_str}/, @mock_logger.message)
|
37
|
+
it 'logs named parameters' do
|
38
|
+
@appender.debug(message: 'hello world', payload: @hash)
|
39
|
+
assert_match(/\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:#{@thread_name}#{@file_name_reg_exp}\] SemanticLogger::Appender::Wrapper -- hello world -- #{@hash_str}/, @mock_logger.message)
|
53
40
|
end
|
54
41
|
end
|
55
42
|
|
56
43
|
describe 'for each log level' do
|
44
|
+
before do
|
45
|
+
@appender = SemanticLogger.add_appender(logger: @mock_logger)
|
46
|
+
@logger = SemanticLogger[WrapperTest]
|
47
|
+
end
|
48
|
+
|
49
|
+
after do
|
50
|
+
SemanticLogger.remove_appender(@appender)
|
51
|
+
end
|
52
|
+
|
57
53
|
# Ensure that any log level can be logged
|
58
54
|
Logger::Severity.constants.each do |level|
|
59
|
-
it "log #{level.downcase.to_sym}
|
60
|
-
|
61
|
-
|
55
|
+
it "log #{level.downcase.to_sym}" do
|
56
|
+
level_char = level[0].upcase
|
57
|
+
level_char = 'E' if level_char == 'U'
|
58
|
+
@logger.send(level.downcase.to_sym, 'hello world', @hash)
|
59
|
+
SemanticLogger.flush
|
60
|
+
assert_match(/\d+-\d+-\d+ \d+:\d+:\d+.\d+ #{level_char} \[\d+:#{@thread_name}#{@file_name_reg_exp}\] Appender::WrapperTest -- hello world -- #{@hash_str}/, @mock_logger.message)
|
62
61
|
end
|
63
62
|
end
|
64
63
|
end
|