pliny 0.25.0 → 0.25.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/pliny/log.rb +12 -0
- data/lib/pliny/version.rb +1 -1
- data/spec/log_spec.rb +36 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 405803fe2e1fc9197737c8dc017c122dbfa55c6f
|
4
|
+
data.tar.gz: 592d0ea8437b24db20277fc45cd3109c48e635b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd6828d0b03e015ee3eb695989538fa88630d43926ee6b9bc8f9d328c9029e38e28acff1e0780e20c8d5456d7238ed5520d1e5e7ee9fb1e5a4e12b33f4ff6de4
|
7
|
+
data.tar.gz: f31990df1e2486b1dcccf4ce0514ccc8f3d1be3a559707007b5b38d9667ec9cf49dd86ead2eba8cb4874b20955e1626054128e8149d33627c424af92350770f2
|
data/lib/pliny/log.rb
CHANGED
@@ -72,6 +72,17 @@ module Pliny
|
|
72
72
|
@stderr
|
73
73
|
end
|
74
74
|
|
75
|
+
def log_scrubber=(scrubber)
|
76
|
+
if scrubber && !scrubber.respond_to?(:call)
|
77
|
+
raise(ArgumentError, "Must respond to 'call'")
|
78
|
+
end
|
79
|
+
@scrubber = scrubber
|
80
|
+
end
|
81
|
+
|
82
|
+
def log_scrubber
|
83
|
+
@scrubber
|
84
|
+
end
|
85
|
+
|
75
86
|
private
|
76
87
|
|
77
88
|
def merge_log_contexts(data)
|
@@ -92,6 +103,7 @@ module Pliny
|
|
92
103
|
|
93
104
|
def log_to_stream(stream, data, &block)
|
94
105
|
unless block
|
106
|
+
data = log_scrubber.call(data) if log_scrubber
|
95
107
|
str = unparse(data)
|
96
108
|
stream.print(str + "\n")
|
97
109
|
else
|
data/lib/pliny/version.rb
CHANGED
data/spec/log_spec.rb
CHANGED
@@ -94,4 +94,40 @@ describe Pliny::Log do
|
|
94
94
|
expect(@io).to receive(:print).with("app=pliny exception class=RuntimeError message=RuntimeError exception_id=#{e.object_id}\n")
|
95
95
|
Pliny.log_exception(e)
|
96
96
|
end
|
97
|
+
|
98
|
+
describe "scrubbing" do
|
99
|
+
|
100
|
+
it "allows a Proc to be assigned as a log scrubber" do
|
101
|
+
Pliny.log_scrubber = -> (hash) { hash }
|
102
|
+
|
103
|
+
begin
|
104
|
+
Pliny.log_scrubber = Object.new
|
105
|
+
fail
|
106
|
+
rescue ArgumentError; end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "when a scrubber is present" do
|
110
|
+
before do
|
111
|
+
Pliny.log_scrubber = -> (hash) {
|
112
|
+
Hash.new.tap do |h|
|
113
|
+
hash.keys.each do |k|
|
114
|
+
h[k] = "*SCRUBBED*"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
}
|
118
|
+
end
|
119
|
+
|
120
|
+
after do
|
121
|
+
Pliny.log_scrubber = nil
|
122
|
+
end
|
123
|
+
|
124
|
+
it "scrubs the log when a scrubber is present" do
|
125
|
+
Pliny::RequestStore.store[:log_context] = { app: "pliny" }
|
126
|
+
|
127
|
+
expect(@io).to receive(:print).with("app=*SCRUBBED* foo=*SCRUBBED*\n")
|
128
|
+
|
129
|
+
Pliny.log(foo: "bar")
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
97
133
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pliny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.25.
|
4
|
+
version: 0.25.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandur Leach
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-04-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|