minato_logger 0.2.17 → 0.2.19
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f523fd2c4e6ebb0bc2ef9cad19a5e0a0f48f29e4f27ff81b98bce11a848ed768
|
|
4
|
+
data.tar.gz: 0e2c98f92018bd6cdc91eb7b8e60fec03e6e34d28d4e4afdca7f54e09c853115
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 113a8a0543e35113868f8dff23bcf942c5c5b089fab83eaeff0c3c422b1bec0ddeec9733e7f4aa119a9cf69715a015d05d18d5da1c95dc15bddc3e4f51284cee
|
|
7
|
+
data.tar.gz: 4269bfa90e60c7230767b517ec6dd4e3f31d4ac732953f3aeb2cfeab9914029d27b1804af37f8704b66ec9351aedcf1ba7a5c5f796239bc7f7f29685e673109b
|
|
@@ -10,14 +10,16 @@ module MinatoLogger
|
|
|
10
10
|
|
|
11
11
|
def call_app(request, env)
|
|
12
12
|
should_log = should_log?(request)
|
|
13
|
-
ctx = {
|
|
14
|
-
|
|
13
|
+
ctx = {}
|
|
14
|
+
ctx[:request] = build_request_context_base(request) if should_log
|
|
15
15
|
log_request(request, env, ctx) if should_log
|
|
16
16
|
handle = dispatch_request_event(request)
|
|
17
|
-
|
|
17
|
+
status, headers, rack_body, log_body = process_request(env)
|
|
18
|
+
ctx[:response] = { status: status, headers: headers, body: log_body } if should_log
|
|
18
19
|
log_response(request, env, ctx) if should_log
|
|
19
20
|
finish_request_instrumentation(handle, env['rails.rack_logger_tag_count'])
|
|
20
|
-
|
|
21
|
+
|
|
22
|
+
[status, headers, rack_body]
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
def compute_tags(request)
|
|
@@ -30,6 +32,11 @@ module MinatoLogger
|
|
|
30
32
|
end
|
|
31
33
|
end
|
|
32
34
|
|
|
35
|
+
def build_request_context_base(request)
|
|
36
|
+
{ start_time: current_time, headers: extract_request_headers(request),
|
|
37
|
+
body: extract_request_body(request) }
|
|
38
|
+
end
|
|
39
|
+
|
|
33
40
|
def should_log?(request)
|
|
34
41
|
blacklist = Rails.application.config.minato_logger.route_blacklist || []
|
|
35
42
|
blacklist.none? do |item|
|
|
@@ -40,10 +47,15 @@ module MinatoLogger
|
|
|
40
47
|
end
|
|
41
48
|
|
|
42
49
|
def process_request(env)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
status, headers, response = @app.call(env)
|
|
51
|
+
content_type = headers['Content-Type'].to_s
|
|
52
|
+
|
|
53
|
+
if content_type.include?('application/json') || content_type.include?('text/')
|
|
54
|
+
body_str = extract_body_safely(response || [])
|
|
55
|
+
[status, headers, [body_str], body_str]
|
|
56
|
+
else
|
|
57
|
+
[status, headers, response, "[Binary or Stream Response: #{content_type}]"]
|
|
58
|
+
end
|
|
47
59
|
end
|
|
48
60
|
|
|
49
61
|
def dispatch_request_event(request)
|
|
@@ -114,10 +126,12 @@ module MinatoLogger
|
|
|
114
126
|
|
|
115
127
|
def extract_request_body(request)
|
|
116
128
|
return nil unless request.body
|
|
129
|
+
return '[Multipart Form Data / File Upload]' if request.content_type.to_s.include?('multipart/form-data')
|
|
117
130
|
|
|
118
131
|
body = request.raw_post
|
|
119
132
|
return nil if body.blank?
|
|
120
133
|
|
|
134
|
+
request.body.rewind if request.body.respond_to?(:rewind)
|
|
121
135
|
safe_parse_json(body)
|
|
122
136
|
rescue StandardError => e
|
|
123
137
|
"Error reading request body: #{e}"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: minato_logger
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.19
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ferreri
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02-
|
|
11
|
+
date: 2026-02-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|