silencer 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +6 -0
- data/lib/silencer/logger.rb +3 -1
- data/lib/silencer/version.rb +1 -1
- data/spec/silencer_spec.rb +7 -1
- metadata +3 -9
data/README.md
CHANGED
|
@@ -27,6 +27,12 @@ Or if you'd prefer, you can pass it regular expressions:
|
|
|
27
27
|
|
|
28
28
|
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.
|
|
29
29
|
|
|
30
|
+
### Rails 2.3
|
|
31
|
+
|
|
32
|
+
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:
|
|
33
|
+
|
|
34
|
+
config.middleware.swap Rails::Rack::Logger, Silencer::Logger, config.log_tags, :silence => [/assets/]
|
|
35
|
+
|
|
30
36
|
## Note on Patches/Pull Requests
|
|
31
37
|
|
|
32
38
|
* Fork the project.
|
data/lib/silencer/logger.rb
CHANGED
|
@@ -3,8 +3,10 @@ require 'active_support/core_ext/array/wrap'
|
|
|
3
3
|
|
|
4
4
|
module Silencer
|
|
5
5
|
class Logger < Rails::Rack::Logger
|
|
6
|
-
def initialize(app,
|
|
6
|
+
def initialize(app, *taggers)
|
|
7
7
|
@app = app
|
|
8
|
+
@taggers = taggers
|
|
9
|
+
opts = @taggers.extract_options!
|
|
8
10
|
@silence = Array.wrap(opts[:silence])
|
|
9
11
|
end
|
|
10
12
|
|
data/lib/silencer/version.rb
CHANGED
data/spec/silencer_spec.rb
CHANGED
|
@@ -17,6 +17,12 @@ describe Silencer::Logger do
|
|
|
17
17
|
Silencer::Logger.new(@app).call(Rack::MockRequest.env_for("/"))
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
it 'instantiates with an optional taggers array' do
|
|
21
|
+
Rails.logger.should_not_receive(:level=).with(::Logger::ERROR).once
|
|
22
|
+
|
|
23
|
+
Silencer::Logger.new(@app, :uuid, :queue, :silence => ['/']).call(Rack::MockRequest.env_for("/"))
|
|
24
|
+
end
|
|
25
|
+
|
|
20
26
|
it 'quiets the log when configured with a silenced path' do
|
|
21
27
|
Rails.logger.should_receive(:level=).with(::Logger::ERROR).once
|
|
22
28
|
|
|
@@ -39,4 +45,4 @@ describe Silencer::Logger do
|
|
|
39
45
|
response = Silencer::Logger.new(@app).call(Rack::MockRequest.env_for("/", 'X-SILENCE-LOGGER' => 'true'))
|
|
40
46
|
response[0].should eq(200)
|
|
41
47
|
end
|
|
42
|
-
end
|
|
48
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: silencer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-
|
|
12
|
+
date: 2012-10-16 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rake
|
|
@@ -174,21 +174,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
174
174
|
- - ! '>='
|
|
175
175
|
- !ruby/object:Gem::Version
|
|
176
176
|
version: '0'
|
|
177
|
-
segments:
|
|
178
|
-
- 0
|
|
179
|
-
hash: -4285288290975348200
|
|
180
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
178
|
none: false
|
|
182
179
|
requirements:
|
|
183
180
|
- - ! '>='
|
|
184
181
|
- !ruby/object:Gem::Version
|
|
185
182
|
version: '0'
|
|
186
|
-
segments:
|
|
187
|
-
- 0
|
|
188
|
-
hash: -4285288290975348200
|
|
189
183
|
requirements: []
|
|
190
184
|
rubyforge_project:
|
|
191
|
-
rubygems_version: 1.8.
|
|
185
|
+
rubygems_version: 1.8.23
|
|
192
186
|
signing_key:
|
|
193
187
|
specification_version: 3
|
|
194
188
|
summary: Selectively quiet your Rails logger on a per-action basis
|