提交 081dfca3 编写于 作者: J José Valim

Clean up Rails::Rack::Logger.

上级 edb81315
...@@ -9,27 +9,23 @@ def initialize(app) ...@@ -9,27 +9,23 @@ def initialize(app)
end end
def call(env) def call(env)
@env = env before_dispatch(env)
before_dispatch @app.call(env)
result = @app.call(@env) ensure
after_dispatch after_dispatch(env)
result
end end
protected protected
def request def before_dispatch(env)
@request ||= ActionDispatch::Request.new(@env) request = ActionDispatch::Request.new(env)
end
def before_dispatch
path = request.request_uri.inspect rescue "unknown" path = request.request_uri.inspect rescue "unknown"
info "\n\nStarted #{request.method.to_s.upcase} #{path} " << info "\n\nStarted #{request.method.to_s.upcase} #{path} " <<
"for #{request.remote_ip} at #{Time.now.to_s(:db)}" "for #{request.remote_ip} at #{Time.now.to_s(:db)}"
end end
def after_dispatch def after_dispatch(env)
Rails::Subscriber.flush_all! Rails::Subscriber.flush_all!
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册