buffering_logger 2.0.6 → 3.0.0
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/buffer.rb +15 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f49590098cb33d87ab8d0114a978908743fe30357604b07dad8e11f5ec999fc2
|
4
|
+
data.tar.gz: fab5895b8c82b7b08f7b50229eb6f6672afe07ea0ee832982e2637230c7f2b5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e6e3304cacc56982a8c1348f8d6911013c6192230ed1e2b8fda53f668bdf76d526b206102877f1b33daa3e369a734f3d413d802f074f05e6e2a6e76f011c6fb
|
7
|
+
data.tar.gz: 3ab02da9c65ff13366f77f1b5935d5d4249357cc0110a71480c3041715f3b7d57454ac0de0009d4b49d1662445bc70bc18711a3e145901c4c1cdca5df12f8529
|
@@ -11,15 +11,15 @@ class BufferingLogger::Buffer
|
|
11
11
|
# buffers during the block and then flushes.
|
12
12
|
# returns the value of the block.
|
13
13
|
def buffered(transform: nil)
|
14
|
-
|
14
|
+
self.buffering = true
|
15
15
|
yield
|
16
16
|
ensure
|
17
|
-
|
17
|
+
self.buffering = false
|
18
18
|
flush(transform: transform)
|
19
19
|
end
|
20
20
|
|
21
21
|
def write(msg)
|
22
|
-
if
|
22
|
+
if buffering
|
23
23
|
buffer.write(msg)
|
24
24
|
else
|
25
25
|
logdev_write(msg)
|
@@ -62,4 +62,16 @@ class BufferingLogger::Buffer
|
|
62
62
|
"buffering_logger_#{object_id}_buffer"
|
63
63
|
end
|
64
64
|
|
65
|
+
def buffering
|
66
|
+
Thread.current[buffering_id]
|
67
|
+
end
|
68
|
+
|
69
|
+
def buffering=(val)
|
70
|
+
Thread.current[buffering_id] = val
|
71
|
+
end
|
72
|
+
|
73
|
+
def buffering_id
|
74
|
+
"buffering_logger_#{object_id}_is_buffering"
|
75
|
+
end
|
76
|
+
|
65
77
|
end
|