Class: WCC::LogFormatter
- Inherits:
-
Object
- Object
- WCC::LogFormatter
- Defined in:
- lib/wcc.rb
Instance Method Summary collapse
- #black ⇒ Object
- #blue ⇒ Object
- #call(lvl, time, progname, msg) ⇒ Object
- #cyan ⇒ Object
- #green ⇒ Object
-
#initialize(use_color = true) ⇒ LogFormatter
constructor
A new instance of LogFormatter.
- #magenta ⇒ Object
- #red ⇒ Object
- #rst ⇒ Object
- #white ⇒ Object
- #yellow ⇒ Object
Constructor Details
#initialize(use_color = true) ⇒ LogFormatter
Returns a new instance of LogFormatter.
312 313 314 |
# File 'lib/wcc.rb', line 312 def initialize(use_color = true) @color = use_color end |
Instance Method Details
#black ⇒ Object
323 |
# File 'lib/wcc.rb', line 323 def black; "\e[1;30m" end |
#blue ⇒ Object
319 |
# File 'lib/wcc.rb', line 319 def blue; "\e[1;34m" end |
#call(lvl, time, progname, msg) ⇒ Object
326 327 328 329 330 331 332 333 334 |
# File 'lib/wcc.rb', line 326 def call(lvl, time, progname, msg) text = "%s: %s" % [lvl, msg.to_s] if @color return [magenta, text, rst, "\n"].join if lvl == "FATAL" return [red, text, rst, "\n"].join if lvl == "ERROR" return [yellow, text, rst, "\n"].join if lvl == "WARN" end [text, "\n"].join end |
#cyan ⇒ Object
317 |
# File 'lib/wcc.rb', line 317 def cyan; "\e[1;36m" end |
#green ⇒ Object
321 |
# File 'lib/wcc.rb', line 321 def green; "\e[1;32m" end |
#magenta ⇒ Object
318 |
# File 'lib/wcc.rb', line 318 def magenta;"\e[1;35m" end |
#red ⇒ Object
322 |
# File 'lib/wcc.rb', line 322 def red; "\e[1;31m" end |
#rst ⇒ Object
324 |
# File 'lib/wcc.rb', line 324 def rst; "\e[0m" end |
#white ⇒ Object
316 |
# File 'lib/wcc.rb', line 316 def white; "\e[1;37m" end |
#yellow ⇒ Object
320 |
# File 'lib/wcc.rb', line 320 def yellow; "\e[1;33m" end |