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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0913f102f2fa739214c54f742359f8771cc84212e9a8fcdd05eeff041b54a42d'
4
- data.tar.gz: 8bc325f2c2fb50c9e32f70abe8ba4d6ac8236597a8a3bb43c90179cdb516ea53
3
+ metadata.gz: 0563c893691556329c50c2b23f43ed5c10de92f9ff07c5e48da1eb0a72b4ced3
4
+ data.tar.gz: 59cb05505414611266e6ef7a12b104fc9757da96eab1383a6a0430b5875c9d57
5
5
  SHA512:
6
- metadata.gz: 5b3abad7e1a467c4bf63ee3aea78a790b04cd83799199c79bf91e6e1ae9617f6081cd83bcb09acafaee5e0ba579028ffb78a89f75b289bc0924fde6918eb92a7
7
- data.tar.gz: f5ea63ec3062cc32284a73b05f991ae5b05e1987cfa0c009b7d3d3629cacd9854e71e375f099e5f5b0cfc2421e7f38964b9b11e32d0abd43547b897837b8c676
6
+ metadata.gz: 5db3cc688afe4cf2884c9fd09d7841ee300a1fc6029c1e1e408b808d249772b7e41b5b669a93a511f4d45616d423e39f70cebbc241b7a2b53f67e3464f41d67b
7
+ data.tar.gz: 0c354c05a49da638b231a1535adcc2ac204351c248693a09347a2fcee4ee82d663fad30e2a2c2dc0908b1e605fc573d29588b380356a39e0fa970292bc2cf317
@@ -20,7 +20,7 @@ class RedactingLogger < Logger
20
20
  def initialize(
21
21
  logdev = $stdout,
22
22
  shift_age = 0,
23
- shift_size = 1048576,
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
- if message
44
- @redact_patterns.each do |pattern|
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RedactingLogger
4
4
  module Version
5
- VERSION = "1.0.0"
5
+ VERSION = "1.2.0"
6
6
  end
7
7
  end
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.0.0
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: 2023-11-22 00:00:00.000000000 Z
12
+ date: 2024-02-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: logger