pier_logging 0.2.3 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +86 -83
- data/lib/pier_logging/logger.rb +1 -1
- data/lib/pier_logging/request_logger.rb +28 -5
- 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: f3b5d51eccb3353d9b1e898eb5c6f6d5d14dedcb183df51c7ed6300554e702f9
|
4
|
+
data.tar.gz: 55a389c152833b3b94889af6fecaddc73682d33a5b48ac495fdf414f7e8886fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1246e42cf2aa2632506cb52aa90159998582f80ed89dda9915834abbff04f726d84fcd819c99dcf9cc0a73d56db03ee0ba597ba29fafa547028ab3f52f75e1b5
|
7
|
+
data.tar.gz: a4d3294e81e52f535a08f8fe883efdcf93acc8f98d27e12c879290db862dcb748458adadb4e7541b5cafcded08e99b74a681d820106a8c7dc9567260124ea2b0
|
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/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: 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
|
@@ -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.2
|
4
|
+
version: 0.3.2
|
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
|