Class: Betterlog::Log::EventFormatter
- Inherits:
-
Object
- Object
- Betterlog::Log::EventFormatter
- Includes:
- 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.
6 7 8 |
# File 'lib/betterlog/log/event_formatter.rb', line 6 def initialize(event) @event = event end |
Instance Method Details
#format(pretty: false, color: false, format: :default) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/betterlog/log/event_formatter.rb', line 10 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 @event.to_json end ensure Term::ANSIColor.coloring = old_coloring end |