lib/semantic_logger/log.rb in semantic_logger-3.2.1 vs lib/semantic_logger/log.rb in semantic_logger-3.3.0
- old
+ new
@@ -161,34 +161,36 @@
end
if defined? JRuby
# Return the Time as a formatted string
# JRuby only supports time in ms
+ # DEPRECATED
def formatted_time
"#{time.strftime('%Y-%m-%d %H:%M:%S')}.#{'%03d' % (time.usec/1000)}"
end
else
# Return the Time as a formatted string
# Ruby MRI supports micro seconds
+ # DEPRECATED
def formatted_time
"#{time.strftime('%Y-%m-%d %H:%M:%S')}.#{'%06d' % (time.usec)}"
end
end
# Returns [Hash] representation of this log entry
- def to_h
+ def to_h(host = SemanticLogger.host, application = SemanticLogger.application)
# Header
- h = {
- host: SemanticLogger.host,
- application: SemanticLogger.application,
+ h = {
name: name,
pid: $$,
thread: thread_name,
time: time,
level: level,
level_index: level_index,
}
- file, line = file_name_and_line
+ h[:host] = host if host
+ h[:application] = application if application
+ file, line = file_name_and_line
if file
h[:file] = file
h[:line] = line.to_i
end