logtail-rack 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/logtail-rack/http_context.rb +4 -3
- data/lib/logtail-rack/http_events.rb +4 -11
- data/lib/logtail-rack/util/encoding.rb +4 -1
- data/lib/logtail-rack/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: fd113ab9b17ca26fa87eff47038f60d80eb83faf8e952272fdf50d78282cdb85
|
4
|
+
data.tar.gz: b10232307696b875ff0ed56fe3e2881e7d010362b2a8aa773a8cae4d40973f69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fda6074ed268d9674060dbd1b1356ad17872299956bcf4290b6748dc0ed247afac45a340e2e673ec5206bb81b9e55510b6a4295dae79dbb05a66b5195a79887a
|
7
|
+
data.tar.gz: 23028ed6c4bfcf5168556d37e73d79a3159b0565802dd35792720282722ca1de7be645795ecfc47a5f9899ee23ec19747fb0c7bcacb523244f94a6d4b0dfce3b
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "logtail/contexts/http"
|
2
2
|
require "logtail/current_context"
|
3
3
|
require "logtail-rack/middleware"
|
4
|
+
require "logtail-rack/util/encoding"
|
4
5
|
require "logtail-rack/util/request"
|
5
6
|
|
6
7
|
module Logtail
|
@@ -11,10 +12,10 @@ module Logtail
|
|
11
12
|
def call(env)
|
12
13
|
request = Util::Request.new(env)
|
13
14
|
context = Contexts::HTTP.new(
|
14
|
-
host: request.host
|
15
|
-
method: request.request_method
|
15
|
+
host: Util::Encoding.force_utf8_encoding(request.host),
|
16
|
+
method: Util::Encoding.force_utf8_encoding(request.request_method),
|
16
17
|
path: request.path,
|
17
|
-
remote_addr: request.ip
|
18
|
+
remote_addr: Util::Encoding.force_utf8_encoding(request.ip),
|
18
19
|
request_id: request.request_id
|
19
20
|
)
|
20
21
|
|
@@ -6,6 +6,7 @@ require "logtail/current_context"
|
|
6
6
|
require "logtail-rack/http_request"
|
7
7
|
require "logtail-rack/http_response"
|
8
8
|
require "logtail-rack/middleware"
|
9
|
+
require "logtail-rack/util/encoding"
|
9
10
|
|
10
11
|
module Logtail
|
11
12
|
module Integrations
|
@@ -179,13 +180,13 @@ module Logtail
|
|
179
180
|
body: event_body,
|
180
181
|
content_length: safe_to_i(request.content_length),
|
181
182
|
headers: filter_http_headers(request.headers),
|
182
|
-
host:
|
183
|
+
host: Util::Encoding.force_utf8_encoding(request.host),
|
183
184
|
method: request.request_method,
|
184
185
|
path: request.path,
|
185
186
|
port: request.port,
|
186
|
-
query_string:
|
187
|
+
query_string: Util::Encoding.force_utf8_encoding(request.query_string),
|
187
188
|
request_id: request.request_id,
|
188
|
-
scheme:
|
189
|
+
scheme: Util::Encoding.force_utf8_encoding(request.scheme),
|
189
190
|
)
|
190
191
|
|
191
192
|
{
|
@@ -277,14 +278,6 @@ module Logtail
|
|
277
278
|
def safe_to_i(val)
|
278
279
|
val.nil? ? nil : val.to_i
|
279
280
|
end
|
280
|
-
|
281
|
-
def force_encoding(value)
|
282
|
-
if value.respond_to?(:force_encoding)
|
283
|
-
value.dup.force_encoding('UTF-8')
|
284
|
-
else
|
285
|
-
value
|
286
|
-
end
|
287
|
-
end
|
288
281
|
end
|
289
282
|
end
|
290
283
|
end
|
@@ -3,7 +3,10 @@ module Logtail
|
|
3
3
|
class Encoding
|
4
4
|
def self.force_utf8_encoding(data)
|
5
5
|
if data.respond_to?(:force_encoding)
|
6
|
-
data.dup.force_encoding('UTF-8')
|
6
|
+
encoded_data = data.dup.force_encoding('UTF-8')
|
7
|
+
encoded_data = data.dup.force_encoding("ISO-8859-1").encode("UTF-8") unless encoded_data.valid_encoding?
|
8
|
+
encoded_data = data.dup.encode('UTF-8', invalid: :replace, undef: :replace) unless encoded_data.valid_encoding?
|
9
|
+
encoded_data
|
7
10
|
elsif data.respond_to?(:transform_values)
|
8
11
|
data.transform_values { |val| Logtail::Util::Encoding.force_utf8_encoding(val) }
|
9
12
|
else
|
data/lib/logtail-rack/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logtail-rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Logtail
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logtail
|