Class: Istox::Logging::LogFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/istox/logging/log_formatter.rb

Instance Method Summary collapse

Instance Method Details

#call(severity, time, progname, msg = '') ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/istox/logging/log_formatter.rb', line 5

def call(severity, time, progname, msg='')
  return '' if msg.blank?

  hash = {
    level: severity,
    message: processed_message(msg)
  }

  if progname.present?
    hash[:app] = progname
  end

  return JSON.pretty_generate(hash) + "\n"

  # return "timestamp='#{time}' level=#{severity} progname='#{progname}' #{processed_message(msg)}\n" if progname.present?
  # "timestamp='#{time}' level=#{severity} #{processed_message(msg)}\n"
end