Class: TTY::Logger::Handlers::Raven
- Inherits:
-
Object
- Object
- TTY::Logger::Handlers::Raven
- Includes:
- Base
- Defined in:
- lib/tty/logger/handlers/raven.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
Instance Method Summary collapse
- #call(event) ⇒ Object
-
#initialize(output: $stderr, formatter: nil, config: nil, level: nil, styles: {}) ⇒ Raven
constructor
A new instance of Raven.
Constructor Details
#initialize(output: $stderr, formatter: nil, config: nil, level: nil, styles: {}) ⇒ Raven
Returns a new instance of Raven.
13 14 15 16 17 18 19 |
# File 'lib/tty/logger/handlers/raven.rb', line 13 def initialize( output: $stderr, formatter: nil, config: nil, level: nil, styles: {} ) @config = config @level = level || @config.level @mutex = Mutex.new end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
11 12 13 |
# File 'lib/tty/logger/handlers/raven.rb', line 11 def config @config end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
11 12 13 |
# File 'lib/tty/logger/handlers/raven.rb', line 11 def level @level end |
Instance Method Details
#call(event) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/tty/logger/handlers/raven.rb', line 22 def call(event) @mutex.lock data = {} event..each do || case when :file data[:path] = format_filepath(event) end end unless event.backtrace.empty? data[:type] = event..first&.class&.name data[:value] = event..first&. end data.merge!(event.fields) unless event.fields.empty? ::Raven..record do |crumb| crumb.level = event.[:level].to_s crumb.category = 'logger' crumb. = event..join(' ') crumb. = event.[:time].to_i crumb.type = event.backtrace.empty? ? 'default' : 'error' crumb.data = data end ensure @mutex.unlock end |