Sha256: 01dd9ae303531cafdb12dc5129326c4c4a48ec829751495fd2171316498b0823

Contents?: true

Size: 1.25 KB

Versions: 8

Compression:

Stored size: 1.25 KB

Contents

require 'logger'
require 'logatron/const'
require 'logatron/basic_formatter'
require 'logatron/error_formatter'
require 'logatron/backtrace_cleaner'
require 'active_support/backtrace_cleaner'
require 'active_support/json'

module Logatron
  class << self
    def configuration=
      @configuration = configuration
    end

    def configuration
      @configuration ||= Configuration.new
    end
  end

  def self.configure
    configuration
    yield(configuration)
  end

  class Configuration
    attr_accessor :logger, :host, :level, :transformer, :app_id, :error_formatter
    attr_reader :loggable_levels, :backtrace_cleaner

    def initialize
      @logger = Logger.new(STDOUT)
      @app_id = 'N/A'
      @transformer = proc { |x| x.to_json }
      @host = `hostname`.chomp
      @level = INFO
      level_threshold = SEVERITY_MAP[@level]
      levels = Logatron::SEVERITY_MAP.keys
      @loggable_levels = levels.select { |level| SEVERITY_MAP[level] >= level_threshold }
      @backtrace_cleaner = Logatron::BacktraceCleaner.new
      @error_formatter = Logatron::ErrorFormatter.new
    end

    def logger=(logger)
      level = @logger.level
      @logger = logger
      @logger.level = level
      @logger.formatter = Logatron::BasicFormatter.new
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
logatron-0.15.0 lib/logatron/configuration.rb
logatron-0.14.0 lib/logatron/configuration.rb
logatron-0.13.0 lib/logatron/configuration.rb
logatron-0.12.0 lib/logatron/configuration.rb
logatron-0.11.0 lib/logatron/configuration.rb
logatron-0.10.0 lib/logatron/configuration.rb
logatron-0.9.0 lib/logatron/configuration.rb
logatron-0.8.0 lib/logatron/configuration.rb