class QuietCommonLogger

Public Instance Methods

call(env) click to toggle source
# File lib/volt/server/rack/quiet_common_logger.rb, line 7
def call(env)
  path = env['PATH_INFO']
  began_at = Time.now
  status, header, body = @app.call(env)
  header = Utils::HeaderHash.new(header)
  base = ::File.basename(path)
  if base.index('.')
    ext = base.split('.').last
  else
    ext = nil
  end

  @logged = false

  body = BodyProxy.new(body) do
    # Don't log on ignored extensions
    if !@@ignore_extensions.include?(ext) &&
       !path.start_with?('/__OPAL_SOURCE_MAPS__/') &&
       !@logged
      log(env, status, header, began_at)
    end
  end

  # Because of web sockets, the initial request doesn't finish, so we
  # can just trigger it now.
  unless ext || path.start_with?('/channel')
    @logged = true
    log(env, status, header, began_at)
  end

  [status, header, body]
end