Merge pull request #372 from bhollis/timing

Add timing info to render logging, and document why we use thin instead of webrick
This commit is contained in:
Thomas Reynolds 2012-04-23 10:27:04 -07:00
commit 5405af5e0f
2 changed files with 8 additions and 8 deletions

View file

@ -378,6 +378,8 @@ module Middleman
#
# @private
def process_request
start_time = Time.now
# Normalize the path and add index if we're looking at a directory
@original_path = env["PATH_INFO"].dup
@escaped_path = @original_path.gsub("%20", " ")
@ -418,7 +420,7 @@ module Middleman
end
# End the request
puts "== Finishing Request: #{self.current_path}" if logging?
puts "== Finishing Request: #{self.current_path} (#{(Time.now - start_time).round(2)}s)" if logging?
halt res.finish
end
@ -531,24 +533,21 @@ module Middleman
# @param [Hash] options to pass to Rack::Server.new
# @return [Rack::Server]
def start_server(options={})
require "webrick"
opts = {
:Port => options[:port] || 4567,
:Host => options[:host] || "0.0.0.0",
:AccessLog => []
}
# opts[:Logger] = WEBrick::Log::new("/dev/null", 7) if !options[:logging]
app_class = options[:app] ||= ::Middleman.server.inst
opts[:app] = app_class
# Disable for Beta 1. See if people notice.
# Use Thin because Webrick gets confused and mixes
# up responses.
# TODO: Figure that out and drop Thin dependency
require "thin"
::Thin::Logging.silent = !options[:logging]
opts[:server] = 'thin'
# opts[:server] = 'webrick'
server = ::Rack::Server.new(opts)
server.start

View file

@ -88,6 +88,7 @@ module Middleman::Sitemap
def render(opts={}, locs={}, &block)
return File.open(source_file).read unless template?
start_time = Time.now
puts "== Render Start: #{source_file}" if app.logging?
md = metadata.dup
@ -106,7 +107,7 @@ module Middleman::Sitemap
app.instance_eval(&block) if block_given?
result = app.render_template(source_file, locs, opts)
puts "== Render End: #{source_file}" if app.logging?
puts "== Render End: #{source_file} (#{(Time.now - start_time).round(2)}s)" if app.logging?
result
end