class Logist::Formatter::Json
Attributes
flat_json[RW]
Public Instance Methods
call(severity, timestamp, progname, raw_msg)
click to toggle source
# File lib/logist/formatter/json.rb, line 10 def call(severity, timestamp, progname, raw_msg) msg = normalize_message(raw_msg) payload = { level: severity, timestamp: format_datetime(timestamp), environment: ::Rails.env } if flat_json && msg.is_a?(Hash) payload.merge!(msg) else payload.merge!(message: msg) end payload.to_json << "\n" end
Private Instance Methods
normalize_message(raw_msg)
click to toggle source
# File lib/logist/formatter/json.rb, line 25 def normalize_message(raw_msg) return raw_msg unless raw_msg.is_a?(String) JSON.parse(raw_msg) rescue JSON::ParserError raw_msg end