Class: AppLogger::Formatter::Json

Inherits:
Object
  • Object
show all
Defined in:
lib/app_logger/formatter/json.rb

Direct Known Subclasses

Aws

Constant Summary collapse

FORMAT =
"%s\n"

Instance Method Summary collapse

Constructor Details

#initialize(hostname = `hostname`.chomp) ⇒ Json

Returns a new instance of Json.



8
9
10
# File 'lib/app_logger/formatter/json.rb', line 8

def initialize(hostname=`hostname`.chomp)
  @hostname = hostname
end

Instance Method Details

#call(severity, datetime, progname, message) ⇒ Object



12
13
14
15
# File 'lib/app_logger/formatter/json.rb', line 12

def call(severity, datetime, progname, message)
  msg = msg2hash(message)
  FORMAT % common_msg(severity, datetime, progname).merge(msg).to_json
end