logjam_agent 0.35.0 → 0.35.1
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.
- checksums.yaml +4 -4
- data/lib/logjam_agent/selective_logging.rb +5 -2
- data/lib/logjam_agent/version.rb +1 -1
- data/test/selective_logging_test.rb +15 -4
- 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: 3f6c65ee6f965cad2efa823e0c7bbdc2445bcc03b5eb5b925a80a3cf5750440b
|
4
|
+
data.tar.gz: cfc487c0f873c6eeb63e90c2680c31394eb112231a9a8f17273864bf26f1f5a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9465b7e6caf9e029b6d68112829a5720f2ee3d3ffc31b53cf3331b24497a9c46f971f3cd30b683feba7022bb56066797fb18b8fc35bd2f542510fd2a9d844eb3
|
7
|
+
data.tar.gz: f5217174aaf9331df102b3a367d6e1d755cc2a689c8e778c7b676d8469e9ba32159b3c06d8d4dccdad956811f55ec86e50e6af935be698ad9f7bb0179b22aff6
|
@@ -2,9 +2,12 @@ module LogjamAgent
|
|
2
2
|
module SelectiveLogging
|
3
3
|
extend self
|
4
4
|
|
5
|
+
mattr_accessor :selective_logging_enabled
|
6
|
+
self.selective_logging_enabled = true
|
7
|
+
|
5
8
|
def logjam_only
|
6
9
|
old_selector = logjam_log_selector
|
7
|
-
self.logjam_log_selector = :logjam_only
|
10
|
+
self.logjam_log_selector = :logjam_only if selective_logging_enabled
|
8
11
|
yield
|
9
12
|
ensure
|
10
13
|
self.logjam_log_selector = old_selector
|
@@ -12,7 +15,7 @@ module LogjamAgent
|
|
12
15
|
|
13
16
|
def logdevice_only
|
14
17
|
old_selector = logjam_log_selector
|
15
|
-
self.logjam_log_selector = :logdevice_only
|
18
|
+
self.logjam_log_selector = :logdevice_only if selective_logging_enabled
|
16
19
|
yield
|
17
20
|
ensure
|
18
21
|
self.logjam_log_selector = old_selector
|
data/lib/logjam_agent/version.rb
CHANGED
@@ -22,11 +22,12 @@ module LogjamAgent
|
|
22
22
|
|
23
23
|
def teardown
|
24
24
|
LogjamAgent.request = nil
|
25
|
+
LogjamAgent.selective_logging_enabled = true
|
25
26
|
end
|
26
27
|
|
27
28
|
def test_normal_logging_adds_line_to_request_and_logdevice
|
28
|
-
|
29
|
-
|
29
|
+
refute LogjamAgent.logjam_only?
|
30
|
+
refute LogjamAgent.logdevice_only?
|
30
31
|
@logger.info("normal")
|
31
32
|
assert_equal 1, @lines.size
|
32
33
|
assert_equal "normal", @lines.first.last
|
@@ -37,7 +38,7 @@ module LogjamAgent
|
|
37
38
|
def test_logjam_only_logging_adds_line_to_request_but_not_to_logdevice
|
38
39
|
LogjamAgent.logjam_only do
|
39
40
|
assert LogjamAgent.logjam_only?
|
40
|
-
|
41
|
+
refute LogjamAgent.logdevice_only?
|
41
42
|
@logger.info("logjam_only")
|
42
43
|
end
|
43
44
|
assert_equal 1, @lines.size
|
@@ -47,7 +48,7 @@ module LogjamAgent
|
|
47
48
|
|
48
49
|
def test_logdevice_only_logging_adds_line_to_logdevice_but_not_to_request
|
49
50
|
LogjamAgent.logdevice_only do
|
50
|
-
|
51
|
+
refute LogjamAgent.logjam_only?
|
51
52
|
assert LogjamAgent.logdevice_only?
|
52
53
|
@logger.info("logdevice_only")
|
53
54
|
end
|
@@ -55,5 +56,15 @@ module LogjamAgent
|
|
55
56
|
assert_equal 1, @device.lines.size
|
56
57
|
assert_match(/logdevice_only\n/, @device.lines.first)
|
57
58
|
end
|
59
|
+
|
60
|
+
def test_select_logging_can_be_globally_disabled
|
61
|
+
LogjamAgent.selective_logging_enabled = false
|
62
|
+
LogjamAgent.logdevice_only do
|
63
|
+
refute LogjamAgent.logdevice_only?
|
64
|
+
end
|
65
|
+
LogjamAgent.logjam_only do
|
66
|
+
refute LogjamAgent.logjam_only?
|
67
|
+
end
|
68
|
+
end
|
58
69
|
end
|
59
70
|
end
|