lib/semantic_logger/appender/graylog.rb in semantic_logger-4.1.1 vs lib/semantic_logger/appender/graylog.rb in semantic_logger-4.2.0
- old
+ new
@@ -108,25 +108,26 @@
@notifier.collect_file_and_line = false
end
# Returns [Hash] of parameters to send
def call(log, logger)
- h = SemanticLogger::Formatters::Raw.new.call(log, logger)
- h.delete(:time)
+ h = default_formatter.call(log, logger)
h[:short_message] = h.delete(:message) || log.exception.message
- h[:timestamp] = log.time.utc.to_f
h[:level] = logger.level_map[log.level]
h[:level_str] = log.level.to_s
h[:duration_str] = h.delete(:duration)
h
end
# Forward log messages
def log(log)
- return false unless should_log?(log)
-
notifier.notify!(formatter.call(log, self))
true
end
+ private
+
+ def default_formatter
+ SemanticLogger::Formatters::Raw.new(time_format: :seconds, time_key: :timestamp)
+ end
end