Class: MailRoom::Logger::Structured

Inherits:
Logger
  • Object
show all
Defined in:
lib/mail_room/logger/structured.rb

Instance Method Summary collapse

Instance Method Details

#format_message(severity, timestamp, progname, message) ⇒ Object

Raises:

  • (ArgumentError)

9
10
11
12
13
14
15
16
17
18
19
# File 'lib/mail_room/logger/structured.rb', line 9

def format_message(severity, timestamp, progname, message)
  raise ArgumentError.new("Message must be a Hash") unless message.is_a? Hash

  data = {}
  data[:severity] = severity
  data[:time] = format_timestamp(timestamp || Time.now)
  # only accept a Hash
  data.merge!(message)

  data.to_json + "\n"
end