semantic_logger 4.3.1 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/semantic_logger.rb +7 -1
- data/lib/semantic_logger/appender.rb +3 -0
- data/lib/semantic_logger/appender/async.rb +29 -10
- data/lib/semantic_logger/appender/rabbitmq.rb +120 -0
- data/lib/semantic_logger/appenders.rb +89 -0
- data/lib/semantic_logger/base.rb +3 -3
- data/lib/semantic_logger/concerns/compatibility.rb +2 -2
- data/lib/semantic_logger/formatters.rb +1 -0
- data/lib/semantic_logger/formatters/base.rb +28 -6
- data/lib/semantic_logger/formatters/color.rb +4 -3
- data/lib/semantic_logger/formatters/fluentd.rb +37 -0
- data/lib/semantic_logger/formatters/json.rb +4 -2
- data/lib/semantic_logger/formatters/raw.rb +2 -2
- data/lib/semantic_logger/formatters/signalfx.rb +4 -3
- data/lib/semantic_logger/levels.rb +38 -0
- data/lib/semantic_logger/log.rb +11 -6
- data/lib/semantic_logger/loggable.rb +1 -1
- data/lib/semantic_logger/logger.rb +43 -1
- data/lib/semantic_logger/processor.rb +10 -130
- data/lib/semantic_logger/reporters/minitest.rb +49 -0
- data/lib/semantic_logger/semantic_logger.rb +40 -75
- data/lib/semantic_logger/version.rb +1 -1
- metadata +9 -81
- data/test/appender/async_batch_test.rb +0 -60
- data/test/appender/async_test.rb +0 -44
- data/test/appender/bugsnag_test.rb +0 -81
- data/test/appender/elasticsearch_http_test.rb +0 -74
- data/test/appender/elasticsearch_test.rb +0 -248
- data/test/appender/file_test.rb +0 -120
- data/test/appender/graylog_test.rb +0 -82
- data/test/appender/honeybadger_test.rb +0 -45
- data/test/appender/http_test.rb +0 -63
- data/test/appender/kafka_test.rb +0 -35
- data/test/appender/mongodb_test.rb +0 -104
- data/test/appender/new_relic_test.rb +0 -80
- data/test/appender/newrelic_rpm.rb +0 -14
- data/test/appender/sentry_test.rb +0 -47
- data/test/appender/splunk_http_test.rb +0 -79
- data/test/appender/splunk_test.rb +0 -83
- data/test/appender/syslog_test.rb +0 -61
- data/test/appender/tcp_test.rb +0 -66
- data/test/appender/udp_test.rb +0 -59
- data/test/appender/wrapper_test.rb +0 -95
- data/test/concerns/compatibility_test.rb +0 -117
- data/test/debug_as_trace_logger_test.rb +0 -81
- data/test/formatters/color_test.rb +0 -153
- data/test/formatters/default_test.rb +0 -175
- data/test/formatters/one_line_test.rb +0 -60
- data/test/formatters/signalfx_test.rb +0 -197
- data/test/formatters_test.rb +0 -36
- data/test/in_memory_appender.rb +0 -8
- data/test/in_memory_appender_helper.rb +0 -43
- data/test/in_memory_batch_appender.rb +0 -8
- data/test/in_memory_metrics_appender.rb +0 -13
- data/test/loggable_test.rb +0 -103
- data/test/logger_test.rb +0 -334
- data/test/measure_test.rb +0 -346
- data/test/metric/new_relic_test.rb +0 -35
- data/test/metric/signalfx_test.rb +0 -77
- data/test/semantic_logger_test.rb +0 -303
- data/test/test_helper.rb +0 -31
@@ -1,79 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
# Unit Test for SemanticLogger::Appender::SplunkHttp
|
4
|
-
module Appender
|
5
|
-
class SplunkHttpTest < Minitest::Test
|
6
|
-
response_mock = Struct.new(:code, :body)
|
7
|
-
|
8
|
-
describe SemanticLogger::Appender::SplunkHttp do
|
9
|
-
before do
|
10
|
-
Net::HTTP.stub_any_instance(:start, true) do
|
11
|
-
@appender = SemanticLogger::Appender::SplunkHttp.new(
|
12
|
-
url: 'http://localhost:8088/path',
|
13
|
-
token: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
|
14
|
-
)
|
15
|
-
end
|
16
|
-
@message = 'AppenderSplunkHttpTest log message'
|
17
|
-
end
|
18
|
-
|
19
|
-
SemanticLogger::LEVELS.each do |level|
|
20
|
-
it "send #{level}" do
|
21
|
-
request = nil
|
22
|
-
@appender.http.stub(:request, ->(r) { request = r; response_mock.new('200', 'ok') }) do
|
23
|
-
@appender.send(level, @message)
|
24
|
-
end
|
25
|
-
body = decompress_data(request.body)
|
26
|
-
message = JSON.parse(body)
|
27
|
-
assert_equal @message, message['event']['message']
|
28
|
-
assert_equal level.to_s, message['event']['level']
|
29
|
-
refute message['event']['exception']
|
30
|
-
end
|
31
|
-
|
32
|
-
it "sends #{level} exceptions" do
|
33
|
-
exc = nil
|
34
|
-
begin
|
35
|
-
Uh oh
|
36
|
-
rescue Exception => e
|
37
|
-
exc = e
|
38
|
-
end
|
39
|
-
request = nil
|
40
|
-
@appender.http.stub(:request, ->(r) { request = r; response_mock.new('200', 'ok') }) do
|
41
|
-
@appender.send(level, 'Reading File', exc)
|
42
|
-
end
|
43
|
-
body = decompress_data(request.body)
|
44
|
-
hash = JSON.parse(body)
|
45
|
-
assert 'Reading File', hash['message']
|
46
|
-
assert exception = hash['event']['exception']
|
47
|
-
assert 'NameError', exception['name']
|
48
|
-
assert 'undefined local variable or method', exception['message']
|
49
|
-
assert_equal level.to_s, hash['event']['level']
|
50
|
-
assert exception['stack_trace'].first.include?(__FILE__), exception
|
51
|
-
end
|
52
|
-
|
53
|
-
it "sends #{level} custom attributes" do
|
54
|
-
request = nil
|
55
|
-
@appender.http.stub(:request, ->(r) { request = r; response_mock.new('200', 'ok') }) do
|
56
|
-
@appender.send(level, @message, key1: 1, key2: 'a')
|
57
|
-
end
|
58
|
-
body = decompress_data(request.body)
|
59
|
-
message = JSON.parse(body)
|
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)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def decompress_data(data)
|
71
|
-
str = StringIO.new(data)
|
72
|
-
gz = Zlib::GzipReader.new(str)
|
73
|
-
raw = gz.read
|
74
|
-
gz.close
|
75
|
-
raw
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
# Unit Test for SemanticLogger::Appender::Splunk
|
4
|
-
#
|
5
|
-
module Appender
|
6
|
-
class SplunkTest < Minitest::Test
|
7
|
-
class Mock
|
8
|
-
attr_accessor :message, :event
|
9
|
-
|
10
|
-
def submit(message, event)
|
11
|
-
self.message = message
|
12
|
-
self.event = event
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe SemanticLogger::Appender::Splunk do
|
17
|
-
before do
|
18
|
-
SemanticLogger::Appender::Splunk.stub_any_instance(:reopen, nil) do
|
19
|
-
@appender = SemanticLogger::Appender::Splunk.new
|
20
|
-
end
|
21
|
-
@message = 'AppenderSplunkTest log message'
|
22
|
-
end
|
23
|
-
|
24
|
-
SemanticLogger::LEVELS.each do |level|
|
25
|
-
it "send #{level}" do
|
26
|
-
mock = Mock.new
|
27
|
-
@appender.stub(:service_index, mock) do
|
28
|
-
@appender.send(level, @message)
|
29
|
-
end
|
30
|
-
assert_equal @message, mock.message
|
31
|
-
assert_equal level, mock.event[:event][:level]
|
32
|
-
refute mock.event[:event][:exception]
|
33
|
-
end
|
34
|
-
|
35
|
-
it "sends #{level} exceptions" do
|
36
|
-
exc = nil
|
37
|
-
begin
|
38
|
-
Uh oh
|
39
|
-
rescue Exception => e
|
40
|
-
exc = e
|
41
|
-
end
|
42
|
-
|
43
|
-
mock = Mock.new
|
44
|
-
@appender.stub(:service_index, mock) do
|
45
|
-
@appender.send(level, @message, exc)
|
46
|
-
end
|
47
|
-
assert_equal @message, mock.message
|
48
|
-
|
49
|
-
assert exception = mock.event[:event][:exception]
|
50
|
-
assert 'NameError', exception[:name]
|
51
|
-
assert 'undefined local variable or method', exception[:message]
|
52
|
-
assert_equal level, mock.event[:event][:level]
|
53
|
-
assert exception[:stack_trace].first.include?(__FILE__), exception
|
54
|
-
end
|
55
|
-
|
56
|
-
it "sends #{level} custom attributes" do
|
57
|
-
mock = Mock.new
|
58
|
-
@appender.stub(:service_index, mock) do
|
59
|
-
@appender.send(level, @message, key1: 1, key2: 'a')
|
60
|
-
end
|
61
|
-
assert_equal @message, mock.message
|
62
|
-
|
63
|
-
assert event = mock.event[:event], mock.event.ai
|
64
|
-
assert_equal level, event[:level]
|
65
|
-
refute event[:stack_trace]
|
66
|
-
assert payload = event[:payload]
|
67
|
-
assert_equal(1, payload[:key1], payload)
|
68
|
-
assert_equal('a', payload[:key2], payload)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'does not send :trace notifications to Splunk when set to :error' do
|
73
|
-
mock = Mock.new
|
74
|
-
@appender.level = :error
|
75
|
-
@appender.stub(:service_index, mock) do
|
76
|
-
@appender.trace('AppenderSplunkTest trace message')
|
77
|
-
end
|
78
|
-
assert_nil mock.event
|
79
|
-
assert_nil mock.message
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
require 'net/tcp_client'
|
3
|
-
|
4
|
-
# Unit Test for SemanticLogger::Appender::Syslog
|
5
|
-
#
|
6
|
-
module Appender
|
7
|
-
class SyslogTest < Minitest::Test
|
8
|
-
describe SemanticLogger::Appender::Syslog do
|
9
|
-
it 'handle local syslog' do
|
10
|
-
message = nil
|
11
|
-
Syslog.stub(:open, nil) do
|
12
|
-
Syslog.stub(:log, ->(_level, msg) { message = msg }) do
|
13
|
-
syslog_appender = SemanticLogger::Appender::Syslog.new(level: :debug)
|
14
|
-
syslog_appender.debug 'AppenderSyslogTest log message'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
assert_match(/D (.*?) SemanticLogger::Appender::Syslog -- AppenderSyslogTest log message/, message)
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'handle remote syslog over TCP' do
|
21
|
-
message = nil
|
22
|
-
Net::TCPClient.stub_any_instance(:closed?, false) do
|
23
|
-
Net::TCPClient.stub_any_instance(:connect, nil) do
|
24
|
-
syslog_appender = SemanticLogger::Appender::Syslog.new(url: 'tcp://localhost:88888', level: :debug)
|
25
|
-
syslog_appender.remote_syslog.stub(:write, proc { |data| message = data }) do
|
26
|
-
syslog_appender.debug 'AppenderSyslogTest log message'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
assert_match(/<70>(.*?)SemanticLogger::Appender::Syslog -- AppenderSyslogTest log message\r\n/, message)
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'handle remote syslog over UDP' do
|
34
|
-
message = nil
|
35
|
-
syslog_appender = SemanticLogger::Appender::Syslog.new(url: 'udp://localhost:88888', level: :debug)
|
36
|
-
UDPSocket.stub_any_instance(:send, ->(msg, _num, _host, _port) { message = msg }) do
|
37
|
-
syslog_appender.debug 'AppenderSyslogTest log message'
|
38
|
-
end
|
39
|
-
assert_match(/<70>(.*?)SemanticLogger::Appender::Syslog -- AppenderSyslogTest log message/, message)
|
40
|
-
end
|
41
|
-
|
42
|
-
# Should be able to log each level.
|
43
|
-
SemanticLogger::LEVELS.each do |level|
|
44
|
-
it "log #{level} information" do
|
45
|
-
Syslog.stub(:open, nil) do
|
46
|
-
Syslog.stub(:log, nil) do
|
47
|
-
syslog_appender = SemanticLogger::Appender::Syslog.new
|
48
|
-
syslog_appender.send(level, "AppenderSyslogTest #{level} message")
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'allow logging with %' do
|
55
|
-
message = 'AppenderSyslogTest %test'
|
56
|
-
syslog_appender = SemanticLogger::Appender::Syslog.new
|
57
|
-
syslog_appender.debug(message)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
data/test/appender/tcp_test.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
# Unit Test for SemanticLogger::Appender::Tcp
|
4
|
-
module Appender
|
5
|
-
class TcpTest < Minitest::Test
|
6
|
-
describe SemanticLogger::Appender::Tcp do
|
7
|
-
before do
|
8
|
-
Net::TCPClient.stub_any_instance(:connect, true) do
|
9
|
-
@appender = SemanticLogger::Appender::Tcp.new(server: 'localhost:8088')
|
10
|
-
end
|
11
|
-
@appender.tcp_client.instance_eval do
|
12
|
-
def retry_on_connection_failure
|
13
|
-
yield
|
14
|
-
end
|
15
|
-
end
|
16
|
-
@message = 'AppenderTcpTest log message'
|
17
|
-
end
|
18
|
-
|
19
|
-
SemanticLogger::LEVELS.each do |level|
|
20
|
-
it "send #{level}" do
|
21
|
-
data = nil
|
22
|
-
@appender.tcp_client.stub(:write, ->(d) { data = d }) do
|
23
|
-
@appender.send(level, @message)
|
24
|
-
end
|
25
|
-
hash = JSON.parse(data)
|
26
|
-
assert_equal @message, hash['message']
|
27
|
-
assert_equal level.to_s, hash['level']
|
28
|
-
refute hash['stack_trace']
|
29
|
-
end
|
30
|
-
|
31
|
-
it "send #{level} exceptions" do
|
32
|
-
exc = nil
|
33
|
-
begin
|
34
|
-
Uh oh
|
35
|
-
rescue Exception => e
|
36
|
-
exc = e
|
37
|
-
end
|
38
|
-
data = nil
|
39
|
-
@appender.tcp_client.stub(:write, ->(d) { data = d }) do
|
40
|
-
@appender.send(level, 'Reading File', exc)
|
41
|
-
end
|
42
|
-
hash = JSON.parse(data)
|
43
|
-
assert 'Reading File', hash['message']
|
44
|
-
assert 'NameError', hash['exception']['name']
|
45
|
-
assert 'undefined local variable or method', hash['exception']['message']
|
46
|
-
assert_equal level.to_s, hash['level'], 'Should be error level (3)'
|
47
|
-
assert hash['exception']['stack_trace'].first.include?(__FILE__), hash['exception']
|
48
|
-
end
|
49
|
-
|
50
|
-
it "send #{level} custom attributes" do
|
51
|
-
data = nil
|
52
|
-
@appender.tcp_client.stub(:write, ->(d) { data = d }) do
|
53
|
-
@appender.send(level, @message, key1: 1, key2: 'a')
|
54
|
-
end
|
55
|
-
hash = JSON.parse(data)
|
56
|
-
assert_equal @message, hash['message']
|
57
|
-
assert_equal level.to_s, hash['level']
|
58
|
-
refute hash['stack_trace']
|
59
|
-
assert payload = hash['payload'], hash
|
60
|
-
assert_equal 1, payload['key1'], payload
|
61
|
-
assert_equal 'a', payload['key2'], payload
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
data/test/appender/udp_test.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
# Unit Test for SemanticLogger::Appender::Tcp
|
4
|
-
module Appender
|
5
|
-
class UdpTest < Minitest::Test
|
6
|
-
describe SemanticLogger::Appender::Udp do
|
7
|
-
before do
|
8
|
-
@appender = SemanticLogger::Appender::Udp.new(server: 'localhost:8088')
|
9
|
-
@message = 'AppenderUdpTest log message'
|
10
|
-
end
|
11
|
-
|
12
|
-
SemanticLogger::LEVELS.each do |level|
|
13
|
-
it "send #{level}" do
|
14
|
-
data = nil
|
15
|
-
@appender.socket.stub(:send, ->(d, _flags) { data = d }) do
|
16
|
-
@appender.send(level, @message)
|
17
|
-
end
|
18
|
-
hash = JSON.parse(data)
|
19
|
-
assert_equal @message, hash['message']
|
20
|
-
assert_equal level.to_s, hash['level']
|
21
|
-
refute hash['stack_trace']
|
22
|
-
end
|
23
|
-
|
24
|
-
it "send #{level} exceptions" do
|
25
|
-
exc = nil
|
26
|
-
begin
|
27
|
-
Uh oh
|
28
|
-
rescue Exception => e
|
29
|
-
exc = e
|
30
|
-
end
|
31
|
-
data = nil
|
32
|
-
@appender.socket.stub(:send, ->(d, _flags) { data = d }) do
|
33
|
-
@appender.send(level, 'Reading File', exc)
|
34
|
-
end
|
35
|
-
hash = JSON.parse(data)
|
36
|
-
assert 'Reading File', hash['message']
|
37
|
-
assert 'NameError', hash['exception']['name']
|
38
|
-
assert 'undefined local variable or method', hash['exception']['message']
|
39
|
-
assert_equal level.to_s, hash['level'], 'Should be error level (3)'
|
40
|
-
assert hash['exception']['stack_trace'].first.include?(__FILE__), hash['exception']
|
41
|
-
end
|
42
|
-
|
43
|
-
it "send #{level} custom attributes" do
|
44
|
-
data = nil
|
45
|
-
@appender.socket.stub(:send, ->(d, _flags) { data = d }) do
|
46
|
-
@appender.send(level, @message, key1: 1, key2: 'a')
|
47
|
-
end
|
48
|
-
hash = JSON.parse(data)
|
49
|
-
assert_equal @message, hash['message']
|
50
|
-
assert_equal level.to_s, hash['level']
|
51
|
-
refute hash['stack_trace']
|
52
|
-
assert payload = hash['payload'], hash
|
53
|
-
assert_equal 1, payload['key1'], payload
|
54
|
-
assert_equal 'a', payload['key2'], payload
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,95 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
# Unit Test for SemanticLogger::Appender::Wrapper
|
4
|
-
#
|
5
|
-
module Appender
|
6
|
-
class WrapperTest < Minitest::Test
|
7
|
-
# Looks like a standard Ruby Logger or Rails Logger
|
8
|
-
# Except that it stores the last logged entry in the instance variable: message
|
9
|
-
class MockLogger
|
10
|
-
attr_accessor :message
|
11
|
-
|
12
|
-
Logger::Severity.constants.each do |level|
|
13
|
-
class_eval <<-EOT, __FILE__, __LINE__
|
14
|
-
def #{level.downcase}(message = nil, progname = nil)
|
15
|
-
if message
|
16
|
-
self.message = message
|
17
|
-
elsif block_given?
|
18
|
-
self.message = yield
|
19
|
-
else
|
20
|
-
self.message = progname
|
21
|
-
end
|
22
|
-
self.message
|
23
|
-
end
|
24
|
-
|
25
|
-
def #{level}?
|
26
|
-
@true
|
27
|
-
end
|
28
|
-
EOT
|
29
|
-
end
|
30
|
-
|
31
|
-
def flush
|
32
|
-
true
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe SemanticLogger::Appender::Wrapper do
|
37
|
-
before do
|
38
|
-
SemanticLogger.default_level = :trace
|
39
|
-
SemanticLogger.backtrace_level = :trace
|
40
|
-
|
41
|
-
@time = Time.new
|
42
|
-
@mock_logger = MockLogger.new
|
43
|
-
@appender = SemanticLogger::Appender::Wrapper.new(logger: @mock_logger)
|
44
|
-
@hash = {session_id: 'HSSKLEU@JDK767', tracking_number: 12_345}
|
45
|
-
@hash_str = @hash.inspect.sub('{', '\\{').sub('}', '\\}')
|
46
|
-
@thread_name = Thread.current.name
|
47
|
-
@file_name_reg_exp = ' wrapper_test.rb:\d+'
|
48
|
-
end
|
49
|
-
|
50
|
-
describe 'format logs into text form' do
|
51
|
-
it 'logs blank data' do
|
52
|
-
@appender.debug
|
53
|
-
assert_match(/\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:#{@thread_name}#{@file_name_reg_exp}\] SemanticLogger::Appender::Wrapper/, @mock_logger.message)
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'logs message' do
|
57
|
-
@appender.debug('hello world')
|
58
|
-
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)
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'logs message and payload' do
|
62
|
-
@appender.debug('hello world', @hash)
|
63
|
-
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)
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'logs named parameters' do
|
67
|
-
@appender.debug(message: 'hello world', payload: @hash)
|
68
|
-
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)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe 'for each log level' do
|
73
|
-
before do
|
74
|
-
@appender = SemanticLogger.add_appender(logger: @mock_logger)
|
75
|
-
@logger = SemanticLogger[WrapperTest]
|
76
|
-
end
|
77
|
-
|
78
|
-
after do
|
79
|
-
SemanticLogger.remove_appender(@appender)
|
80
|
-
end
|
81
|
-
|
82
|
-
# Ensure that any log level can be logged
|
83
|
-
Logger::Severity.constants.each do |level|
|
84
|
-
it "log #{level.downcase.to_sym}" do
|
85
|
-
level_char = level[0].upcase
|
86
|
-
level_char = 'E' if level_char == 'U'
|
87
|
-
@logger.send(level.downcase.to_sym, 'hello world', @hash)
|
88
|
-
SemanticLogger.flush
|
89
|
-
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)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|