Class: Itamae::Logger::Formatter
- Inherits:
-
Object
- Object
- Itamae::Logger::Formatter
- Defined in:
- lib/itamae/logger.rb
Constant Summary collapse
- INDENT_LENGTH =
3
Instance Attribute Summary collapse
-
#colored ⇒ Object
Returns the value of attribute colored.
-
#depth ⇒ Object
Returns the value of attribute depth.
Instance Method Summary collapse
- #call(severity, datetime, progname, msg) ⇒ Object
- #indent ⇒ Object
-
#initialize(*args) ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
#initialize(*args) ⇒ Formatter
Returns a new instance of Formatter.
13 14 15 16 17 |
# File 'lib/itamae/logger.rb', line 13 def initialize(*args) super @depth = 0 end |
Instance Attribute Details
#colored ⇒ Object
Returns the value of attribute colored.
8 9 10 |
# File 'lib/itamae/logger.rb', line 8 def colored @colored end |
#depth ⇒ Object
Returns the value of attribute depth.
9 10 11 |
# File 'lib/itamae/logger.rb', line 9 def depth @depth end |
Instance Method Details
#call(severity, datetime, progname, msg) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/itamae/logger.rb', line 19 def call(severity, datetime, progname, msg) log = "%s : %s%s\n" % ["%5s" % severity, ' ' * INDENT_LENGTH * depth , msg2str(msg)] if colored color(log, severity) else log end end |
#indent ⇒ Object
28 29 30 31 32 33 |
# File 'lib/itamae/logger.rb', line 28 def indent @depth += 1 yield ensure @depth -= 1 end |