Module: Logging
- Defined in:
- lib/canuby/util.rb
Overview
Canuby's Logger
Usage: logger.debug('message') To change log level on runtime: logger.level = Logger::DEBUG
Class Method Summary collapse
Class Method Details
.log(severity, datetime, progname, msg) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/canuby/util.rb', line 60 def self.log(severity, datetime, progname, msg) date_format = "[#{datetime.strftime('%d-%m-%Y %H:%M:%S,%L')}]".magenta # color needs to be set before \n or it will leak into the console case severity when 'DEBUG' puts "#{date_format} #{severity.cyan} (#{progname}): #{msg}" + "\n" when 'INFO' puts "#{date_format} #{severity.yellow} (#{progname}): #{msg.green}" + "\n" when 'WARN' puts "#{date_format} #{severity.red} (#{progname}): #{msg}" + "\n" when 'ERROR' puts "#{date_format} #{severity} (#{progname}): #{msg}".red + "\n" end end |
.logger ⇒ Object
75 76 77 78 79 80 |
# File 'lib/canuby/util.rb', line 75 def self.logger @logger.formatter = proc do |severity, datetime, progname, msg| log(severity, datetime, progname, msg) end @logger end |