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.
296 297 298 |
# File 'lib/wcc.rb', line 296 def initialize(use_color = true) @color = use_color end |
Instance Method Details
#black ⇒ Object
307 |
# File 'lib/wcc.rb', line 307 def black; "\e[1;30m" end |
#blue ⇒ Object
303 |
# File 'lib/wcc.rb', line 303 def blue; "\e[1;34m" end |
#call(lvl, time, progname, msg) ⇒ Object
310 311 312 313 314 315 316 317 318 |
# File 'lib/wcc.rb', line 310 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
301 |
# File 'lib/wcc.rb', line 301 def cyan; "\e[1;36m" end |
#green ⇒ Object
305 |
# File 'lib/wcc.rb', line 305 def green; "\e[1;32m" end |
#magenta ⇒ Object
302 |
# File 'lib/wcc.rb', line 302 def magenta;"\e[1;35m" end |
#red ⇒ Object
306 |
# File 'lib/wcc.rb', line 306 def red; "\e[1;31m" end |
#rst ⇒ Object
308 |
# File 'lib/wcc.rb', line 308 def rst; "\e[0m" end |
#white ⇒ Object
300 |
# File 'lib/wcc.rb', line 300 def white; "\e[1;37m" end |
#yellow ⇒ Object
304 |
# File 'lib/wcc.rb', line 304 def yellow; "\e[1;33m" end |