Class: PrettyLogs::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/pretty_logs/formatter.rb

Constant Summary collapse

LEVEL_COLORS =
{
  debug: :cyan,
  info: :green,
  warn: :yellow,
  error: :red,
  fatal: :magenta,
  warning: :yellow,
  unknown: :white
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(structured: true) ⇒ Formatter

Returns a new instance of Formatter.



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

def initialize(structured: true)
  @structured = structured
end

Instance Method Details

#format(log_entry) ⇒ Object



21
22
23
24
25
# File 'lib/pretty_logs/formatter.rb', line 21

def format(log_entry)
  return format_structured(log_entry) if @structured

  format_simple(log_entry)
end