logtail-rack 0.2.2 → 0.2.3
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 +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43f0b7693831d0097e1496ba79258afc7b8b7cda69d805fa99248cbc79812181
|
4
|
+
data.tar.gz: 23bdde6dc4a16420b3f8604edc3266775b248e2a51177be01c64a314577612d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9dc63f41ea21c4f31360608d82ec1cbf6652cac1774a28695a845a36858a95215ee24d49696278f07267266922659559cee8790a85767e64cd143e833232950
|
7
|
+
data.tar.gz: c1faf9719cac776039dac04d3acc9b91b9520f9f7983a4db242344e9f66cfedd37feb0bfe8b6575185b883918e45b37eaf76a61708f364dd627a8805349f6989
|
@@ -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:
|
15
|
-
method: request.request_method
|
15
|
+
host: Util::Encoding.force_utf8_encoding(request),
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Logtail
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logtail
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
- !ruby/object:Gem::Version
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
|
-
rubygems_version: 3.3.
|
139
|
+
rubygems_version: 3.3.3
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Logtail integration for Rack
|