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 +4 -4
- data/lib/buffering_logger/logger.rb +11 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fa7fd977ce2384f69fe8c43f5ec0a9b8a65d49f
|
4
|
+
data.tar.gz: 304a6a02b266ff01c9be3cdcbd14f56bcec533ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
21
|
-
|
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)
|