Skip to content

Instantly share code, notes, and snippets.

@toolmantim
Last active December 13, 2015 18:48
Show Gist options
  • Save toolmantim/4957786 to your computer and use it in GitHub Desktop.
Save toolmantim/4957786 to your computer and use it in GitHub Desktop.
Filtering asset requests from the development log using Rails 3.2
# Add the following configuration to your config/environments/development.rb file
#
# This will set the Rails to log to STDOUT (insetad of log/development.log) as well
# as tag all assets request log lines with [assets]
#
# You can then pipe it into grep to filter out the asset lines
#
# tail -f log/development.rb | grep -v '\[assets\]'
#
# If you log to STDOUT rather than log/development.rb then you can:
#
# rails s | grep -v '\[assets\]'
#
# or:
#
# foreman start | grep -v '\[assets\]'
SomeApp::Application.configure do
# Tag assets requests log lines with [assets]
config.log_tags = [
-> request { :assets if request.path.starts_with?(config.assets.prefix) },
-> request { nil }
]
# If you want to log to STDOUT rather than log files
# config.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
end
@lengarvey
Copy link

I tend to use: https://github.com/evrone/quiet_assets since most of the time I don't actually need to see asset requests and if I'm debugging something I can just flick them on.

Still a really cool trick!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment