Permalink
Browse files

NullLogger should actually be a middleware

  • Loading branch information...
1 parent 78ae5ef commit ab6c66bc8a1ec928e4c3eb0f0b97323879db84dc @josh josh committed Dec 11, 2009
Showing with 10 additions and 1 deletion.
  1. +9 −0 lib/rack/nulllogger.rb
  2. +1 −1 test/spec_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
@@ -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

0 comments on commit ab6c66b

Please sign in to comment.