Skip to content

Instantly share code, notes, and snippets.

@mtodd
Created September 15, 2008 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtodd/10821 to your computer and use it in GitHub Desktop.
Save mtodd/10821 to your computer and use it in GitHub Desktop.
class Rack::Logger
def initialize(app, logger)
@app = app
@logger = logger
end
def call(env)
env["rack.logger"] = @logger
result = @app.call(env)
@logger.flush if @logger.respond_to?(:flush)
result
end
end
use Rack::Logger, Logger.new(STDOUT)
# or
use Rack::Logger, ActiveSupport::BufferedLogger.new("rack.log")
run lambda { |env|
env["rack.logger"].warn "Hey Logger"
[200, {"Content-Type" => "text/html"}, "Hello, World!"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment