Sha256: 63260908a5f64fd1985614e2a020481542e72cdffe5c213c58f462fda772956c

Contents?: true

Size: 958 Bytes

Versions: 11

Compression:

Stored size: 958 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)
      unless Rollbar.configuration.enabled && acceptable_levels.include?(level.to_sym)
        return
      end

      @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

11 entries across 11 versions & 1 rubygems

Version Path
rollbar-3.6.0 lib/rollbar/logger_proxy.rb
rollbar-3.5.2 lib/rollbar/logger_proxy.rb
rollbar-3.5.1 lib/rollbar/logger_proxy.rb
rollbar-3.5.0 lib/rollbar/logger_proxy.rb
rollbar-3.4.2 lib/rollbar/logger_proxy.rb
rollbar-3.4.1 lib/rollbar/logger_proxy.rb
rollbar-3.4.0 lib/rollbar/logger_proxy.rb
rollbar-3.3.3 lib/rollbar/logger_proxy.rb
rollbar-3.3.2 lib/rollbar/logger_proxy.rb
rollbar-3.3.1 lib/rollbar/logger_proxy.rb
rollbar-3.3.0 lib/rollbar/logger_proxy.rb