Class: RequestIdLogging::Formatter
- Inherits:
-
Logger::Formatter
- Object
- Logger::Formatter
- RequestIdLogging::Formatter
- Defined in:
- lib/request_id_logging/formatter.rb
Overview
A logger formatter which prepends request_id to message.
Constant Summary collapse
- DEFAULT_REQ_ID_PROC =
->(id) { id }
Instance Method Summary collapse
- #call(severity, time, progname, msg) ⇒ Object
-
#initialize(formatter: nil, request_id_proc: DEFAULT_REQ_ID_PROC) ⇒ Formatter
constructor
Initialize RequestIdLogging::Formatter.
Constructor Details
#initialize(formatter: nil, request_id_proc: DEFAULT_REQ_ID_PROC) ⇒ Formatter
Initialize RequestIdLogging::Formatter
18 19 20 21 22 |
# File 'lib/request_id_logging/formatter.rb', line 18 def initialize(formatter: nil, request_id_proc: DEFAULT_REQ_ID_PROC) super() @original_formatter = formatter @req_id_proc = request_id_proc || DEFAULT_PROC end |
Instance Method Details
#call(severity, time, progname, msg) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/request_id_logging/formatter.rb', line 24 def call(severity, time, progname, msg) if @original_formatter @original_formatter.call(severity, time, progname, new_msg(msg)) else super(severity, time, progname, new_msg(msg)) end end |