Sha256: 686c736bc4f23cd314969dd92165afba539b068c5bba00788f1e02c7da41c0f7

Contents?: true

Size: 962 Bytes

Versions: 21

Compression:

Stored size: 962 Bytes

Contents

require 'rack'
class QuietCommonLogger < Rack::CommonLogger
  include Rack

  @@ignore_extensions = %w(png jpg jpeg ico gif woff tff svg eot css js)

  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
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
volt-0.9.7.pre8 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.7.pre7 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.7.pre6 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.7.pre5 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.7.pre3 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.7.pre2 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.6 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.6.pre3 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.6.pre2 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.6.pre1 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.5 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.5.pre12 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.5.pre11 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.5.pre9 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.5.pre8 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.5.pre7 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.5.pre6 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.5.pre5 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.5.pre4 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.5.pre3 lib/volt/server/rack/quiet_common_logger.rb