Class: BackgroundQueue::Worker::LogFormatter

Inherits:
Logger::Formatter
  • Object
show all
Defined in:
lib/background_queue/worker/logger.rb

Overview

custom log formatter

Constant Summary collapse

Format =
"%s %5s [%s] %s\n"

Instance Method Summary collapse

Constructor Details

#initialize(task_key) ⇒ LogFormatter

Returns a new instance of LogFormatter.



80
81
82
83
# File 'lib/background_queue/worker/logger.rb', line 80

def initialize(task_key)
  @datetime_format = "%Y-%m-%d %H:%M:%S"
  @task_key = task_key
end

Instance Method Details

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



85
86
87
# File 'lib/background_queue/worker/logger.rb', line 85

def call(severity, time, progname, msg)
  Format % [@task_key, severity, format_datetime(time), msg2str(msg)]
end