Class: ReeLogger::RollbarAppender
- Includes:
- Ree::LinkDSL
- Defined in:
- lib/ree_lib/packages/ree_logger/package/ree_logger/appenders/rollbar_appender.rb
Instance Attribute Summary
Attributes inherited from Appender
Instance Method Summary collapse
- #append(event, progname = nil) ⇒ Object
-
#initialize(level, access_token:, environment:, **opts) ⇒ RollbarAppender
constructor
A new instance of RollbarAppender.
Constructor Details
#initialize(level, access_token:, environment:, **opts) ⇒ RollbarAppender
Returns a new instance of RollbarAppender.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ree_lib/packages/ree_logger/package/ree_logger/appenders/rollbar_appender.rb', line 22 def initialize(level, access_token:, environment:, **opts) super(level, nil) require 'rollbar' Rollbar.configure do |config| config.enabled = true config.access_token = access_token config.environment = environment config.branch = opts[:branch] if opts[:branch] config.host = opts[:host] if opts[:host] end end |
Instance Method Details
#append(event, progname = nil) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/ree_lib/packages/ree_logger/package/ree_logger/appenders/rollbar_appender.rb', line 37 def append(event, progname = nil) = case event.level when :fatal 'critical' when :unknown 'critical' else event.level.to_s end fingerprint = event..to_s if event.exception fingerprint += event.exception.class.to_s end scope = {} parameters = event.parameters.dup if parameters.key?(:rollbar_scope) && parameters[:rollbar_scope].is_a?(Hash) scope = scope.merge( parameters.delete(:rollbar_scope) ) end if !scope[:fingerprint] fingerprint = event..to_s if event.exception fingerprint += event.exception.class.to_s end scope[:fingerprint] = Digest::MD5.new.update(fingerprint).to_s end Rollbar.scoped(scope) do Rollbar.log(, event., event.exception, parameters) end nil end |