Sha256: de1e4313f6ece93d54550be6c966c4b0684cdb430f47561d9e1dcfab50f477c4

Contents?: true

Size: 752 Bytes

Versions: 3

Compression:

Stored size: 752 Bytes

Contents

# frozen_string_literal: true
require 'logger'

module Raven
  class Logger
    LOG_PREFIX = "** [Raven] ".freeze

    LEVELS = {
      :debug => ::Logger::DEBUG,
      :info => ::Logger::INFO,
      :warn => ::Logger::WARN,
      :error => ::Logger::ERROR,
      :fatal => ::Logger::FATAL
    }.freeze

    [
      :fatal,
      :error,
      :warn,
      :info,
      :debug,
    ].each do |level|
      define_method level do |*args, &block|
        msg = args[0] # Block-level default args is a 1.9 feature
        msg ||= block.call if block
        logger = Raven.configuration[:logger]
        logger = ::Logger.new(STDOUT) if logger.nil?

        logger.add(LEVELS[level], "#{LOG_PREFIX}#{msg}", "sentry") if logger
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sentry-raven-1.2.2 lib/raven/logger.rb
sentry-raven-1.2.1 lib/raven/logger.rb
sentry-raven-1.2.0 lib/raven/logger.rb