Rack::CommonLogger forwards every request to an app
given, and
logs a line in the Apache common log format to the logger
, or
rack.errors by default.
Common Log Format: httpd.apache.org/docs/1.3/logs.html#common lilith.local - - [07/Aug/2006 23:58:02] “GET / HTTP/1.1” 500 -
%{%s - %s [%s] "%s %s%s %s" %d %s\n} %
# File lib/sinatra/rack_logger.rb, line 30 def log_path(path=nil) @log_file ||= path end
# File lib/sinatra/rack_logger.rb, line 54 def logger @logger ||= ::Logger.new(log_path || $stdout) end
If Deltacloud is started with the -L/–log option then we set logger to this file, otherwise use the default Sinatra logger facility
# File lib/sinatra/rack_logger.rb, line 76 def initialize(app, logger=nil) @app = app if self.class.log_path @logger = self.class.logger else @logger = logger end end
# File lib/sinatra/rack_logger.rb, line 42 def setup(path, be_verbose=false) verbose(be_verbose) return self if path.nil? dir = ::File.dirname(path) if ::File.exists?(dir) and ::File.writable?(dir) log_path(path) else warn "Warning: The log directory (#{dir}) is not writeable." end self end
# File lib/sinatra/rack_logger.rb, line 38 def verbose(v=nil) @verbose ||= v end
# File lib/sinatra/rack_logger.rb, line 34 def verbose? @verbose end
# File lib/sinatra/rack_logger.rb, line 85 def call(env) began_at = Time.now status, header, body = @app.call(env) header = Utils::HeaderHash.new(header) body = BodyProxy.new(body) do self.class.verbose? ? verbose_log(env, status, header, began_at) : log(env, status, header, began_at) end [status, header, body] end