Class: Dphil::LogFormatter
- Inherits:
-
Logger::Formatter
- Object
- Logger::Formatter
- Dphil::LogFormatter
- Defined in:
- lib/dphil/log_formatter.rb
Instance Method Summary collapse
Instance Method Details
#call(severity, timestamp, progname, msg) ⇒ Object
14 15 16 17 18 |
# File 'lib/dphil/log_formatter.rb', line 14 def call(severity, , progname, msg) out = colorize(severity, "[#{timestamp.strftime('%Y-%m-%d %H:%M:%S %Z')}][v#{VERSION}] [#{severity}] ") out << colorize("PROGNAME", "[#{progname}]") unless progname.nil? "#{out}\n#{(msg.respond_to?(:to_str) ? msg : msg.ai(indent: -2))}\n" end |
#colorize(severity, string) ⇒ Object
9 10 11 12 |
# File 'lib/dphil/log_formatter.rb', line 9 def colorize(severity, string) color = SEVERITY_MAP[severity] || :none String.new("#{COLOR_MAP[color]}#{string}#{COLOR_MAP[:none]}") end |