Class: PsdFormatter

Inherits:
Syslog::Logger::Formatter
  • Object
show all
Defined in:
lib/psd_formatter.rb

Constant Summary collapse

LINE_FORMAT =
"(thread-%s) [%s] %5s -- : %s\n"

Instance Method Summary collapse

Constructor Details

#initialize(deployment_info) ⇒ PsdFormatter

Returns a new instance of PsdFormatter.



9
10
11
12
13
14
15
# File 'lib/psd_formatter.rb', line 9

def initialize(deployment_info)
  # below line is included because it was unknown whether
  # deployment_info is a Hash, an OpenStruct or a Struct - this makes them all a hash
  info = deployment_info.to_h
  @app_tag = [info[:name], info[:version], info[:environment]].compact.join(':').freeze
  super()
end

Instance Method Details

#call(severity, _timestamp, _progname, msg) ⇒ Object



17
18
19
20
# File 'lib/psd_formatter.rb', line 17

def call(severity, _timestamp, _progname, msg)
  thread_id = Thread.current.object_id
  format(LINE_FORMAT, thread_id, @app_tag, format_severity(severity), msg)
end