Class: Utopia::Logger::CompactFormatter
- Inherits:
-
Object
- Object
- Utopia::Logger::CompactFormatter
- Defined in:
- lib/utopia/logger/compact_formatter.rb
Overview
Provides a concise log output format.
Instance Method Summary collapse
-
#call(severity, datetime, progname, message) ⇒ Object
-
#initialize ⇒ CompactFormatter
constructor
A new instance of CompactFormatter.
-
#time_offset_string ⇒ Object
Constructor Details
#initialize ⇒ CompactFormatter
Returns a new instance of CompactFormatter
28 29 30 |
# File 'lib/utopia/logger/compact_formatter.rb', line 28 def initialize @start = Time.now end |
Instance Method Details
#call(severity, datetime, progname, message) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/utopia/logger/compact_formatter.rb', line 38 def call(severity, datetime, progname, ) if progname "#{Rainbow(time_offset_string).bright.blue} #{Rainbow(progname).bright}: #{}\n" else "#{Rainbow(time_offset_string).bright.blue} #{}\n" end end |
#time_offset_string ⇒ Object
32 33 34 35 36 |
# File 'lib/utopia/logger/compact_formatter.rb', line 32 def time_offset_string offset = Time.now - @start "T+#{offset.round(1).to_s.ljust(5)}" end |