Class: Cogger::Formatters::Crash

Inherits:
Abstract
  • Object
show all
Defined in:
lib/cogger/formatters/crash.rb

Overview

Formats fatal crashes.

Constant Summary collapse

TEMPLATE =
<<~CONTENT
  <dynamic>[%<id>s] [%<level>s] [%<at>s] Crash!
    %<message>s
    %<error_message>s (%<error_class>s)
  %<backtrace>s</dynamic>
CONTENT

Constants inherited from Abstract

Abstract::NEW_LINE, Abstract::SANITIZERS

Instance Method Summary collapse

Constructor Details

#initialize(template = TEMPLATE, parser: Parsers::Combined.new) ⇒ Crash

Returns a new instance of Crash.



14
15
16
17
18
# File 'lib/cogger/formatters/crash.rb', line 14

def initialize template = TEMPLATE, parser: Parsers::Combined.new
  super()
  @template = template
  @parser = parser
end

Instance Method Details

#call(*input) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/cogger/formatters/crash.rb', line 20

def call(*input)
  *, entry = input
  attributes = sanitize entry, :tagged
  attributes[:backtrace] = %(  #{attributes[:backtrace].join "\n  "})

  format(parse(attributes[:level]), attributes) << NEW_LINE
end