Class: Rundock::Logger::Formatter
Instance Attribute Summary collapse
-
#color(code) ⇒ Object
Returns the value of attribute color.
-
#colored ⇒ Object
Returns the value of attribute colored.
-
#indent_depth ⇒ Object
Returns the value of attribute indent_depth.
-
#show_header ⇒ Object
Returns the value of attribute show_header.
Instance Method Summary collapse
- #add_indent ⇒ Object
- #call(severity, datetime, progname, msg) ⇒ Object
- #indent ⇒ Object
-
#initialize(*args) ⇒ Formatter
constructor
A new instance of Formatter.
- #reduce_indent ⇒ Object
Constructor Details
#initialize(*args) ⇒ Formatter
Returns a new instance of Formatter.
13 14 15 16 |
# File 'lib/rundock/logger.rb', line 13 def initialize(*args) super @indent_depth = 0 end |
Instance Attribute Details
#color(code) ⇒ Object
Returns the value of attribute color.
10 11 12 |
# File 'lib/rundock/logger.rb', line 10 def color @color end |
#colored ⇒ Object
Returns the value of attribute colored.
8 9 10 |
# File 'lib/rundock/logger.rb', line 8 def colored @colored end |
#indent_depth ⇒ Object
Returns the value of attribute indent_depth.
9 10 11 |
# File 'lib/rundock/logger.rb', line 9 def indent_depth @indent_depth end |
#show_header ⇒ Object
Returns the value of attribute show_header.
11 12 13 |
# File 'lib/rundock/logger.rb', line 11 def show_header @show_header end |
Instance Method Details
#add_indent ⇒ Object
39 40 41 |
# File 'lib/rundock/logger.rb', line 39 def add_indent @indent_depth += 1 end |
#call(severity, datetime, progname, msg) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rundock/logger.rb', line 18 def call(severity, datetime, progname, msg) if @show_header out = "[\%5s:] %s%s\n" % [severity, ' ' * 2 * indent_depth, msg2str(msg)] else out = "%s\n" % [msg2str(msg)] end if colored colorize(out, severity) else out end end |
#indent ⇒ Object
32 33 34 35 36 37 |
# File 'lib/rundock/logger.rb', line 32 def indent add_indent yield ensure reduce_indent end |
#reduce_indent ⇒ Object
43 44 45 |
# File 'lib/rundock/logger.rb', line 43 def reduce_indent @indent_depth -= 1 if @indent_depth > 0 end |