redacting-logger 1.0.0 → 1.1.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 +15 -3
- 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: d88bd6e2d2e1c5fc186f05de1c0edb096d69399c6cb341eebfee809e2e46ab05
|
4
|
+
data.tar.gz: af491b9b0ceb4a9d4800fdd102ae1560c90f4d4eb107dd5e3f6b82da0a03627a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1361b56a1c97dac3f910ebbbcb65652caea545bd2178cc12b61ae8725e0c99e4d06a3d6114c94349e1292adc795eb7802127255ffeaaafac8146ea866f8e3804
|
7
|
+
data.tar.gz: 282b6cb2221ecfa793acee8232da60f0e70c0c9c396889f2dd725b37cd9cb1e7bb67a0159f64c40ada9748b67f849e8ba42aaaa7853fc4907d39df8c588c9ab5
|
data/lib/redacting_logger.rb
CHANGED
@@ -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
|
45
47
|
message = message.to_s.gsub(pattern, @redacted_msg)
|
48
|
+
|
49
|
+
when Array
|
50
|
+
message = message.map do |m|
|
51
|
+
m = m.to_s.gsub(pattern, @redacted_msg)
|
52
|
+
end
|
53
|
+
|
54
|
+
when Hash
|
55
|
+
message = message.map do |k, v|
|
56
|
+
[k, v.to_s.gsub(pattern, @redacted_msg)]
|
57
|
+
end.to_h
|
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.1.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: 2023-
|
12
|
+
date: 2023-12-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: logger
|