semantic_logger 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,7 +54,6 @@ module SemanticLogger
|
|
54
54
|
|
55
55
|
str = "#{log.time.strftime("%Y-%m-%d %H:%M:%S")}.#{"%03d" % (log.time.usec/1000)} #{log.level.to_s[0..0].upcase} [#{$$}:#{log.thread_name}] #{tags}#{log.name} -- #{message}"
|
56
56
|
str << " (#{'%.1f' % log.duration}ms)" if log.duration
|
57
|
-
str << "\n"
|
58
57
|
str
|
59
58
|
end
|
60
59
|
end
|
@@ -25,7 +25,7 @@ class AppenderLoggerTest < Test::Unit::TestCase
|
|
25
25
|
log.time = Time.now
|
26
26
|
log.level = :debug
|
27
27
|
@appender.log(log)
|
28
|
-
assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:\] --
|
28
|
+
assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:\] -- /, @mock_logger.message
|
29
29
|
end
|
30
30
|
|
31
31
|
should "handle nil message and payload" do
|
@@ -34,7 +34,7 @@ class AppenderLoggerTest < Test::Unit::TestCase
|
|
34
34
|
log.level = :debug
|
35
35
|
log.name = 'class'
|
36
36
|
@appender.log(log)
|
37
|
-
assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:\] class --
|
37
|
+
assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:\] class -- /, @mock_logger.message
|
38
38
|
end
|
39
39
|
|
40
40
|
should "handle nil payload" do
|
@@ -44,7 +44,7 @@ class AppenderLoggerTest < Test::Unit::TestCase
|
|
44
44
|
log.name = 'class'
|
45
45
|
log.message = 'hello world'
|
46
46
|
@appender.log(log)
|
47
|
-
assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:\] class -- hello world
|
47
|
+
assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:\] class -- hello world/, @mock_logger.message
|
48
48
|
end
|
49
49
|
|
50
50
|
should "handle payload" do
|
@@ -55,7 +55,7 @@ class AppenderLoggerTest < Test::Unit::TestCase
|
|
55
55
|
log.message = 'hello world'
|
56
56
|
log.payload = @hash
|
57
57
|
@appender.log(log)
|
58
|
-
assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:\] class -- hello world -- \{:session_id=>\"HSSKLEU@JDK767\", :tracking_number=>12345\}
|
58
|
+
assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ D \[\d+:\] class -- hello world -- \{:session_id=>\"HSSKLEU@JDK767\", :tracking_number=>12345\}/, @mock_logger.message
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -64,7 +64,7 @@ class AppenderLoggerTest < Test::Unit::TestCase
|
|
64
64
|
Logger::Severity.constants.each do |level|
|
65
65
|
should "log #{level.downcase.to_sym} info" do
|
66
66
|
@appender.log SemanticLogger::Logger::Log.new(level.downcase.to_sym, 'thread', 'class', 'hello world -- Calculations', @hash, Time.now)
|
67
|
-
assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:thread\] class -- hello world -- Calculations -- \{:session_id=>\"HSSKLEU@JDK767\", :tracking_number=>12345\}
|
67
|
+
assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:thread\] class -- hello world -- Calculations -- \{:session_id=>\"HSSKLEU@JDK767\", :tracking_number=>12345\}/, @mock_logger.message
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
data/test/logger_test.rb
CHANGED
@@ -34,7 +34,7 @@ class LoggerTest < Test::Unit::TestCase
|
|
34
34
|
should "log #{level} info" do
|
35
35
|
@logger.send(level, 'hello world', @hash) { "Calculations" }
|
36
36
|
@logger.flush
|
37
|
-
assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:.+\] LoggerTest -- hello world -- Calculations -- \{:session_id=>\"HSSKLEU@JDK767\", :tracking_number=>12345\}
|
37
|
+
assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:.+\] LoggerTest -- hello world -- Calculations -- \{:session_id=>\"HSSKLEU@JDK767\", :tracking_number=>12345\}/, @mock_logger.message
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -43,7 +43,7 @@ class LoggerTest < Test::Unit::TestCase
|
|
43
43
|
@logger.with_tags('12345', 'DJHSFK') do
|
44
44
|
@logger.info('Hello world')
|
45
45
|
@logger.flush
|
46
|
-
assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:.+\] \[12345\] \[DJHSFK\] LoggerTest -- Hello world
|
46
|
+
assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:.+\] \[12345\] \[DJHSFK\] LoggerTest -- Hello world/, @mock_logger.message
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -52,7 +52,7 @@ class LoggerTest < Test::Unit::TestCase
|
|
52
52
|
@logger.with_tags('Second Level') do
|
53
53
|
@logger.info('Hello world')
|
54
54
|
@logger.flush
|
55
|
-
assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:.+\] \[First Level\] \[tags\] \[Second Level\] LoggerTest -- Hello world
|
55
|
+
assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:.+\] \[First Level\] \[tags\] \[Second Level\] LoggerTest -- Hello world/, @mock_logger.message
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -62,7 +62,7 @@ class LoggerTest < Test::Unit::TestCase
|
|
62
62
|
@logger.with_payload(:more => 'data', :even => 2) do
|
63
63
|
@logger.info('Hello world')
|
64
64
|
@logger.flush
|
65
|
-
assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:.+\] LoggerTest -- Hello world -- \{:more=>\"data\", :even=>2, :tracking_number=>\"123456\"\}
|
65
|
+
assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:.+\] LoggerTest -- Hello world -- \{:more=>\"data\", :even=>2, :tracking_number=>\"123456\"\}/, @mock_logger.message
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|