Class: Niboshi::JsonFormatter

Inherits:
Logger::Formatter
  • Object
show all
Defined in:
lib/niboshi/json_formatter.rb,
lib/niboshi_json_formatter.rb

Constant Summary collapse

Version =
VERSION = "0.1.0"

Instance Method Summary collapse

Instance Method Details

#call(severity, time, program_name, message) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/niboshi/json_formatter.rb', line 16

def call(severity, time, program_name, message)
  {
    time: time.to_f,
    formatted_time: time,
    hostname: hostname,
    pid: $$,
    tid: tid,
    level: severity,
    program_name: program_name,
    message: message
  }.to_json + "\n"
end

#hostnameObject



8
9
10
# File 'lib/niboshi/json_formatter.rb', line 8

def hostname
  @hostname ||= Socket.gethostname
end

#tidObject



12
13
14
# File 'lib/niboshi/json_formatter.rb', line 12

def tid
  Thread.current.object_id
end