Class: PsdFormatter

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

Overview

PsdFormatter

Constant Summary collapse

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

Severity label for logging (max 5 chars).

%w[DEBUG INFO WARN ERROR FATAL ANY].each(&:freeze).freeze

Instance Method Summary collapse

Constructor Details

#initialize(deployment_info) ⇒ PsdFormatter

Returns a new instance of PsdFormatter.



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

def initialize(deployment_info)
  # deployment_info is set as DETAILS in deployed_version and called in deployment project
  @app_tag = deployment_info.values.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