paul_bunyan 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9faf88c896e659a4e197204602b9a74ad16e1ed6
4
- data.tar.gz: c2eeb9d27331dba0843e9c4f0a0dc1aeafbf04dd
3
+ metadata.gz: d8ea928ce32c34a63cd4b14dc3e2bf1636472539
4
+ data.tar.gz: fa38000b5ceecda0373c2a6c29d0f917f50c7ba4
5
5
  SHA512:
6
- metadata.gz: eb99a1f146a20ef706ced17bc9909568696bb8190d994dd12f309d739179adfec7715019291d69f29a3c1b9127d30bf09c5303444c5d6917d6db731253792b47
7
- data.tar.gz: 645fa919eb06097ebf2b4695262fb7fb8b78427366156818e876bf8848f5728860b0a5f5a66a5714cfed75b9b656e382fcee8ccdcfaeaf8845525efabaf35862
6
+ metadata.gz: 2a7f5fb1dd233492d92daa32e25a67ce315eaf460d834924cb20771ed7c92bc287fad20f091373c00e60aa3ab5050e9d7114f633656a724820da9fa053822f16
7
+ data.tar.gz: e0e153759bbb4d25eb0005a3e69f768e48cb91f583642aa4938676d2ec2a4068e0311abb2661db1408c32cef4f82a978c89e2c29e60aa78ff62a4cc951bbd76a
@@ -95,6 +95,19 @@ module PaulBunyan
95
95
  logger.nil? ? DEBUG : logger.level
96
96
  end
97
97
 
98
+ def silence(level = Logger::ERROR, &block)
99
+ loggers = self.loggers.select { |l| l.respond_to?(:silence) }.reverse
100
+ silencer = proc do
101
+ logger = loggers.pop
102
+ if logger
103
+ logger.silence(level, &silencer)
104
+ else
105
+ block.call
106
+ end
107
+ end
108
+ silencer.call
109
+ end
110
+
98
111
  module TaggedRelayer
99
112
  def current_tags
100
113
  tags = loggers.each_with_object(Set.new) do |logger, set|
@@ -1,3 +1,3 @@
1
1
  module PaulBunyan
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -330,4 +330,20 @@ describe PaulBunyan::LogRelayer do
330
330
  end
331
331
  end
332
332
  end
333
+
334
+ context 'silence' do
335
+ describe '#silence' do
336
+ it 'calls silence on all loggers' do
337
+ expect(primary).to receive(:silence).with(Logger::WARN) { |&b| b.call }
338
+ expect(secondary).to receive(:silence).with(Logger::WARN) { |&b| b.call }
339
+ expect { |b| double_relayer.silence(Logger::WARN, &b) }.to yield_control
340
+ end
341
+
342
+ it 'skips loggers without a #silence method' do
343
+ allow(secondary).to receive(:respond_to?) { false }
344
+ expect(primary).to receive(:silence).with(Logger::WARN) { |&b| b.call }
345
+ expect { |b| double_relayer.silence(Logger::WARN, &b) }.to yield_control
346
+ end
347
+ end
348
+ end
333
349
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paul_bunyan
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Duane Johnson
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-06-22 00:00:00.000000000 Z
14
+ date: 2016-06-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: request_store