From 936372cb5739440b64ef58eb6bbc8596c1f94ebc Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 2 Mar 2012 13:29:15 -0500 Subject: [PATCH] add ability to enable/disable logging --- lib/flowerbox/delivery/server.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/flowerbox/delivery/server.rb b/lib/flowerbox/delivery/server.rb index ab9bf12..8da608a 100644 --- a/lib/flowerbox/delivery/server.rb +++ b/lib/flowerbox/delivery/server.rb @@ -8,12 +8,18 @@ module Flowerbox attr_reader :options def initialize(options = {}) - @options = options || {} + @options = { :logging => false }.merge(options || {}) end def start @server_thread = Thread.new do - ::Rack::Handler::WEBrick.run(options[:app], :Port => port, :Host => interface) do |server| + server_options = { :Port => port, :Host => interface } + if !options[:logging] + server_options[:AccessLog] = [ nil, nil ] + server_options[:Logger] = Logger.new('/dev/null') + end + + ::Rack::Handler::WEBrick.run(options[:app], server_options) do |server| trap('QUIT') { server.stop } Thread.current[:server] = server @@ -21,8 +27,6 @@ module Flowerbox end while !@server_thread[:server] && @server_thread.alive? - $stderr.puts "waiting" - sleep 0.1 end