Class: ColorizeLogs::Formatter

Inherits:
ActiveSupport::Logger::SimpleFormatter
  • Object
show all
Includes:
ActiveSupport::TaggedLogging::Formatter
Defined in:
lib/colorize_logs/formatter.rb

Overview

Custom formatter for Rails logger

Instance Method Summary collapse

Constructor Details

#initializeFormatter

Returns a new instance of Formatter.



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

def initialize
  super

  @matchers = {}
end

Instance Method Details

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



22
23
24
25
26
27
28
# File 'lib/colorize_logs/formatter.rb', line 22

def call(severity, time, progname, msg)
  return if msg.blank?

  msg = colorize_message(msg)

  super(severity, time, progname, msg)
end

#configure(&block) ⇒ Object



17
18
19
20
# File 'lib/colorize_logs/formatter.rb', line 17

def configure(&block)
  instance_eval(&block)
  self
end