Sha256: 59aecb8ac181629c436769c800efa84c5fbaf8c3a5f924571441b29fbc2b76e5

Contents?: true

Size: 840 Bytes

Versions: 6

Compression:

Stored size: 840 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
      puts "[Rollbar] Error logging #{level}:"
      puts "[Rollbar] #{message}"
    end

    protected

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rollbar-2.19.2 lib/rollbar/logger_proxy.rb
rollbar-2.19.1 lib/rollbar/logger_proxy.rb
rollbar-2.19.0 lib/rollbar/logger_proxy.rb
rollbar-2.18.2 lib/rollbar/logger_proxy.rb
rollbar-2.18.0 lib/rollbar/logger_proxy.rb
rollbar-2.17.0 lib/rollbar/logger_proxy.rb