Class: Cauchy::PrettyLogger

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/cauchy/logging.rb

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ PrettyLogger

Returns a new instance of PrettyLogger.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/cauchy/logging.rb', line 12

def initialize logger
  super

  old_formatter = logger.formatter

  logger.formatter =  proc do |level, time, prog, msg|
    unless msg.start_with?("\e")
      color = case level
              when 'FATAL' then :red
              when 'WARN'  then :yellow
              when 'INFO'  then :blue
              when 'DEBUG' then '333333'
              else              :default
              end
      msg = msg.color(color)
    end

    old_formatter.call level, time, prog, msg
  end
end

Instance Method Details

#inspect(object) ⇒ Object



39
40
41
# File 'lib/cauchy/logging.rb', line 39

def inspect object
  info object.to_yaml[4..-1].strip.indent
end