Sha256: 47a558a36925339c83bb7ad818de45bf9b66b126f6d5b68a031632af9adfe8f4

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

require 'loggr/adapter/abstract'
require 'loggr/support/annotations'

module Loggr
  module Adapter

    # Always uses the logger defined on `Rails.logger`, CAVEAT ensure to never
    # ever set `Rails.logger` to this backend, i.e.:
    #
    #    # IF YOU DID THIS...
    #    Loggr.adapter = Loggr::Adapter::Rails
    #
    #    MyApp::Application.configure do
    #      # ...NEVER DO THIS !!!
    #      config.logger = Loggr.logger('rails')
    #    end
    #
    # If you are using the rails adapter, ensure that you do not override `config.logger`
    # with an instance of the Rails adapter logger factory. Keep the default logger, or
    # create a new one using:
    #
    #    config.logger = Loggr.logger('rails', :backend => Loggr::Adapter::Buffered)
    #
    class RailsAdapter < AbstractAdapter

      # The rails backend ignores all options as it just returns
      # always returns `Rails.logger` :)
      #
      # Ensures we get some black magic using `tagged` and `mapped`.
      def logger(name, options = {})
        Loggr::Support::Annotations.enhance ::Rails.logger
      end
    end

    # THE Rails backed implementation instance
    Rails = RailsAdapter.new
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
loggr-1.1.2 lib/loggr/adapter/rails.rb
loggr-1.1.1 lib/loggr/adapter/rails.rb