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-3.2.0 lib/rollbar/logger_proxy.rb
rollbar-3.1.2 lib/rollbar/logger_proxy.rb
rollbar-3.1.1 lib/rollbar/logger_proxy.rb
rollbar-3.1.0 lib/rollbar/logger_proxy.rb
rollbar-3.0.1 lib/rollbar/logger_proxy.rb
rollbar-3.0.0 lib/rollbar/logger_proxy.rb
rollbar-2.27.1 lib/rollbar/logger_proxy.rb
rollbar-2.27.0 lib/rollbar/logger_proxy.rb
rollbar-2.26.1 lib/rollbar/logger_proxy.rb
rollbar-2.26.0 lib/rollbar/logger_proxy.rb
rollbar-2.25.1 lib/rollbar/logger_proxy.rb
rollbar-2.25.0 lib/rollbar/logger_proxy.rb
rollbar-2.24.0 lib/rollbar/logger_proxy.rb
rollbar-2.23.2 lib/rollbar/logger_proxy.rb
rollbar-2.23.1 lib/rollbar/logger_proxy.rb
rollbar-2.23.0 lib/rollbar/logger_proxy.rb
rollbar-2.22.1 lib/rollbar/logger_proxy.rb
rollbar-2.22.0 lib/rollbar/logger_proxy.rb
rollbar-2.21.0 lib/rollbar/logger_proxy.rb
rollbar-2.20.2 lib/rollbar/logger_proxy.rb