redacting-logger 1.0.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redacting_logger.rb +16 -4
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0563c893691556329c50c2b23f43ed5c10de92f9ff07c5e48da1eb0a72b4ced3
|
4
|
+
data.tar.gz: 59cb05505414611266e6ef7a12b104fc9757da96eab1383a6a0430b5875c9d57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5db3cc688afe4cf2884c9fd09d7841ee300a1fc6029c1e1e408b808d249772b7e41b5b669a93a511f4d45616d423e39f70cebbc241b7a2b53f67e3464f41d67b
|
7
|
+
data.tar.gz: 0c354c05a49da638b231a1535adcc2ac204351c248693a09347a2fcee4ee82d663fad30e2a2c2dc0908b1e605fc573d29588b380356a39e0fa970292bc2cf317
|
data/lib/redacting_logger.rb
CHANGED
@@ -20,7 +20,7 @@ class RedactingLogger < Logger
|
|
20
20
|
def initialize(
|
21
21
|
logdev = $stdout,
|
22
22
|
shift_age = 0,
|
23
|
-
shift_size =
|
23
|
+
shift_size = 1_048_576,
|
24
24
|
redact_patterns: [],
|
25
25
|
redacted_msg: "[REDACTED]",
|
26
26
|
use_default_patterns: true,
|
@@ -35,14 +35,26 @@ class RedactingLogger < Logger
|
|
35
35
|
# Adds a message to the log.
|
36
36
|
#
|
37
37
|
# @param severity [Integer] The severity level of the message.
|
38
|
-
# @param message [String] The message to log.
|
38
|
+
# @param message [String|Array|Hash] The message to log.
|
39
39
|
# @param progname [String] The name of the program.
|
40
40
|
def add(severity, message = nil, progname = nil)
|
41
41
|
message, progname = yield if block_given?
|
42
42
|
|
43
|
-
|
44
|
-
|
43
|
+
@redact_patterns.each do |pattern|
|
44
|
+
case message
|
45
|
+
|
46
|
+
when String, Symbol, Numeric
|
45
47
|
message = message.to_s.gsub(pattern, @redacted_msg)
|
48
|
+
|
49
|
+
when Array
|
50
|
+
message = message.map do |m|
|
51
|
+
m.to_s.gsub(pattern, @redacted_msg)
|
52
|
+
end
|
53
|
+
|
54
|
+
when Hash
|
55
|
+
message = message.transform_values do |v|
|
56
|
+
v.to_s.gsub(pattern, @redacted_msg)
|
57
|
+
end
|
46
58
|
end
|
47
59
|
end
|
48
60
|
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redacting-logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-02-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: logger
|