Class: PsdFormatter

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

Overview

rubocop:todo Style/Documentation

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
# File 'lib/psd_formatter.rb', line 9

def initialize(deployment_info)
  info = OpenStruct.new(deployment_info) # rubocop:todo Style/OpenStructUse
  @app_tag = [info.name, info.version, info.environment].compact.join(':').freeze
  super()
end

Instance Method Details

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



15
16
17
18
# File 'lib/psd_formatter.rb', line 15

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