Sha256: f6d02f55634c8919348738b89ae69c748cb4780950310330446ca755554a19d0

Contents?: true

Size: 1.39 KB

Versions: 16

Compression:

Stored size: 1.39 KB

Contents

require 'logjam_agent'
module LogjamAgent
  class Railtie < Rails::Railtie

    initializer "initialize_logjam_agent_logger", :before => :initialize_logger do |app|
      Rails.logger ||= app.config.logger ||
        begin
          path = app.config.paths.log.to_a.first
          logger = LogjamAgent::BufferedLogger.new(path)
          logger.level = ActiveSupport::BufferedLogger.const_get(app.config.log_level.to_s.upcase)
          logger.auto_flushing = false if Rails.env.production?
          logger
        rescue StandardError => e
          logger = LogjamAgent::BufferedLogger.new(STDERR)
          logger.level = ActiveSupport::BufferedLogger::WARN
          logger.warn(
                      "Logging Error: Unable to access log file. Please ensure that #{path} exists and is writable. " +
                      "The log level has been raised to WARN and the output directed to STDERR until the problem is fixed."
                      )
          logger
        end
    end

    initializer "logjam_agent", :after => "time_bandits" do |app|
      app.config.middleware.swap("TimeBandits::Rack::Logger", "LogjamAgent::Rack::Logger")
      app.config.middleware.insert_before("LogjamAgent::Rack::Logger", "LogjamAgent::Middleware")

      ActiveSupport.on_load(:action_controller) do
        require 'logjam_agent/middleware.rb'
        require 'logjam_agent/rack/logger.rb'
      end
    end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
logjam_agent-0.3.6 lib/logjam_agent/railtie.rb
logjam_agent-0.3.5 lib/logjam_agent/railtie.rb
logjam_agent-0.3.4 lib/logjam_agent/railtie.rb
logjam_agent-0.3.3 lib/logjam_agent/railtie.rb
logjam_agent-0.3.2 lib/logjam_agent/railtie.rb
logjam_agent-0.3.1 lib/logjam_agent/railtie.rb
logjam_agent-0.3.0 lib/logjam_agent/railtie.rb
logjam_agent-0.2.4 lib/logjam_agent/railtie.rb
logjam_agent-0.2.3 lib/logjam_agent/railtie.rb
logjam_agent-0.2.2 lib/logjam_agent/railtie.rb
logjam_agent-0.2.1 lib/logjam_agent/railtie.rb
logjam_agent-0.2.0 lib/logjam_agent/railtie.rb
logjam_agent-0.1.3 lib/logjam_agent/railtie.rb
logjam_agent-0.1.2 lib/logjam_agent/railtie.rb
logjam_agent-0.1.1 lib/logjam_agent/railtie.rb
logjam_agent-0.1.0 lib/logjam_agent/railtie.rb