pliny 0.25.0 → 0.25.1

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: fc58fa1c7528a90b019d6f7d01dcb733909c918d
4
- data.tar.gz: ed596145f95be0ff622f9cdcf2e6a5448a96a56e
3
+ metadata.gz: 405803fe2e1fc9197737c8dc017c122dbfa55c6f
4
+ data.tar.gz: 592d0ea8437b24db20277fc45cd3109c48e635b2
5
5
  SHA512:
6
- metadata.gz: 300c529e268a5e168dd015a42d3a1a68b3fceaf6359c47ca8288aa6e08cfcf222f029a0cb0f6541c160ad000951ebb607144c4191eecaa981b75fbbe75cd2679
7
- data.tar.gz: ad0e7f83fdd78ccd9c97c2fcdf296b17c842874cf9e372e592a666072b0361cf9a1e4a1aebdda921130115b5420e03623ea472ebcb24946ffafd4ed17a9c33d8
6
+ metadata.gz: cd6828d0b03e015ee3eb695989538fa88630d43926ee6b9bc8f9d328c9029e38e28acff1e0780e20c8d5456d7238ed5520d1e5e7ee9fb1e5a4e12b33f4ff6de4
7
+ data.tar.gz: f31990df1e2486b1dcccf4ce0514ccc8f3d1be3a559707007b5b38d9667ec9cf49dd86ead2eba8cb4874b20955e1626054128e8149d33627c424af92350770f2
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Pliny
2
- VERSION = "0.25.0"
2
+ VERSION = "0.25.1"
3
3
  end
@@ -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.0
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-03-24 00:00:00.000000000 Z
12
+ date: 2017-04-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport