Sha256: c9d375f39a1ad8a11190eabccbd3b738f938418cd44a68c497cbf8e0e04974ff

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

require 'rack/action_logger/emit_adapter/logger_adapter'
require 'rack/action_logger/emit_adapter/fluent_adapter'
require 'rack/action_logger/emit_adapter/null_adapter'
require 'logger'

module Rack::ActionLogger
  class Configuration
    DEFAULT_TAG_PREFIX = 'action'

    attr_accessor :emit_adapter
    attr_accessor :wrap_key
    attr_accessor :tag_prefix
    attr_accessor :logger
    attr_accessor :filters
    attr_accessor :rack_request_blacklist
    attr_accessor :pretty_print
    attr_accessor :rack_metrics

    def initialize
      @emit_adapter = EmitAdapter::LoggerAdapter
      @tag_prefix = DEFAULT_TAG_PREFIX
      @logger = Logger.new(STDOUT)
      @logger.progname = 'rack-action_logger'
      @filters = ['password']
      @rack_request_blacklist = [:request_headers, :response_headers, :response_json_body]
      @pretty_print = true
      @rack_metrics = Rack::ActionLogger::Metrics::RackMetrics
    end

    def tag_prefix
      if @tag_prefix.to_s.empty?
        Rack::ActionLogger.logger.error('tag_prefix should not be empty')
        @tag_prefix = DEFAULT_TAG_PREFIX
      end
      @tag_prefix
    end

    def default_tag
      [tag_prefix, 'log'].join('.')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-action_logger-0.1.3 lib/rack/action_logger/configuration.rb
rack-action_logger-0.1.2 lib/rack/action_logger/configuration.rb