Sha256: 4919c93744363ed870305afd15b94986ef3e0ac50cdc0335d1a46decb481765b

Contents?: true

Size: 940 Bytes

Versions: 22

Compression:

Stored size: 940 Bytes

Contents

module Rollbar
  class LoggerProxy
    attr_reader :object

    def initialize(object)
      @object = object
    end

    def debug(message)
      log('debug', message)
    end

    def info(message)
      log('info', message)
    end

    def warn(message)
      log('warn', message)
    end

    def error(message)
      log('error', message)
    end

    def log(level, message)
      return unless Rollbar.configuration.enabled && acceptable_levels.include?(level.to_sym)

      @object.send(level, message)
    rescue StandardError
      puts "[Rollbar] Error logging #{level}:"
      puts "[Rollbar] #{message}"
    end

    protected

    def acceptable_levels
      @acceptable_levels ||= begin
        levels = [:debug, :info, :warn, :error]
        if Rollbar.configuration.logger_level
          levels[levels.find_index(Rollbar.configuration.logger_level)..-1]
        else
          []
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
rollbar-2.20.1 lib/rollbar/logger_proxy.rb
rollbar-2.20.0 lib/rollbar/logger_proxy.rb