hubrise_initializer 0.2.5 → 0.2.6
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/hubrise_initializer/lograge.rb +12 -7
- data/lib/hubrise_initializer/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: 66f2a6620893b4928f509dceaf4693f00d44e8f7372670d0bb29cb6aae7f88dc
|
4
|
+
data.tar.gz: 0b740151154568d2b42a49f0e508a333b164079a75fbca4513e62c1b4e78d5ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38773d3d4ee8cb07554786a4db4cf84625a8d5106b34295cc11914401e8110347217b564d60acb5a817e66e6a3e04fd1fc62f31a54c49dcfd53ba139f24cca48
|
7
|
+
data.tar.gz: 5e37b26c88b4ae570aa938ff59deedbdffc3e7df0862dacab9ec9ee8cda884f900d6b3d0e40d6847f4ca2b5f4535f7a527a0fdf11a61395614d43f4cdc7fc531
|
@@ -17,9 +17,9 @@ class HubriseInitializer
|
|
17
17
|
if ENV['RAILS_LOGRAGE_QUERY'] == 'true'
|
18
18
|
{
|
19
19
|
request_headers: process_request_headers(request).to_s,
|
20
|
-
request_body: truncate_body(switch_to_utf8(request.raw_post
|
20
|
+
request_body: truncate_body(switch_to_utf8(request.raw_post)),
|
21
21
|
response_headers: response.headers.to_h.to_s,
|
22
|
-
response_body: truncate_body(response.body)
|
22
|
+
response_body: truncate_body(switch_to_utf8(response.body))
|
23
23
|
}
|
24
24
|
else
|
25
25
|
{}
|
@@ -31,12 +31,17 @@ class HubriseInitializer
|
|
31
31
|
|
32
32
|
TRUNCATED_BODY_MAX_LENGTH = 1000
|
33
33
|
|
34
|
-
#
|
35
|
-
def switch_to_utf8(s
|
34
|
+
# Attempt to switch string encoding to utf-8. Return fallback if not a valid utf-8 sequence.
|
35
|
+
def switch_to_utf8(s)
|
36
|
+
return if !s
|
37
|
+
|
38
|
+
return s if s.encoding == Encoding::UTF_8
|
39
|
+
|
36
40
|
s_utf_8 = s.dup.force_encoding(Encoding::UTF_8)
|
37
|
-
s_utf_8.valid_encoding?
|
38
|
-
|
39
|
-
|
41
|
+
return s_utf_8 if s_utf_8.valid_encoding?
|
42
|
+
|
43
|
+
# Fallback for binary data
|
44
|
+
return "Binary (#{s.size} bytes)"
|
40
45
|
end
|
41
46
|
|
42
47
|
def truncate_body(s)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hubrise_initializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antoine Monnier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lograge
|