Class: Phrender::Logger
- Inherits:
-
Object
- Object
- Phrender::Logger
- Defined in:
- lib/phrender/logger.rb
Constant Summary collapse
- MESSAGE_FORMAT =
"%s: %s"
Class Method Summary collapse
- .console(message) ⇒ Object
- .critical(message) ⇒ Object
- .error(message) ⇒ Object
- .info(message) ⇒ Object
- .log(msg, color = nil) ⇒ Object
- .log_json(json) ⇒ Object
- .trace(message) ⇒ Object
Class Method Details
.console(message) ⇒ Object
17 18 19 |
# File 'lib/phrender/logger.rb', line 17 def console() log MESSAGE_FORMAT % [ apply_color("CONSOLE", :magenta), ] end |
.critical(message) ⇒ Object
33 34 35 |
# File 'lib/phrender/logger.rb', line 33 def critical() log MESSAGE_FORMAT % [ apply_color("CRITICAL", :on_red), ] end |
.error(message) ⇒ Object
25 26 27 |
# File 'lib/phrender/logger.rb', line 25 def error() log MESSAGE_FORMAT % [ apply_color("ERROR", :red), ] end |
.info(message) ⇒ Object
21 22 23 |
# File 'lib/phrender/logger.rb', line 21 def info() log MESSAGE_FORMAT % [ apply_color("INFO"), ] end |
.log(msg, color = nil) ⇒ Object
37 38 39 40 41 |
# File 'lib/phrender/logger.rb', line 37 def log(msg, color = nil) = "[%s] - %s" % [Time.now, msg] $stdout.puts $stdout.flush end |
.log_json(json) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/phrender/logger.rb', line 9 def log_json(json) %w(console info error trace critical).each do |type| if json.has_key? type send type.to_sym, json[type] end end end |
.trace(message) ⇒ Object
29 30 31 |
# File 'lib/phrender/logger.rb', line 29 def trace() log MESSAGE_FORMAT % [ apply_color("TRACE", :cyan), ] end |