pier_logging 0.2.4 → 0.2.5
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/lib/pier_logging/request_logger.rb +27 -4
- 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: 5b2a1b9430577ae2c662d051aa5e305f33aeff05655333e0112a73386beab712
|
4
|
+
data.tar.gz: b1cb0e6cb96dde62fac3c7ae240e3f56aa14df4df416929eb889b68df4a09ae3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ea2ebdf2a038bd3c0b9b76f0409c0e3abf05eab7b00d5934c9bcf7b461e2bee3a35af07788a62d87cf892f333141ae5658348237effb7d171c1feddd511826c
|
7
|
+
data.tar.gz: d2aefc5a1d51a288e541d80cefc0caf3f9794726b8860131cdfc320eeba0ea0deac035097de74515ddb9639d42d76b080e6850d1d610b83c11e1e05451b699cd
|
@@ -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,6 +56,7 @@ module PierLogging
|
|
56
56
|
request: {
|
57
57
|
headers: request_headers,
|
58
58
|
href: request.url,
|
59
|
+
query_string: request.query_string,
|
59
60
|
body: parse_body(request.body)
|
60
61
|
},
|
61
62
|
response: {
|
@@ -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.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mauricio Banduk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ougai
|