Sha256: 3e2b803ab6dab4ffc945ac8b9685ae459b66c93778fc18efdf629147d63b3e12

Contents?: true

Size: 846 Bytes

Versions: 9

Compression:

Stored size: 846 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

    body = BodyProxy.new(body) do
      # Don't log on ignored extensions
      unless @@ignore_extensions.include?(ext)
        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')
      log(env, status, header, began_at)
    end

    [status, header, body]
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
volt-0.9.3.pre6 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.3.pre5 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.3.pre4 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.3.pre3 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.3.pre2 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.3.pre1 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.2 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.1 lib/volt/server/rack/quiet_common_logger.rb
volt-0.9.1.pre5 lib/volt/server/rack/quiet_common_logger.rb