Class: LtsvLogFormatter
- Inherits:
-
Object
- Object
- LtsvLogFormatter
- Defined in:
- lib/ltsv_log_formatter.rb
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
for tests.
Instance Method Summary collapse
- #call(severity, time, progname, msg) ⇒ Object
-
#initialize(opts = {}) ⇒ LtsvLogFormatter
constructor
A new instance of LtsvLogFormatter.
Constructor Details
#initialize(opts = {}) ⇒ LtsvLogFormatter
Returns a new instance of LtsvLogFormatter.
11 12 13 14 15 16 |
# File 'lib/ltsv_log_formatter.rb', line 11 def initialize(opts={}) @opts = opts.map {|k, v| [k.to_sym, v] }.to_h # symbolize_keys @opts[:time_key] = :time unless @opts.has_key?(:time_key) @opts[:level_key] = :level unless @opts.has_key?(:level_key) @opts[:message_key] ||= :message end |
Instance Attribute Details
#opts ⇒ Object (readonly)
for tests
5 6 7 |
# File 'lib/ltsv_log_formatter.rb', line 5 def opts @opts end |
Instance Method Details
#call(severity, time, progname, msg) ⇒ Object
18 19 20 |
# File 'lib/ltsv_log_formatter.rb', line 18 def call(severity, time, progname, msg) "#{format_time(time)}#{format_severity(severity)}#{(msg)}\n" end |