class Tablexi::Logger

Constants

NewRelic
Rollbar
VERSION

Attributes

handlers[R]
option_filters[R]

Public Class Methods

new() click to toggle source
# File lib/tablexi/logger.rb, line 49
def initialize
  @option_filters = []
  @handlers = Hash.new { |h, k| h[k] = [] }
end

Public Instance Methods

handle(severities, &block) click to toggle source
# File lib/tablexi/logger.rb, line 54
def handle(severities, &block)
  raise ArgumentError, "Missing block argument" unless block_given?

  Array(severities).each { |severity| handlers[severity] << block }
end

Private Instance Methods

log(severity, exception_or_message, options) click to toggle source
# File lib/tablexi/logger.rb, line 68
def log(severity, exception_or_message, options)
  process_option_filters(options)
  handlers[severity].each do |handler|
    handler.call(exception_or_message, options)
  end
  nil
rescue StandardError => e
  if options.key? :tablexi_logger_error
    raise # recursion prevention
  else
    error(e, tablexi_logger_error: true)
  end
end
process_option_filters(options) click to toggle source
# File lib/tablexi/logger.rb, line 82
def process_option_filters(options)
  option_filters.each_with_object(options) { |filter, opts| filter.call(opts) }
end