Class: Betterlog::Log::EventFormatter
- Inherits:
-
Object
- Object
- Betterlog::Log::EventFormatter
- Includes:
- ComplexConfig::Provider::Shortcuts, Term::ANSIColor
- Defined in:
- lib/betterlog/log/event_formatter.rb
Instance Method Summary collapse
- #format(pretty: false, color: false, format: :default) ⇒ Object
-
#initialize(event) ⇒ EventFormatter
constructor
A new instance of EventFormatter.
Constructor Details
#initialize(event) ⇒ EventFormatter
Returns a new instance of EventFormatter.
10 11 12 |
# File 'lib/betterlog/log/event_formatter.rb', line 10 def initialize(event) @event = event end |
Instance Method Details
#format(pretty: false, color: false, format: :default) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/betterlog/log/event_formatter.rb', line 14 def format(pretty: false, color: false, format: :default) old_coloring, Term::ANSIColor.coloring = Term::ANSIColor.coloring?, color f = cc.log.formats[format] and format = f case pretty when :format format_pattern(format: format) else JSON.generate(@event) end ensure Term::ANSIColor.coloring = old_coloring end |