logger.rb 357 B

123456789101112131415161718
  1. require 'logger'
  2. module Rack
  3. # Sets up rack.logger to write to rack.errors stream
  4. class Logger
  5. def initialize(app, level = ::Logger::INFO)
  6. @app, @level = app, level
  7. end
  8. def call(env)
  9. logger = ::Logger.new(env['rack.errors'])
  10. logger.level = @level
  11. env['rack.logger'] = logger
  12. @app.call(env)
  13. end
  14. end
  15. end