README.md in silencer-1.0.0.rc3 vs README.md in silencer-1.0.0
- old
+ new
@@ -1,39 +1,62 @@
-# Silencer [![Build Status](https://secure.travis-ci.org/spagalloco/silencer.png?branch=master)][travis] [![Dependency Status](https://gemnasium.com/spagalloco/silencer.png?travis)][gemnasium]
+# Silencer
-[travis]: http://travis-ci.org/spagalloco/silencer
-[gemnasium]: https://gemnasium.com/spagalloco/silencer
+[![Gem Version](http://img.shields.io/gem/v/silencer.svg)][gem]
+[![Build Status](http://img.shields.io/travis/stve/silencer.svg)][travis]
+[![Dependency Status](http://img.shields.io/gemnasium/stve/silencer.svg)][gemnasium]
+
+[gem]: https://rubygems.org/gems/silencer
+[travis]: https://travis-ci.org/stve/silencer
+[gemnasium]: https://gemnasium.com/stve/silencer
+
Silencer is a simple rack-middleware for Rails that can selectively disable logging on per-action basis. It's based on a [blog post](http://dennisreimann.de/blog/silencing-the-rails-log-on-a-per-action-basis/) by Dennis Reimann.
-__Note__: Silencer is not thread safe.
+__Note__: Silencer is only threadsafe in Rails version 4.2.6 and later.
## Installation
Just add silencer to your Gemfile:
gem 'silencer'
## Usage
-In your production environment (presumably):
+### Rails
+Create an initializer (like `config/initializers/silencer.rb`) with the contents:
- require 'silencer/logger'
+```ruby
+require 'silencer/logger'
- config.middleware.swap Rails::Rack::Logger, Silencer::Logger, :silence => ["/noisy/action.json"]
+Rails.application.configure do
+ config.middleware.swap Rails::Rack::Logger, Silencer::Logger, :silence => ["/noisy/action.json"]
+end
+```
-Or if you'd prefer, you can pass it regular expressions:
+### Rack
+```ruby
+require 'silencer/logger'
- config.middleware.swap Rails::Rack::Logger, Silencer::Logger, :silence => [%r{^/assets/}]
+use Silencer::Logger, :silence => ["/noisy/action.json"]
+```
-Or you can silence specific request methods only:
+## Configuration
+Or if you'd prefer, you can pass it regular expressions:
- config.middleware.swap Rails::Rack::Logger, Silencer::Logger, :get => [%r{^/assets/}], :post => [%r{^/some_path}]
+```ruby
+config.middleware.swap Rails::Rack::Logger, Silencer::Logger, :silence => [%r{^/assets/}]
+```
+Or you can silence specific request methods only:
+
+```ruby
+config.middleware.swap Rails::Rack::Logger, Silencer::Logger, :get => [%r{^/assets/}], :post => [%r{^/some_path}]
+```
+
Silencer's logger will serve as a drop-in replacement for Rails' default logger. It will not suppress any logging by default, simply pass it an array of urls via the options hash. You can also send it a 'X-SILENCE-LOGGER' header (with any value) with your request and that will also produce the same behavior.
### All options
Silencer supports the following configuration options.
@@ -51,10 +74,12 @@
### Rails 2.3
Rails 2.3.x introduced a tagged logging feature. If you are using tagged logging with Rails 2.3 you can also pass taggers via the middleware:
- config.middleware.swap Rails::Rack::Logger, Silencer::Logger, config.log_tags, :silence => [%r{^/assets/}]
+```ruby
+config.middleware.swap Rails::Rack::Logger, Silencer::Logger, config.log_tags, :silence => [%r{^/assets/}]
+```
## Note on Patches/Pull Requests
* Fork the project.
* Make your feature addition or bug fix.