simple_json_log_formatter 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/simple_json_log_formatter.rb +16 -3
- data/lib/simple_json_log_formatter/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da0d035d7d2b9777a10635d6d11af182a925d8f449cb762c7dd6db6bfa41629b
|
4
|
+
data.tar.gz: 3453a84b7a43e0f644fee9bbba20087567338f663cdffe66cbc46235bcb74f1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38c17f47025f784724f30a235cd5fb6e268619291e6ba7926c38053528c4a40cf0a73fe7d9305f80ae5943c8b4e8694fa4285561a3dfc2884ad3bbca8143b0fd
|
7
|
+
data.tar.gz: 852591062e91446f94bb5c2f49aef70cfedf8862abf240dadaf9bd8b1bb863154d243222a7e6e6dc111a1f9eb23d9d36f9b514f48849347ccef643de7cd5162c
|
@@ -32,9 +32,22 @@ class SimpleJsonLogFormatter
|
|
32
32
|
|
33
33
|
private
|
34
34
|
def format_message(msg)
|
35
|
-
|
36
|
-
|
35
|
+
case msg
|
36
|
+
when String
|
37
|
+
if msg.start_with?("{") && msg.end_with?("}")
|
38
|
+
(JSON.parse(msg) rescue nil) || msg
|
39
|
+
else
|
40
|
+
msg
|
41
|
+
end
|
42
|
+
when Hash
|
43
|
+
msg
|
44
|
+
when Exception
|
45
|
+
exception = {}
|
46
|
+
exception["message"] = msg.message
|
47
|
+
exception["backtrace"] = msg.backtrace if msg.backtrace
|
48
|
+
exception
|
49
|
+
else
|
50
|
+
msg.inspect
|
37
51
|
end
|
38
|
-
msg
|
39
52
|
end
|
40
53
|
end
|