Permalink
Browse files

[padrino-core] Added in our logs app name space for urls and layouts …

…- issue #170
  • Loading branch information...
DAddYE committed Mar 30, 2011
1 parent 39a08b2 commit a7796bd0b037c6f50d408f908e05a9e9af79bf69
View
@@ -18,6 +18,7 @@
* Correctly work with nested parameters sent to url [Thanks to Funny-falcon]
* Fix ajax request detection for dataType: 'application/javascript'
* Removed lib from excluded list of our reloader
* Added in our logs app name space for urls and layouts
== 0.9.23
@@ -198,9 +198,9 @@ def calculate_paths
# Requires the Padrino middleware
#
def register_initializers
use Padrino::Logger::Rack if Padrino.logger && (Padrino.logger.level == 0 && padrino_logging?)
use Padrino::Reloader::Rack if reload?
use Rack::Flash if flash? && sessions?
use Padrino::Logger::Rack, uri_root if Padrino.logger && (Padrino.logger.level == 0 && padrino_logging?)
use Padrino::Reloader::Rack if reload?
use Rack::Flash if flash? && sessions?
end
##
@@ -236,4 +236,4 @@ def clean_backtrace(trace)
}.map! { |line| line.gsub(/^\.\//, '') }
end
end # Application
end # Padrino
end # Padrino
@@ -117,16 +117,19 @@ def render(engine, data=nil, options={}, locals={}, &block)
# Sinatra 1.0 requires an outvar for erb and erubis templates
options[:outvar] ||= '@_out_buf' if [:erb, :erubis] & [engine]
# Setup uri_root
uri_root = settings.uri_root.sub(/\/$/,"")
# Resolve layouts similar to in Rails
if (options[:layout].nil? || options[:layout] == true) && !settings.templates.has_key?(:layout)
layout_path, layout_engine = *resolved_layout
options[:layout] = layout_path || false # We need to force layout false so sinatra don't try to render it
options[:layout] = false unless layout_engine == engine # TODO allow different layout engine
options[:layout_engine] = layout_engine || engine if options[:layout]
logger.debug "Resolving layout #{options[:layout]}" if defined?(logger) && options[:layout].present?
logger.debug "Resolving layout #{uri_root}/views#{options[:layout]}" if defined?(logger) && options[:layout].present?
elsif options[:layout].present?
options[:layout] = settings.fetch_layout_path(options[:layout])
logger.debug "Resolving layout #{options[:layout]}" if defined?(logger)
logger.debug "Resolving layout #{uri_root}/views#{options[:layout]}" if defined?(logger)
end
# Pass arguments to Sinatra render method
@@ -271,10 +271,11 @@ class Rack
# "lilith.local - - GET / HTTP/1.1 500 -"
# %{%s - %s %s %s%s %s - %d %s %0.4f}
#
FORMAT = %{%s - %s %s %s%s %s - %d %s %0.4f}
FORMAT = %{%s - %s %s %s%s%s %s - %d %s %0.4f}
def initialize(app)
def initialize(app, uri_root)
@app = app
@uri_root = uri_root.sub(/\/$/,"")
end
def call(env)
@@ -293,6 +294,7 @@ def log(env, status, header, began_at)
env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"] || "-",
env["REMOTE_USER"] || "-",
env["REQUEST_METHOD"],
@uri_root || "",
env["PATH_INFO"],
env["QUERY_STRING"].empty? ? "" : "?" + env["QUERY_STRING"],
env["HTTP_VERSION"],

0 comments on commit a7796bd

Please sign in to comment.