lib/rlyeh/deep_ones/logger.rb in rlyeh-0.0.2 vs lib/rlyeh/deep_ones/logger.rb in rlyeh-0.1.1
- old
+ new
@@ -1,22 +1,24 @@
-require 'logger'
+require 'rlyeh/logger'
module Rlyeh
module DeepOnes
class Logger
- def initialize(app, options = {})
+ include Rlyeh::Logger
+
+ def initialize(app, logger = nil, level = :debug)
@app = app
- @logger = options[:logger] || ::Logger.new(STDOUT)
- @logger.level = options[:level] || ::Logger::INFO
+ @logger = logger || self
+ @level = level
end
def call(env)
write env
- @app.call env
+ @app.call env if @app
end
def write(env)
- @logger.debug env.data
+ @logger.__send__ @level, "Message received: #{env.data}"
end
end
end
end