class Loga::Railtie::InitializeMiddleware

Attributes

app[R]

Public Class Methods

call(app) click to toggle source
# File lib/loga/railtie.rb, line 96
def self.call(app)
  new(app).call
end
new(app) click to toggle source
# File lib/loga/railtie.rb, line 100
def initialize(app)
  @app = app
end

Public Instance Methods

call() click to toggle source
# File lib/loga/railtie.rb, line 104
def call
  insert_loga_rack_logger
  silence_rails_rack_logger
  insert_exceptions_catcher
  silence_action_dispatch_debug_exceptions_logger
end

Private Instance Methods

insert_exceptions_catcher() click to toggle source
# File lib/loga/railtie.rb, line 115
def insert_exceptions_catcher
  if defined?(ActionDispatch::DebugExceptions)
    ActionDispatch::DebugExceptions.send(:include, ExceptionsCatcher)
  elsif defined?(ActionDispatch::ShowExceptions)
    ActionDispatch::ShowExceptions.send(:include, ExceptionsCatcher)
  end
end
insert_loga_rack_logger() click to toggle source
# File lib/loga/railtie.rb, line 141
def insert_loga_rack_logger
  app.middleware.insert_after Rails::Rack::Logger, Loga::Rack::Logger
end
silence_action_dispatch_debug_exceptions_logger() click to toggle source

Removes unstructured exception output. Exceptions are logged with Loga::Rack::Logger instead

# File lib/loga/railtie.rb, line 137
def silence_action_dispatch_debug_exceptions_logger
  require 'loga/ext/rails/rack/debug_exceptions.rb'
end
silence_rails_rack_logger() click to toggle source

Removes start of request log (e.g. Started GET “/users” for 127.0.0.1 at 2015-12-24 23:59:00 +0000)

# File lib/loga/railtie.rb, line 125
def silence_rails_rack_logger
  case Rails::VERSION::MAJOR
  when 3    then require 'loga/ext/rails/rack/logger3.rb'
  when 4..6 then require 'loga/ext/rails/rack/logger.rb'
  else
    raise Loga::ConfigurationError,
          "Rails #{Rails::VERSION::MAJOR} is unsupported"
  end
end