pier_logging 0.2.4 → 0.3.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/Gemfile.lock +86 -83
- data/lib/pier_logging.rb +17 -2
- data/lib/pier_logging/logger.rb +1 -1
- data/lib/pier_logging/request_logger.rb +38 -6
- data/lib/pier_logging/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: a55ccf237c0b0f40cdc5a97c3b1409112de8343a8b1070f1b70d814ef4ed4dad
|
|
4
|
+
data.tar.gz: acd0969b17612d4f42d1c8229699c5176e2aa8ebfdf13a5fd8c07b64b94602d3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 56f1b5ca14007773f0604a3bf8720f81f5950892120e260a9a7c6a9231680edf4ece11c5702714e29a07ccae6c9490d8b406a992c78af8e6c1e85a887fa05deb
|
|
7
|
+
data.tar.gz: 79c17490ba3109bdbce3a06dd8fa45f92b6537a350e274273d5856208b99f878e9d085d4d194f7c8b62490af5b051b568d1a9eb74552993bb55c0962815a92d0
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
pier_logging (0.1
|
|
4
|
+
pier_logging (0.3.1)
|
|
5
5
|
awesome_print
|
|
6
6
|
facets
|
|
7
7
|
ougai
|
|
@@ -10,135 +10,138 @@ PATH
|
|
|
10
10
|
GEM
|
|
11
11
|
remote: https://rubygems.org/
|
|
12
12
|
specs:
|
|
13
|
-
actioncable (6.
|
|
14
|
-
actionpack (= 6.
|
|
13
|
+
actioncable (6.1.3.1)
|
|
14
|
+
actionpack (= 6.1.3.1)
|
|
15
|
+
activesupport (= 6.1.3.1)
|
|
15
16
|
nio4r (~> 2.0)
|
|
16
17
|
websocket-driver (>= 0.6.1)
|
|
17
|
-
actionmailbox (6.
|
|
18
|
-
actionpack (= 6.
|
|
19
|
-
activejob (= 6.
|
|
20
|
-
activerecord (= 6.
|
|
21
|
-
activestorage (= 6.
|
|
22
|
-
activesupport (= 6.
|
|
18
|
+
actionmailbox (6.1.3.1)
|
|
19
|
+
actionpack (= 6.1.3.1)
|
|
20
|
+
activejob (= 6.1.3.1)
|
|
21
|
+
activerecord (= 6.1.3.1)
|
|
22
|
+
activestorage (= 6.1.3.1)
|
|
23
|
+
activesupport (= 6.1.3.1)
|
|
23
24
|
mail (>= 2.7.1)
|
|
24
|
-
actionmailer (6.
|
|
25
|
-
actionpack (= 6.
|
|
26
|
-
actionview (= 6.
|
|
27
|
-
activejob (= 6.
|
|
25
|
+
actionmailer (6.1.3.1)
|
|
26
|
+
actionpack (= 6.1.3.1)
|
|
27
|
+
actionview (= 6.1.3.1)
|
|
28
|
+
activejob (= 6.1.3.1)
|
|
29
|
+
activesupport (= 6.1.3.1)
|
|
28
30
|
mail (~> 2.5, >= 2.5.4)
|
|
29
31
|
rails-dom-testing (~> 2.0)
|
|
30
|
-
actionpack (6.
|
|
31
|
-
actionview (= 6.
|
|
32
|
-
activesupport (= 6.
|
|
33
|
-
rack (~> 2.0, >= 2.0.
|
|
32
|
+
actionpack (6.1.3.1)
|
|
33
|
+
actionview (= 6.1.3.1)
|
|
34
|
+
activesupport (= 6.1.3.1)
|
|
35
|
+
rack (~> 2.0, >= 2.0.9)
|
|
34
36
|
rack-test (>= 0.6.3)
|
|
35
37
|
rails-dom-testing (~> 2.0)
|
|
36
38
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
37
|
-
actiontext (6.
|
|
38
|
-
actionpack (= 6.
|
|
39
|
-
activerecord (= 6.
|
|
40
|
-
activestorage (= 6.
|
|
41
|
-
activesupport (= 6.
|
|
39
|
+
actiontext (6.1.3.1)
|
|
40
|
+
actionpack (= 6.1.3.1)
|
|
41
|
+
activerecord (= 6.1.3.1)
|
|
42
|
+
activestorage (= 6.1.3.1)
|
|
43
|
+
activesupport (= 6.1.3.1)
|
|
42
44
|
nokogiri (>= 1.8.5)
|
|
43
|
-
actionview (6.
|
|
44
|
-
activesupport (= 6.
|
|
45
|
+
actionview (6.1.3.1)
|
|
46
|
+
activesupport (= 6.1.3.1)
|
|
45
47
|
builder (~> 3.1)
|
|
46
48
|
erubi (~> 1.4)
|
|
47
49
|
rails-dom-testing (~> 2.0)
|
|
48
50
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
49
|
-
activejob (6.
|
|
50
|
-
activesupport (= 6.
|
|
51
|
+
activejob (6.1.3.1)
|
|
52
|
+
activesupport (= 6.1.3.1)
|
|
51
53
|
globalid (>= 0.3.6)
|
|
52
|
-
activemodel (6.
|
|
53
|
-
activesupport (= 6.
|
|
54
|
-
activerecord (6.
|
|
55
|
-
activemodel (= 6.
|
|
56
|
-
activesupport (= 6.
|
|
57
|
-
activestorage (6.
|
|
58
|
-
actionpack (= 6.
|
|
59
|
-
activejob (= 6.
|
|
60
|
-
activerecord (= 6.
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
activemodel (6.1.3.1)
|
|
55
|
+
activesupport (= 6.1.3.1)
|
|
56
|
+
activerecord (6.1.3.1)
|
|
57
|
+
activemodel (= 6.1.3.1)
|
|
58
|
+
activesupport (= 6.1.3.1)
|
|
59
|
+
activestorage (6.1.3.1)
|
|
60
|
+
actionpack (= 6.1.3.1)
|
|
61
|
+
activejob (= 6.1.3.1)
|
|
62
|
+
activerecord (= 6.1.3.1)
|
|
63
|
+
activesupport (= 6.1.3.1)
|
|
64
|
+
marcel (~> 1.0.0)
|
|
65
|
+
mini_mime (~> 1.0.2)
|
|
66
|
+
activesupport (6.1.3.1)
|
|
63
67
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
64
|
-
i18n (>=
|
|
65
|
-
minitest (
|
|
66
|
-
tzinfo (~>
|
|
67
|
-
zeitwerk (~> 2.
|
|
68
|
-
awesome_print (1.
|
|
68
|
+
i18n (>= 1.6, < 2)
|
|
69
|
+
minitest (>= 5.1)
|
|
70
|
+
tzinfo (~> 2.0)
|
|
71
|
+
zeitwerk (~> 2.3)
|
|
72
|
+
awesome_print (1.9.2)
|
|
69
73
|
builder (3.2.4)
|
|
70
74
|
byebug (11.1.3)
|
|
71
|
-
concurrent-ruby (1.1.
|
|
75
|
+
concurrent-ruby (1.1.8)
|
|
72
76
|
crass (1.0.6)
|
|
73
|
-
erubi (1.
|
|
77
|
+
erubi (1.10.0)
|
|
74
78
|
facets (3.1.0)
|
|
75
79
|
globalid (0.4.2)
|
|
76
80
|
activesupport (>= 4.2.0)
|
|
77
|
-
i18n (1.8.
|
|
81
|
+
i18n (1.8.10)
|
|
78
82
|
concurrent-ruby (~> 1.0)
|
|
79
|
-
loofah (2.
|
|
83
|
+
loofah (2.9.1)
|
|
80
84
|
crass (~> 1.0.2)
|
|
81
85
|
nokogiri (>= 1.5.9)
|
|
82
86
|
mail (2.7.1)
|
|
83
87
|
mini_mime (>= 0.1.1)
|
|
84
|
-
marcel (0.
|
|
85
|
-
mimemagic (~> 0.3.2)
|
|
88
|
+
marcel (1.0.1)
|
|
86
89
|
method_source (1.0.0)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
oj (3.
|
|
95
|
-
ougai (
|
|
90
|
+
mini_mime (1.0.3)
|
|
91
|
+
mini_portile2 (2.5.0)
|
|
92
|
+
minitest (5.14.4)
|
|
93
|
+
nio4r (2.5.7)
|
|
94
|
+
nokogiri (1.11.3)
|
|
95
|
+
mini_portile2 (~> 2.5.0)
|
|
96
|
+
racc (~> 1.4)
|
|
97
|
+
oj (3.11.3)
|
|
98
|
+
ougai (2.0.0)
|
|
96
99
|
oj (~> 3.10)
|
|
100
|
+
racc (1.5.2)
|
|
97
101
|
rack (2.2.3)
|
|
98
102
|
rack-test (1.1.0)
|
|
99
103
|
rack (>= 1.0, < 3)
|
|
100
|
-
rails (6.
|
|
101
|
-
actioncable (= 6.
|
|
102
|
-
actionmailbox (= 6.
|
|
103
|
-
actionmailer (= 6.
|
|
104
|
-
actionpack (= 6.
|
|
105
|
-
actiontext (= 6.
|
|
106
|
-
actionview (= 6.
|
|
107
|
-
activejob (= 6.
|
|
108
|
-
activemodel (= 6.
|
|
109
|
-
activerecord (= 6.
|
|
110
|
-
activestorage (= 6.
|
|
111
|
-
activesupport (= 6.
|
|
112
|
-
bundler (>= 1.
|
|
113
|
-
railties (= 6.
|
|
104
|
+
rails (6.1.3.1)
|
|
105
|
+
actioncable (= 6.1.3.1)
|
|
106
|
+
actionmailbox (= 6.1.3.1)
|
|
107
|
+
actionmailer (= 6.1.3.1)
|
|
108
|
+
actionpack (= 6.1.3.1)
|
|
109
|
+
actiontext (= 6.1.3.1)
|
|
110
|
+
actionview (= 6.1.3.1)
|
|
111
|
+
activejob (= 6.1.3.1)
|
|
112
|
+
activemodel (= 6.1.3.1)
|
|
113
|
+
activerecord (= 6.1.3.1)
|
|
114
|
+
activestorage (= 6.1.3.1)
|
|
115
|
+
activesupport (= 6.1.3.1)
|
|
116
|
+
bundler (>= 1.15.0)
|
|
117
|
+
railties (= 6.1.3.1)
|
|
114
118
|
sprockets-rails (>= 2.0.0)
|
|
115
119
|
rails-dom-testing (2.0.3)
|
|
116
120
|
activesupport (>= 4.2.0)
|
|
117
121
|
nokogiri (>= 1.6)
|
|
118
122
|
rails-html-sanitizer (1.3.0)
|
|
119
123
|
loofah (~> 2.3)
|
|
120
|
-
railties (6.
|
|
121
|
-
actionpack (= 6.
|
|
122
|
-
activesupport (= 6.
|
|
124
|
+
railties (6.1.3.1)
|
|
125
|
+
actionpack (= 6.1.3.1)
|
|
126
|
+
activesupport (= 6.1.3.1)
|
|
123
127
|
method_source
|
|
124
128
|
rake (>= 0.8.7)
|
|
125
|
-
thor (
|
|
126
|
-
rake (13.0.
|
|
129
|
+
thor (~> 1.0)
|
|
130
|
+
rake (13.0.3)
|
|
127
131
|
sprockets (4.0.2)
|
|
128
132
|
concurrent-ruby (~> 1.0)
|
|
129
133
|
rack (> 1, < 3)
|
|
130
|
-
sprockets-rails (3.2.
|
|
134
|
+
sprockets-rails (3.2.2)
|
|
131
135
|
actionpack (>= 4.0)
|
|
132
136
|
activesupport (>= 4.0)
|
|
133
137
|
sprockets (>= 3.0.0)
|
|
134
|
-
thor (1.0
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
websocket-driver (0.7.2)
|
|
138
|
+
thor (1.1.0)
|
|
139
|
+
tzinfo (2.0.4)
|
|
140
|
+
concurrent-ruby (~> 1.0)
|
|
141
|
+
websocket-driver (0.7.3)
|
|
139
142
|
websocket-extensions (>= 0.1.0)
|
|
140
143
|
websocket-extensions (0.1.5)
|
|
141
|
-
zeitwerk (2.
|
|
144
|
+
zeitwerk (2.4.2)
|
|
142
145
|
|
|
143
146
|
PLATFORMS
|
|
144
147
|
ruby
|
data/lib/pier_logging.rb
CHANGED
|
@@ -54,13 +54,15 @@ module PierLogging
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
class RequestLoggerConfiguration
|
|
57
|
-
attr_reader :enabled, :user_info_getter, :hide_response_body_for_paths,
|
|
58
|
-
:log_response, :hide_request_headers, :correlation_id_getter
|
|
57
|
+
attr_reader :enabled, :user_info_getter, :hide_request_body_for_paths, :hide_response_body_for_paths,
|
|
58
|
+
:log_request_body, :log_response, :hide_request_headers, :correlation_id_getter
|
|
59
59
|
|
|
60
60
|
def initialize
|
|
61
61
|
@user_info_getter = ->(_ = nil) { nil }
|
|
62
62
|
@enabled = false
|
|
63
|
+
@hide_request_body_for_paths = nil
|
|
63
64
|
@hide_response_body_for_paths = nil
|
|
65
|
+
@log_request_body = true
|
|
64
66
|
@log_response = true
|
|
65
67
|
@hide_request_headers = nil
|
|
66
68
|
@correlation_id_getter = ->(_ = nil, _ = nil) { nil }
|
|
@@ -71,11 +73,24 @@ module PierLogging
|
|
|
71
73
|
@user_info_getter = proc
|
|
72
74
|
end
|
|
73
75
|
|
|
76
|
+
def log_request_body=(log_request_body)
|
|
77
|
+
raise ArgumentError, "Config 'log_request_body' must be a 'boolean'" unless !!log_request_body == log_request_body
|
|
78
|
+
@log_request_body = log_request_body
|
|
79
|
+
end
|
|
80
|
+
|
|
74
81
|
def log_response=(log_response)
|
|
75
82
|
raise ArgumentError, "Config 'log_response' must be a 'boolean'" unless !!log_response == log_response
|
|
76
83
|
@log_response = log_response
|
|
77
84
|
end
|
|
78
85
|
|
|
86
|
+
def hide_request_body_for_paths=(hide_request_body_for_paths)
|
|
87
|
+
unless (hide_request_body_for_paths.is_a? Array) && (hide_request_body_for_paths.all?{|item| item.is_a? Regexp})
|
|
88
|
+
raise ArgumentError, "Config 'hide_request_body_for_paths' must be an 'Array of Regexps'"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
@hide_request_body_for_paths = hide_request_body_for_paths
|
|
92
|
+
end
|
|
93
|
+
|
|
79
94
|
def hide_response_body_for_paths=(hide_response_body_for_paths)
|
|
80
95
|
unless (hide_response_body_for_paths.is_a? Array) && (hide_response_body_for_paths.all?{|item| item.is_a? Regexp})
|
|
81
96
|
raise ArgumentError, "Config 'hide_response_body_for_paths' must be an 'Array of Regexps'"
|
data/lib/pier_logging/logger.rb
CHANGED
|
@@ -44,7 +44,7 @@ module PierLogging
|
|
|
44
44
|
env, status, type, body, starts_at, ends_at, _ = args
|
|
45
45
|
request = Rack::Request.new(env)
|
|
46
46
|
request_headers = get_request_headers_from_env(env)
|
|
47
|
-
logger.info
|
|
47
|
+
logger.info redact_object({
|
|
48
48
|
message: build_message_from_request(request),
|
|
49
49
|
type: 'http',
|
|
50
50
|
duration: ((ends_at - starts_at)*1000).to_i,
|
|
@@ -56,7 +56,8 @@ module PierLogging
|
|
|
56
56
|
request: {
|
|
57
57
|
headers: request_headers,
|
|
58
58
|
href: request.url,
|
|
59
|
-
|
|
59
|
+
query_string: request.query_string,
|
|
60
|
+
body: request_body(request.path, request.body)
|
|
60
61
|
},
|
|
61
62
|
response: {
|
|
62
63
|
status: status,
|
|
@@ -77,16 +78,25 @@ module PierLogging
|
|
|
77
78
|
headers = env.select { |k,v| k[0..4] == 'HTTP_'}.
|
|
78
79
|
transform_keys { |k| k[5..-1].split('_').join('-').upcase }
|
|
79
80
|
|
|
80
|
-
return
|
|
81
|
+
return redact_object(headers, hide_request_headers, nil) if hide_request_headers.present?
|
|
81
82
|
|
|
82
83
|
headers
|
|
83
84
|
end
|
|
84
85
|
|
|
86
|
+
def request_body(request_path, body)
|
|
87
|
+
return nil unless PierLogging.request_logger_configuration.log_request_body
|
|
88
|
+
|
|
89
|
+
hide_request_body_for_paths = PierLogging.request_logger_configuration.hide_request_body_for_paths
|
|
90
|
+
return nil if hide_request_body_for_paths&.any?{ |path|request_path =~ path }
|
|
91
|
+
|
|
92
|
+
parse_body(body)
|
|
93
|
+
end
|
|
94
|
+
|
|
85
95
|
def response_body(request_path, body)
|
|
86
96
|
return nil unless PierLogging.request_logger_configuration.log_response
|
|
87
97
|
|
|
88
98
|
hide_response_body_for_paths = PierLogging.request_logger_configuration.hide_response_body_for_paths
|
|
89
|
-
return nil if hide_response_body_for_paths
|
|
99
|
+
return nil if hide_response_body_for_paths&.any?{ |path|request_path =~ path }
|
|
90
100
|
|
|
91
101
|
parse_body(body)
|
|
92
102
|
end
|
|
@@ -119,13 +129,35 @@ module PierLogging
|
|
|
119
129
|
body
|
|
120
130
|
end
|
|
121
131
|
|
|
132
|
+
def redact_object(obj, replace_keys = REDACT_REPLACE_KEYS, replace_by = REDACT_REPLACE_BY)
|
|
133
|
+
if obj === Array
|
|
134
|
+
redact_array(obj, replace_keys, replace_by)
|
|
135
|
+
elsif obj === Hash
|
|
136
|
+
redact_hash(obj, replace_keys, replace_by)
|
|
137
|
+
elsif obj.respond_to?(:to_hash)
|
|
138
|
+
redact_hash(obj.to_hash, replace_keys, replace_by)
|
|
139
|
+
else
|
|
140
|
+
obj
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def redact_array(arr, replace_keys = REDACT_REPLACE_KEYS, replace_by = REDACT_REPLACE_BY)
|
|
145
|
+
raise StandardError, 'Could not redact_array for non-array objects' unless arr.is_a? Array
|
|
146
|
+
arr.map { |el| redact_object(el, replace_keys, replace_by) }
|
|
147
|
+
end
|
|
148
|
+
|
|
122
149
|
def redact_hash(hash, replace_keys = REDACT_REPLACE_KEYS, replace_by = REDACT_REPLACE_BY)
|
|
123
|
-
hash
|
|
150
|
+
raise StandardError, 'Could not redact_hash for non-hash objects' unless hash.is_a? Hash
|
|
151
|
+
hash.traverse do |k,v|
|
|
124
152
|
should_redact = replace_keys.any?{ |regex| k =~regex }
|
|
125
153
|
if (should_redact)
|
|
126
154
|
[k, replace_by]
|
|
127
155
|
else
|
|
128
|
-
|
|
156
|
+
case v
|
|
157
|
+
when Array then [k, redact_array(v, replace_keys, replace_by)]
|
|
158
|
+
else
|
|
159
|
+
[k, v]
|
|
160
|
+
end
|
|
129
161
|
end
|
|
130
162
|
end
|
|
131
163
|
end
|
data/lib/pier_logging/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pier_logging
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mauricio Banduk
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-04-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ougai
|