Sha256: 7364493ce824c70578b27c5ed6060a3b70f0fef8e2775bd993a7c7bfe70b9ac8

Contents?: true

Size: 840 Bytes

Versions: 3

Compression:

Stored size: 840 Bytes

Contents

require 'loggr/adapter/base'
require 'loggr/support/annotations'
require 'active_support/buffered_logger'

module Loggr
  module Adapter

    # Backend for `ActiveSupport::BufferedLogger`.
    #
    class BufferedAdapter < BaseAdapter

      protected
        # Creates a new `AS::BufferedLogger` instance, note that BufferedLogger has
        # no support for setting a default progname, so `name` is basically ignored.
        #
        def build_new_logger(name, options = {})
          logger = ActiveSupport::BufferedLogger.new(options[:to] || "#{name.to_s.gsub(/[\s\/]+/, '_')}.log").tap do |logger|
            logger.level = options[:level] || ActiveSupport::BufferedLogger::INFO
          end
          Loggr::Support::Annotations.enhance(logger)
        end
    end

    # THE instance
    Buffered = BufferedAdapter.new
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
loggr-1.1.2 lib/loggr/adapter/buffered.rb
loggr-1.1.1 lib/loggr/adapter/buffered.rb
loggr-1.1.0 lib/loggr/adapter/buffered.rb