<commit_before># Log Shusher

Silence your Rails logs under certain conditions.

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`):

```ruby
LogShusher.shush do |env|
   # expression
end
```

The `env` parameter is the [Rack environment hash](http://rack.rubyforge.org/doc/SPEC.html) corresponding to the current request. The request will be logged if the expression inside the block evaluates to `nil` or `false`.

Example: don't log any request

```ruby
LogShusher.shush do |env|
  true
end
```

Example: don't log requests for certain file extensions

```ruby
LogShusher.shush do |env|<commit_msg>Image in README<commit_after># Log Shusher

Silence your Rails logs under certain conditions.

![](https://raw.githubusercontent.com/raul/log_shusher/master/shusher.jpg)

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`):

```ruby
LogShusher.shush do |env|
   # expression
end
```

The `env` parameter is the [Rack environment hash](http://rack.rubyforge.org/doc/SPEC.html) corresponding to the current request. The request will be logged if the expression inside the block evaluates to `nil` or `false`.

Example: don't log any request

```ruby
LogShusher.shush do |env|
  true
end
```

Example: don't log requests for certain file extensions

```ruby
LogShusher.shush do |env|
{'fraction_non_alphanumeric': 0.10620052770448549, 'fraction_numerical': 0.0, 'mean_word_length': 4.92578125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5636680', 'n_tokens_mistral': 488, 'n_tokens_neox': 462, 'n_words': 172}