Permalink
Browse files

Tag the blank log line between dev requests so it's easier to filter …

…out entire requests with grep -v without leaving a stray newline behind. Example:

  # Tag asset requests so it's easy to filter them from dev logs
  config.log_tags = [
    -> request { :assets if request.path.starts_with?(config.assets.prefix) },
    -> request { request.uuid }
  ]

  # Watch the logs, ignoring asset requests
  $ tail -100f log/development.log | grep -v assets
  • Loading branch information...
1 parent f89ef12 commit 1a7049906ee6735bae058e9985a3806d08d9746b @jeremy jeremy committed Oct 7, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 railties/lib/rails/rack/logger.rb
View
6 railties/lib/rails/rack/logger.rb
@@ -12,9 +12,6 @@ def initialize(app, taggers = nil)
def call(env)
request = ActionDispatch::Request.new(env)
- # Put some space between requests in development logs.
- Rails.logger.info "\n\n" if Rails.env.development?
-
if Rails.logger.respond_to?(:tagged)
Rails.logger.tagged(compute_tags(request)) { call_app(request, env) }
else
@@ -25,6 +22,9 @@ def call(env)
protected
def call_app(request, env)
+ # Put some space between requests in development logs.
+ Rails.logger.info "\n\n" if Rails.env.development?
+
Rails.logger.info started_request_message(request)
@app.call(env)
ensure

0 comments on commit 1a70499

Please sign in to comment.