semantic_logger 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/semantic_logger/logger.rb +3 -2
- data/lib/semantic_logger/version.rb +1 -1
- data/test/logger_test.rb +1 -1
- metadata +2 -2
@@ -134,15 +134,16 @@ module SemanticLogger
|
|
134
134
|
start = Time.now
|
135
135
|
begin
|
136
136
|
result = yield
|
137
|
+
end_time = Time.now
|
137
138
|
# Add scoped payload
|
138
139
|
if self.payload
|
139
140
|
payload = payload.nil? ? self.payload : self.payload.merge(payload)
|
140
141
|
end
|
141
|
-
self.class.queue << Log.new(:#{level}, self.class.thread_name, name, message, payload,
|
142
|
+
self.class.queue << Log.new(:#{level}, self.class.thread_name, name, message, payload, end_time, 1000.0 * (end_time - start), tags)
|
142
143
|
result
|
143
144
|
rescue Exception => exc
|
144
145
|
# TODO Need to be able to have both an exception and a Payload
|
145
|
-
self.class.queue << Log.new(:#{level}, self.class.thread_name, name, message, exc,
|
146
|
+
self.class.queue << Log.new(:#{level}, self.class.thread_name, name, message, exc, Time.now, 1000.0 * (Time.now - start), tags)
|
146
147
|
raise exc
|
147
148
|
end
|
148
149
|
else
|
data/test/logger_test.rb
CHANGED
@@ -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
|
SemanticLogger::Logger.flush
|
65
|
-
assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:.+\] LoggerTest -- Hello world -- \{:more=>\"data\", :
|
65
|
+
assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:.+\] LoggerTest -- Hello world -- \{:even=>2, :more=>\"data\", :tracking_number=>\"123456\"\}/, @mock_logger.message
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|