tag_logger 1.0.2 → 1.0.3
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/README.md +7 -1
- data/lib/tag_logger.rb +14 -0
- data/lib/tag_logger/configuration.rb +5 -1
- data/lib/tag_logger/helper_logger.rb +3 -1
- data/lib/tag_logger/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a7649a198354c1d095fcef0635f1a9b622ca6918a1ae081e7dd2e01349cd0ce
|
4
|
+
data.tar.gz: ae8d092d882bc27d42063ee76828986196aa9fa0c5111850988a8dc215e3f361
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fbe43f76a3f87c48857e76f994bd8b5f41c29ca9a2ee851bd3b82ce66f21ba52e23d2f760ae95e233f6dc50584edf24c6e9ba127276de111d4d7fb65c286416
|
7
|
+
data.tar.gz: 89283740080c5eaba1a1cdaf6956b60e3c887468d264804e9d64a8eb12da14d98b0a365c8d8b16de5ba787896f03aed501f4f0d50cbdaa713fb98f1a820e5f8b
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ gem 'tag_logger'
|
|
11
11
|
|
12
12
|
Or install it yourself as:
|
13
13
|
```bash
|
14
|
-
$ gem install
|
14
|
+
$ gem install tag_logger
|
15
15
|
```
|
16
16
|
|
17
17
|
## Usage
|
@@ -19,6 +19,7 @@ First need to add configuration:
|
|
19
19
|
```ruby
|
20
20
|
TagLogger.configure do |config|
|
21
21
|
config.output_path = 'log/tag_logger.log'
|
22
|
+
config.filter_parameters = [:password]
|
22
23
|
end
|
23
24
|
```
|
24
25
|
|
@@ -33,6 +34,11 @@ class MyClass
|
|
33
34
|
|
34
35
|
# then log with levels: [:warn, :info, :debug, :fatal, :error]
|
35
36
|
log :info, 'Log information'
|
37
|
+
|
38
|
+
# if data has sensitive information, it must be sanitized
|
39
|
+
# INFO -- : [tag_name] Log information {:email=>"test@email.com", :password=>"[FILTERED]"}
|
40
|
+
data = {email: 'test@email.com', password: '123456'}
|
41
|
+
log :info, "Log information #{sanitize_log(data)}"
|
36
42
|
end
|
37
43
|
end
|
38
44
|
```
|
data/lib/tag_logger.rb
CHANGED
@@ -2,6 +2,8 @@ require 'tag_logger/helper_logger'
|
|
2
2
|
require 'tag_logger/configuration'
|
3
3
|
|
4
4
|
module TagLogger
|
5
|
+
FILTERED_TEXT = '[FILTERED]'.freeze
|
6
|
+
|
5
7
|
def tag_logger(*tags)
|
6
8
|
@tag_logger ||= HelperLogger.new(tags)
|
7
9
|
end
|
@@ -13,4 +15,16 @@ module TagLogger
|
|
13
15
|
@tag_logger.write_log(type, text)
|
14
16
|
end
|
15
17
|
end
|
18
|
+
|
19
|
+
def sanitize_log(data)
|
20
|
+
raise '`sanitize_log` only for Hash' unless data.is_a?(Hash)
|
21
|
+
|
22
|
+
filter_parameters = TagLogger.configuration.filter_parameters
|
23
|
+
filter_parameters.each do |key|
|
24
|
+
next if data[key].nil?
|
25
|
+
data[key] = FILTERED_TEXT
|
26
|
+
end
|
27
|
+
|
28
|
+
data
|
29
|
+
end
|
16
30
|
end
|
@@ -3,13 +3,15 @@ module TagLogger
|
|
3
3
|
attr_reader :tags, :logger
|
4
4
|
|
5
5
|
def initialize(tags)
|
6
|
+
raise 'TagLogger configuration is nil!' if TagLogger.configuration.nil?
|
7
|
+
|
6
8
|
if tags.empty?
|
7
9
|
raise 'Tags for `tag_logger` are empty!'
|
8
10
|
else
|
9
11
|
@tags = tags
|
10
12
|
end
|
11
13
|
|
12
|
-
output_path = TagLogger.configuration
|
14
|
+
output_path = TagLogger.configuration.output_path
|
13
15
|
if output_path.nil? || output_path.empty?
|
14
16
|
raise 'TagLogger configuration `output_path` is blank!'
|
15
17
|
else
|
data/lib/tag_logger/version.rb
CHANGED