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: de75773167a1f0005162fe5db12b9ea507226464ee89371f059b580e574fc85b
4
- data.tar.gz: 2c8445bd5ea5f6a47d5e64fa67e7f8a782376899f6f7cf523c08e94f551dc04f
3
+ metadata.gz: f523fd2c4e6ebb0bc2ef9cad19a5e0a0f48f29e4f27ff81b98bce11a848ed768
4
+ data.tar.gz: 0e2c98f92018bd6cdc91eb7b8e60fec03e6e34d28d4e4afdca7f54e09c853115
5
5
  SHA512:
6
- metadata.gz: dc73c23868b4235a384d2d2cec64c9a311cc65822a7f9ee9ee8bf782c7d6080e5c5660b8f7d348157a414f66faf20e8bcbf27157813759576a9e51d360bd43a5
7
- data.tar.gz: f0f84bdd18f26ab316ca5b1e3660867855b48a827c33d46cfb19ae6d96619e2da534bdfefd6416e49bbc7d697305c3abcb977a5b8e91eeee787c86ca89a5613c
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 = { request: { start_time: current_time, headers: extract_request_headers(request),
14
- body: extract_request_body(request) } }
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
- ctx[:response] = process_request(env)
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
- [ctx.dig(:response, :status), ctx.dig(:response, :headers), [ctx.dig(:response, :body)]]
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
- res = { body: '', status: 500, headers: {} }
44
- res[:status], res[:headers], response = @app.call(env)
45
- res[:body] = extract_body_safely(response || [])
46
- res
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}"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MinatoLogger
4
- VERSION = '0.2.17'
4
+ VERSION = '0.2.19'
5
5
  end
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.17
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-18 00:00:00.000000000 Z
11
+ date: 2026-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport