Class: Bitlogger::PrettyFormatter
- Inherits:
-
Object
- Object
- Bitlogger::PrettyFormatter
- Defined in:
- lib/bitlogger/pretty_formatter.rb
Instance Method Summary collapse
- #format_hash(hash) ⇒ String
-
#initialize ⇒ PrettyFormatter
constructor
A new instance of PrettyFormatter.
Constructor Details
#initialize ⇒ PrettyFormatter
Returns a new instance of PrettyFormatter.
4 5 6 |
# File 'lib/bitlogger/pretty_formatter.rb', line 4 def initialize @offset = DateTime.now.offset end |
Instance Method Details
#format_hash(hash) ⇒ String
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/bitlogger/pretty_formatter.rb', line 10 def format_hash(hash) str = "" hash.each do |k, v| str += "[#{k}: #{v}] " unless k == :level or k == :timestamp end dt = DateTime.strptime(hash[:timestamp].to_s, '%s') dt = dt.new_offset(@offset) "[#{dt}] [#{hash[:level]}] #{str}" end |