buffering_logger 2.0.2 → 2.0.3

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: 9168297a1f4a15fcf8289aadcca9bfc4ea8b403d
4
- data.tar.gz: d354f4dc69923e6d80cca22d40eed6a177741153
3
+ metadata.gz: 8fa7fd977ce2384f69fe8c43f5ec0a9b8a65d49f
4
+ data.tar.gz: 304a6a02b266ff01c9be3cdcbd14f56bcec533ca
5
5
  SHA512:
6
- metadata.gz: 412f58633a22807483e11483173aecef9a4cf9591def697711ee8431240a53d297b211c1a1813a2d95a522a875cbc0effeccb22e0e1684ebd68998b7b691cf0a
7
- data.tar.gz: 2f28a0e6d62404c3c146d0c6d1de987a67783e46a959e5b6647595332dae80c7d6e2a055837bb40874ee0f1841075322f8005d234bd45a0e38cf6421b8d8970d
6
+ metadata.gz: 07a9d3b0caa90abd4c7576424342cc9c5e739f71384caf06e789c97b6c6559a71e9243e18cee2b416bbd708bae38663dab12ebcd714d2c2ac48204b20758581e
7
+ data.tar.gz: a86ac7136625e40dba9b1d4b35d7a42a5db5648580a81c6789798663d598938a1047e9a0920443a9ba229a79f035b7ea440ff47612018a7ab6fc44fd55fc5ab7
@@ -9,6 +9,7 @@ module BufferingLogger
9
9
 
10
10
  def initialize(logdev, shift_age: 0, shift_size: 1048576)
11
11
  @shift_age, @shift_size = shift_age, shift_size
12
+ @opened_logdev = false
12
13
  super(nil, shift_age, shift_size)
13
14
  self.logdev = logdev
14
15
  end
@@ -16,10 +17,16 @@ module BufferingLogger
16
17
  # allow changing the log destination. e.g.: in Unicorn during after_fork to
17
18
  # set a separate log path for each worker.
18
19
  def logdev=(logdev)
19
- @logdev.close if @logdev
20
- @logdev = Buffer.new(
21
- LogDevice.new(logdev, shift_age: @shift_age, shift_size: @shift_size)
22
- )
20
+ @logdev.close if @logdev && @opened_logdev
21
+
22
+ raw_log_device = LogDevice.new(logdev, shift_age: @shift_age, shift_size: @shift_size)
23
+
24
+ # if we opened the logdev then we should close it when we're done
25
+ if raw_log_device.dev != logdev
26
+ @opened_logdev = true
27
+ end
28
+
29
+ @logdev = Buffer.new(raw_log_device)
23
30
  end
24
31
 
25
32
  def buffered(transform: nil)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buffering_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Brough