Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

NullLogger should actually be a middleware

  • Loading branch information...
commit ab6c66bc8a1ec928e4c3eb0f0b97323879db84dc 1 parent 78ae5ef
Joshua Peek josh authored
Showing with 10 additions and 1 deletion.
  1. +9 −0 lib/rack/nulllogger.rb
  2. +1 −1  test/spec_rack_nulllogger.rb
9 lib/rack/nulllogger.rb
View
@@ -1,5 +1,14 @@
module Rack
class NullLogger
+ def initialize(app)
+ @app = app
+ end
+
+ def call(env)
+ env['rack.logger'] = self
+ @app.call(env)
+ end
+
def info(progname = nil, &block); end
def debug(progname = nil, &block); end
def warn(progname = nil, &block); end
2  test/spec_rack_nulllogger.rb
View
@@ -8,6 +8,6 @@
env['rack.logger'].warn "b00m"
[200, {'Content-Type' => 'text/plain'}, ["Hello, World!"]]
}
- app.call({'rack.logger' => Rack::NullLogger.new})
+ Rack::NullLogger.new(app).call({})
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.