0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Silence your Rails logs under certain conditions.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Log Shusher

Silence your Rails logs under certain conditions.

Installation

Add the gem to your Gemfile:

gem 'log_shusher'

and run

bundle

Usage

Add the following code in an initializer (e.g: config/initializers/log_shusher.rb) or in an environment configuration file (e.g: config/environments/development.rb):

LogShusher.shush do |env|
   # expression
end

The env parameter is the Rack environment hash corresponding to the current request. The request will be logged if the expression inside the block evaluates to nil or false.

Examples:

# Don't log any request
LogShusher.shush do |env|
  true
end

# Don't log asset requests
LogShusher.shush do |env|
  env['PATH_INFO'].to_s.include? '/assets/'
end

# Don't log requests for certain file extensions
LogShusher.shush do |env|
  exts = %w{ .ico .js .css .gif .png .jpeg .jpg }
  exts.any? { |ext| env['PATH_INFO'].to_s.ends_with?(ext) }
end

License

Released under the MIT License, Copyright (c) 2014 - To infity... and beyond! Raúl Murciano.