Permalink
Browse files

extract logger and development checks to methods

  • Loading branch information...
1 parent 56f3d05 commit 23b69c95ac24b6c0faf682e0f8a1f9acc53f43f8 @tenderlove tenderlove committed Jan 8, 2013
Showing with 16 additions and 6 deletions.
  1. +16 −6 railties/lib/rails/rack/logger.rb
@@ -12,8 +12,8 @@ def initialize(app, taggers = nil)
def call(env)
request = ActionDispatch::Request.new(env)
- if Rails.logger.respond_to?(:tagged)
- Rails.logger.tagged(compute_tags(request)) { call_app(request, env) }
+ if logger.respond_to?(:tagged)
+ logger.tagged(compute_tags(request)) { call_app(request, env) }
else
call_app(request, env)
end
@@ -23,12 +23,12 @@ def call(env)
def call_app(request, env)
# Put some space between requests in development logs.
- if Rails.env.development?
- Rails.logger.debug ''
- Rails.logger.debug ''
+ if development?
+ logger.debug ''
+ logger.debug ''
end
- Rails.logger.info started_request_message(request)
+ logger.info started_request_message(request)
@app.call(env)
ensure
ActiveSupport::LogSubscriber.flush_all!
@@ -55,6 +55,16 @@ def compute_tags(request)
end
end
end
+
+ private
+
+ def development?
+ Rails.env.development?
+ end
+
+ def logger
+ Rails.logger
+ end
end
end
end

0 comments on commit 23b69c9

Please sign in to comment.