class Exceptions::Backends::LogResult

Public: LogResult is an implementation of the Backend interface the wraps an existing backend and logs the result id and url.

Attributes

backend[R]
logger[R]

Public Class Methods

new(backend, logger = ::Logger.new(STDOUT)) click to toggle source
# File lib/exceptions/backends/log_result.rb, line 10
def initialize(backend, logger = ::Logger.new(STDOUT))
  @backend = backend
  @logger  = logger
end

Public Instance Methods

clear_context(*args) click to toggle source
# File lib/exceptions/backends/log_result.rb, line 25
def clear_context(*args)
  backend.clear_context(*args)
end
context(*args) click to toggle source
# File lib/exceptions/backends/log_result.rb, line 21
def context(*args)
  backend.context(*args)
end
notify(exception, options = {}) click to toggle source
# File lib/exceptions/backends/log_result.rb, line 15
def notify(exception, options = {})
  backend.notify(exception, options).tap do |result|
    log exception, result
  end
end

Private Instance Methods

log(exception, result) click to toggle source
# File lib/exceptions/backends/log_result.rb, line 31
def log(exception, result)
  logger.info "at=exception exception=#{exception.class} message=\"#{exception}\" " + \
    "exception-id=#{result.id} url=#{result.url} source=#{source} count#exception=1" if result.ok?
end
source() click to toggle source
# File lib/exceptions/backends/log_result.rb, line 36
def source
  ''
end