pier_logging 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +58 -58
- data/lib/pier_logging/logger.rb +1 -1
- data/lib/pier_logging/request_logger.rb +30 -7
- 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: 002c7af8b57dee3c6d7701bb5c297a01f605d5d9c045dedcd03f2293f521242e
|
4
|
+
data.tar.gz: d8fb099b212e46ec4d76a3933719517c2caca8820bec1d8d86e6723055043587
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e83c1d6ea35adb4429c7f40e83fb617ee9979fee0cea5f675982af661ca7b974ba924f513ab04573236d44cafd5729ce6e64dfecd51097c8a5970de0e4b46a38
|
7
|
+
data.tar.gz: 95fb36b857acb6f66ae83da3abfad7736b11d08c219c904b82c5b6c912e0b46d75c66ee982dd579c85e3894f3c4580a49f7cff2e07c389c2140bd8baec6575de
|
data/Gemfile.lock
CHANGED
@@ -10,56 +10,56 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
actioncable (6.0.3.
|
14
|
-
actionpack (= 6.0.3.
|
13
|
+
actioncable (6.0.3.3)
|
14
|
+
actionpack (= 6.0.3.3)
|
15
15
|
nio4r (~> 2.0)
|
16
16
|
websocket-driver (>= 0.6.1)
|
17
|
-
actionmailbox (6.0.3.
|
18
|
-
actionpack (= 6.0.3.
|
19
|
-
activejob (= 6.0.3.
|
20
|
-
activerecord (= 6.0.3.
|
21
|
-
activestorage (= 6.0.3.
|
22
|
-
activesupport (= 6.0.3.
|
17
|
+
actionmailbox (6.0.3.3)
|
18
|
+
actionpack (= 6.0.3.3)
|
19
|
+
activejob (= 6.0.3.3)
|
20
|
+
activerecord (= 6.0.3.3)
|
21
|
+
activestorage (= 6.0.3.3)
|
22
|
+
activesupport (= 6.0.3.3)
|
23
23
|
mail (>= 2.7.1)
|
24
|
-
actionmailer (6.0.3.
|
25
|
-
actionpack (= 6.0.3.
|
26
|
-
actionview (= 6.0.3.
|
27
|
-
activejob (= 6.0.3.
|
24
|
+
actionmailer (6.0.3.3)
|
25
|
+
actionpack (= 6.0.3.3)
|
26
|
+
actionview (= 6.0.3.3)
|
27
|
+
activejob (= 6.0.3.3)
|
28
28
|
mail (~> 2.5, >= 2.5.4)
|
29
29
|
rails-dom-testing (~> 2.0)
|
30
|
-
actionpack (6.0.3.
|
31
|
-
actionview (= 6.0.3.
|
32
|
-
activesupport (= 6.0.3.
|
30
|
+
actionpack (6.0.3.3)
|
31
|
+
actionview (= 6.0.3.3)
|
32
|
+
activesupport (= 6.0.3.3)
|
33
33
|
rack (~> 2.0, >= 2.0.8)
|
34
34
|
rack-test (>= 0.6.3)
|
35
35
|
rails-dom-testing (~> 2.0)
|
36
36
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
37
|
-
actiontext (6.0.3.
|
38
|
-
actionpack (= 6.0.3.
|
39
|
-
activerecord (= 6.0.3.
|
40
|
-
activestorage (= 6.0.3.
|
41
|
-
activesupport (= 6.0.3.
|
37
|
+
actiontext (6.0.3.3)
|
38
|
+
actionpack (= 6.0.3.3)
|
39
|
+
activerecord (= 6.0.3.3)
|
40
|
+
activestorage (= 6.0.3.3)
|
41
|
+
activesupport (= 6.0.3.3)
|
42
42
|
nokogiri (>= 1.8.5)
|
43
|
-
actionview (6.0.3.
|
44
|
-
activesupport (= 6.0.3.
|
43
|
+
actionview (6.0.3.3)
|
44
|
+
activesupport (= 6.0.3.3)
|
45
45
|
builder (~> 3.1)
|
46
46
|
erubi (~> 1.4)
|
47
47
|
rails-dom-testing (~> 2.0)
|
48
48
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
49
|
-
activejob (6.0.3.
|
50
|
-
activesupport (= 6.0.3.
|
49
|
+
activejob (6.0.3.3)
|
50
|
+
activesupport (= 6.0.3.3)
|
51
51
|
globalid (>= 0.3.6)
|
52
|
-
activemodel (6.0.3.
|
53
|
-
activesupport (= 6.0.3.
|
54
|
-
activerecord (6.0.3.
|
55
|
-
activemodel (= 6.0.3.
|
56
|
-
activesupport (= 6.0.3.
|
57
|
-
activestorage (6.0.3.
|
58
|
-
actionpack (= 6.0.3.
|
59
|
-
activejob (= 6.0.3.
|
60
|
-
activerecord (= 6.0.3.
|
52
|
+
activemodel (6.0.3.3)
|
53
|
+
activesupport (= 6.0.3.3)
|
54
|
+
activerecord (6.0.3.3)
|
55
|
+
activemodel (= 6.0.3.3)
|
56
|
+
activesupport (= 6.0.3.3)
|
57
|
+
activestorage (6.0.3.3)
|
58
|
+
actionpack (= 6.0.3.3)
|
59
|
+
activejob (= 6.0.3.3)
|
60
|
+
activerecord (= 6.0.3.3)
|
61
61
|
marcel (~> 0.3.1)
|
62
|
-
activesupport (6.0.3.
|
62
|
+
activesupport (6.0.3.3)
|
63
63
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
64
64
|
i18n (>= 0.7, < 2)
|
65
65
|
minitest (~> 5.1)
|
@@ -68,15 +68,15 @@ GEM
|
|
68
68
|
awesome_print (1.8.0)
|
69
69
|
builder (3.2.4)
|
70
70
|
byebug (11.1.3)
|
71
|
-
concurrent-ruby (1.1.
|
71
|
+
concurrent-ruby (1.1.7)
|
72
72
|
crass (1.0.6)
|
73
73
|
erubi (1.9.0)
|
74
74
|
facets (3.1.0)
|
75
75
|
globalid (0.4.2)
|
76
76
|
activesupport (>= 4.2.0)
|
77
|
-
i18n (1.8.
|
77
|
+
i18n (1.8.5)
|
78
78
|
concurrent-ruby (~> 1.0)
|
79
|
-
loofah (2.
|
79
|
+
loofah (2.7.0)
|
80
80
|
crass (~> 1.0.2)
|
81
81
|
nokogiri (>= 1.5.9)
|
82
82
|
mail (2.7.1)
|
@@ -88,8 +88,8 @@ GEM
|
|
88
88
|
mini_mime (1.0.2)
|
89
89
|
mini_portile2 (2.4.0)
|
90
90
|
minitest (5.14.1)
|
91
|
-
nio4r (2.5.
|
92
|
-
nokogiri (1.10.
|
91
|
+
nio4r (2.5.4)
|
92
|
+
nokogiri (1.10.10)
|
93
93
|
mini_portile2 (~> 2.4.0)
|
94
94
|
oj (3.10.6)
|
95
95
|
ougai (1.8.5)
|
@@ -97,29 +97,29 @@ GEM
|
|
97
97
|
rack (2.2.3)
|
98
98
|
rack-test (1.1.0)
|
99
99
|
rack (>= 1.0, < 3)
|
100
|
-
rails (6.0.3.
|
101
|
-
actioncable (= 6.0.3.
|
102
|
-
actionmailbox (= 6.0.3.
|
103
|
-
actionmailer (= 6.0.3.
|
104
|
-
actionpack (= 6.0.3.
|
105
|
-
actiontext (= 6.0.3.
|
106
|
-
actionview (= 6.0.3.
|
107
|
-
activejob (= 6.0.3.
|
108
|
-
activemodel (= 6.0.3.
|
109
|
-
activerecord (= 6.0.3.
|
110
|
-
activestorage (= 6.0.3.
|
111
|
-
activesupport (= 6.0.3.
|
100
|
+
rails (6.0.3.3)
|
101
|
+
actioncable (= 6.0.3.3)
|
102
|
+
actionmailbox (= 6.0.3.3)
|
103
|
+
actionmailer (= 6.0.3.3)
|
104
|
+
actionpack (= 6.0.3.3)
|
105
|
+
actiontext (= 6.0.3.3)
|
106
|
+
actionview (= 6.0.3.3)
|
107
|
+
activejob (= 6.0.3.3)
|
108
|
+
activemodel (= 6.0.3.3)
|
109
|
+
activerecord (= 6.0.3.3)
|
110
|
+
activestorage (= 6.0.3.3)
|
111
|
+
activesupport (= 6.0.3.3)
|
112
112
|
bundler (>= 1.3.0)
|
113
|
-
railties (= 6.0.3.
|
113
|
+
railties (= 6.0.3.3)
|
114
114
|
sprockets-rails (>= 2.0.0)
|
115
115
|
rails-dom-testing (2.0.3)
|
116
116
|
activesupport (>= 4.2.0)
|
117
117
|
nokogiri (>= 1.6)
|
118
118
|
rails-html-sanitizer (1.3.0)
|
119
119
|
loofah (~> 2.3)
|
120
|
-
railties (6.0.3.
|
121
|
-
actionpack (= 6.0.3.
|
122
|
-
activesupport (= 6.0.3.
|
120
|
+
railties (6.0.3.3)
|
121
|
+
actionpack (= 6.0.3.3)
|
122
|
+
activesupport (= 6.0.3.3)
|
123
123
|
method_source
|
124
124
|
rake (>= 0.8.7)
|
125
125
|
thor (>= 0.20.3, < 2.0)
|
@@ -127,7 +127,7 @@ GEM
|
|
127
127
|
sprockets (4.0.2)
|
128
128
|
concurrent-ruby (~> 1.0)
|
129
129
|
rack (> 1, < 3)
|
130
|
-
sprockets-rails (3.2.
|
130
|
+
sprockets-rails (3.2.2)
|
131
131
|
actionpack (>= 4.0)
|
132
132
|
activesupport (>= 4.0)
|
133
133
|
sprockets (>= 3.0.0)
|
@@ -135,10 +135,10 @@ GEM
|
|
135
135
|
thread_safe (0.3.6)
|
136
136
|
tzinfo (1.2.7)
|
137
137
|
thread_safe (~> 0.1)
|
138
|
-
websocket-driver (0.7.
|
138
|
+
websocket-driver (0.7.3)
|
139
139
|
websocket-extensions (>= 0.1.0)
|
140
140
|
websocket-extensions (0.1.5)
|
141
|
-
zeitwerk (2.
|
141
|
+
zeitwerk (2.4.0)
|
142
142
|
|
143
143
|
PLATFORMS
|
144
144
|
ruby
|
data/lib/pier_logging/logger.rb
CHANGED
@@ -44,19 +44,20 @@ 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,
|
51
51
|
context: {
|
52
52
|
user: get_user_info_from_headers(request_headers),
|
53
53
|
request_id: env['action_dispatch.request_id'],
|
54
|
-
correlation_id: get_correlation_id(env,
|
54
|
+
correlation_id: get_correlation_id(env, request_headers)
|
55
55
|
},
|
56
56
|
request: {
|
57
57
|
headers: request_headers,
|
58
58
|
href: request.url,
|
59
|
-
|
59
|
+
query_string: request.query_string,
|
60
|
+
body: parse_body(request.body)
|
60
61
|
},
|
61
62
|
response: {
|
62
63
|
status: status,
|
@@ -77,7 +78,7 @@ 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
|
@@ -103,7 +104,7 @@ module PierLogging
|
|
103
104
|
end
|
104
105
|
|
105
106
|
def get_correlation_id(env, headers)
|
106
|
-
PierLogging.request_logger_configuration.correlation_id_getter(env, headers) || headers['X-CORRELATION-ID']
|
107
|
+
PierLogging.request_logger_configuration.correlation_id_getter.call(env, headers) || headers['X-CORRELATION-ID']
|
107
108
|
end
|
108
109
|
|
109
110
|
def parse_body(body)
|
@@ -119,13 +120,35 @@ module PierLogging
|
|
119
120
|
body
|
120
121
|
end
|
121
122
|
|
123
|
+
def redact_object(obj, replace_keys = REDACT_REPLACE_KEYS, replace_by = REDACT_REPLACE_BY)
|
124
|
+
if obj === Array
|
125
|
+
redact_array(obj, replace_keys, replace_by)
|
126
|
+
elsif obj === Hash
|
127
|
+
redact_hash(obj, replace_keys, replace_by)
|
128
|
+
elsif obj.respond_to?(:to_hash)
|
129
|
+
redact_hash(obj.to_hash, replace_keys, replace_by)
|
130
|
+
else
|
131
|
+
obj
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def redact_array(arr, replace_keys = REDACT_REPLACE_KEYS, replace_by = REDACT_REPLACE_BY)
|
136
|
+
raise StandardError, 'Could not redact_array for non-array objects' unless arr.is_a? Array
|
137
|
+
arr.map { |el| redact_object(el, replace_keys, replace_by) }
|
138
|
+
end
|
139
|
+
|
122
140
|
def redact_hash(hash, replace_keys = REDACT_REPLACE_KEYS, replace_by = REDACT_REPLACE_BY)
|
123
|
-
hash
|
141
|
+
raise StandardError, 'Could not redact_hash for non-hash objects' unless hash.is_a? Hash
|
142
|
+
hash.traverse do |k,v|
|
124
143
|
should_redact = replace_keys.any?{ |regex| k =~regex }
|
125
144
|
if (should_redact)
|
126
145
|
[k, replace_by]
|
127
146
|
else
|
128
|
-
|
147
|
+
case v
|
148
|
+
when Array then [k, redact_array(v, replace_keys, replace_by)]
|
149
|
+
else
|
150
|
+
[k, v]
|
151
|
+
end
|
129
152
|
end
|
130
153
|
end
|
131
154
|
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.0
|
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-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ougai
|