Class: Itamae::Logger::Formatter
- Inherits:
-
Object
- Object
- Itamae::Logger::Formatter
- Defined in:
- lib/itamae/logger.rb
Instance Attribute Summary collapse
-
#colored ⇒ Object
Returns the value of attribute colored.
Instance Method Summary collapse
- #call(severity, datetime, progname, msg) ⇒ Object
- #color(code) ⇒ Object
-
#initialize ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
#initialize ⇒ Formatter
Returns a new instance of Formatter.
74 75 76 |
# File 'lib/itamae/logger.rb', line 74 def initialize @color = nil end |
Instance Attribute Details
#colored ⇒ Object
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 |