Module: RollbarHelper
- Defined in:
- lib/rollbar_helper.rb,
lib/rollbar_helper/version.rb
Constant Summary collapse
- LEVELS =
[ :critical, :debug, :error, :info, :warning, ]
- VERSION =
'1.0.0'
Class Method Summary collapse
- .critical(obj, fingerprint: nil, **data) ⇒ Object
- .debug(obj, fingerprint: nil, **data) ⇒ Object
- .error(obj, fingerprint: nil, **data) ⇒ Object
- .info(obj, fingerprint: nil, **data) ⇒ Object
- .log(level, obj, callee: caller, fingerprint: nil, **data) ⇒ Object
- .warn(obj, fingerprint: nil, **data) ⇒ Object
- .warning(obj, fingerprint: nil, **data) ⇒ Object
Class Method Details
.critical(obj, fingerprint: nil, **data) ⇒ Object
14 15 16 |
# File 'lib/rollbar_helper.rb', line 14 def critical(obj, fingerprint: nil, **data) log(:critical, obj, :callee => caller, fingerprint: fingerprint, **data) end |
.debug(obj, fingerprint: nil, **data) ⇒ Object
18 19 20 |
# File 'lib/rollbar_helper.rb', line 18 def debug(obj, fingerprint: nil, **data) log(:debug, obj, :callee => caller, fingerprint: fingerprint, **data) end |
.error(obj, fingerprint: nil, **data) ⇒ Object
22 23 24 |
# File 'lib/rollbar_helper.rb', line 22 def error(obj, fingerprint: nil, **data) log(:error, obj, :callee => caller, fingerprint: fingerprint, **data) end |
.info(obj, fingerprint: nil, **data) ⇒ Object
26 27 28 |
# File 'lib/rollbar_helper.rb', line 26 def info(obj, fingerprint: nil, **data) log(:info, obj, :callee => caller, fingerprint: fingerprint, **data) end |
.log(level, obj, callee: caller, fingerprint: nil, **data) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rollbar_helper.rb', line 38 def log(level, obj, callee: caller, fingerprint: nil, **data) level = level.to_sym raise ArgumentError, 'Log level is not supported' unless LEVELS.include?(level) e = nil if obj.is_a?(Exception) e = obj else e = StandardError.new(obj.to_s) e.set_backtrace(callee) end unless fingerprint.nil? ::Rollbar.scope(:fingerprint => fingerprint).send(level, e, data) else ::Rollbar.send(level, e, data) end end |
.warn(obj, fingerprint: nil, **data) ⇒ Object
30 31 32 |
# File 'lib/rollbar_helper.rb', line 30 def warn(obj, fingerprint: nil, **data) log(:warning, obj, :callee => caller, fingerprint: fingerprint, **data) end |
.warning(obj, fingerprint: nil, **data) ⇒ Object
34 35 36 |
# File 'lib/rollbar_helper.rb', line 34 def warning(obj, fingerprint: nil, **data) log(:warning, obj, :callee => caller, fingerprint: fingerprint, **data) end |