Class: Itamae::Logger::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/itamae/logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFormatter

Returns a new instance of Formatter.



74
75
76
# File 'lib/itamae/logger.rb', line 74

def initialize
  @color = nil
end

Instance Attribute Details

#coloredObject

Returns the value of attribute colored.



72
73
74
# File 'lib/itamae/logger.rb', line 72

def colored
  @colored
end

Instance Method Details

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



78
79
80
81
82
# File 'lib/itamae/logger.rb', line 78

def call(severity, datetime, progname, msg)
  log = "%s : %s" % ["%5s" % severity, msg2str(msg)]

  (colored ? colorize(log, severity) : log) + "\n"
end

#color(code) ⇒ Object



84
85
86
87
88
89
90
# File 'lib/itamae/logger.rb', line 84

def color(code)
  prev_color = @color
  @color = code
  yield
ensure
  @color = prev_color
end