activesupport-json_logging 1.3.2 → 1.3.3
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/CHANGELOG.md +4 -0
- data/lib/json_logging/line_encoder.rb +7 -7
- data/lib/json_logging/structured_hash_json_encoder.rb +3 -3
- data/lib/json_logging/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: 9efc2314c0376efb67a3889a8212e9ce20afdf69f62d41c2f30627e2cf6c2754
|
|
4
|
+
data.tar.gz: 53ebc52bbbb6bb5cea9389ca5e2941c3be45bf3e9a7e0c1dadafffb4745118fe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 39a43fb4295a780a0264707a80e3f19020eec0f9eedbe75d71f1652656713e2b9b49906aaf61d69a64a6e1d5f9dbd880140fedf9090c2bfc4509b20a4c9180ea
|
|
7
|
+
data.tar.gz: b599ed9a3ca38e34e74c86f8a892e5cd59b3191df4760eff8dc8f5ef9875ef9ff197045b8e30d04d8653daceebb14e77a219c57b772b46cb94ba61999651462f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 1.3.3 (2026-11-10)
|
|
4
|
+
|
|
5
|
+
- Emit log lines with `JSON.generate` so boot and encode work under json 3, which removed `JSON.fast_generate`
|
|
6
|
+
|
|
3
7
|
## 1.3.2 (2026-11-07)
|
|
4
8
|
|
|
5
9
|
- Prefer `JSON.fast_generate` on generic `to_json_line`, structured-hash encoder assembly, and `LineEncoder` fast-path lines
|
|
@@ -83,7 +83,7 @@ module JsonLogging
|
|
|
83
83
|
def to_json_line(payload_hash)
|
|
84
84
|
compacted = payload_hash.compact
|
|
85
85
|
json_payload = string_keyed_structure?(compacted) ? compacted : compacted.deep_stringify_keys
|
|
86
|
-
"#{JSON.
|
|
86
|
+
"#{JSON.generate(json_payload)}\n"
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
def string_keyed_structure?(object)
|
|
@@ -106,7 +106,7 @@ module JsonLogging
|
|
|
106
106
|
|
|
107
107
|
def simple_string_json_line(message:, severity:, timestamp:)
|
|
108
108
|
sanitized_message = Sanitizer.sanitize_string(message)
|
|
109
|
-
"#{JSON.
|
|
109
|
+
"#{JSON.generate("message" => sanitized_message, "severity" => severity, "timestamp" => timestamp)}\n"
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
def tagged_simple_string_line?(message, tags, additional_context)
|
|
@@ -124,7 +124,7 @@ module JsonLogging
|
|
|
124
124
|
else
|
|
125
125
|
tags
|
|
126
126
|
end
|
|
127
|
-
"#{JSON.
|
|
127
|
+
"#{JSON.generate("message" => sanitized_message, "severity" => severity, "timestamp" => timestamp, "tags" => prepared_tags)}\n"
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
def contextual_simple_string_line?(message, tags, additional_context, additional_context_sanitized:)
|
|
@@ -144,7 +144,7 @@ module JsonLogging
|
|
|
144
144
|
}
|
|
145
145
|
context = PayloadBuilder.context_payload_portion(additional_context)
|
|
146
146
|
payload["context"] = context unless context.empty?
|
|
147
|
-
"#{JSON.
|
|
147
|
+
"#{JSON.generate(payload)}\n"
|
|
148
148
|
end
|
|
149
149
|
|
|
150
150
|
def standalone_hash_line?(message, tags, additional_context)
|
|
@@ -165,7 +165,7 @@ module JsonLogging
|
|
|
165
165
|
payload = Sanitizer.sanitize_hash(hash)
|
|
166
166
|
payload["severity"] = severity
|
|
167
167
|
payload["timestamp"] = timestamp
|
|
168
|
-
"#{JSON.
|
|
168
|
+
"#{JSON.generate(payload)}\n"
|
|
169
169
|
end
|
|
170
170
|
|
|
171
171
|
def tagged_hash_line?(message, tags, additional_context)
|
|
@@ -196,7 +196,7 @@ module JsonLogging
|
|
|
196
196
|
payload["severity"] = severity
|
|
197
197
|
payload["timestamp"] = timestamp
|
|
198
198
|
payload["tags"] = merged_tags
|
|
199
|
-
"#{JSON.
|
|
199
|
+
"#{JSON.generate(payload)}\n"
|
|
200
200
|
end
|
|
201
201
|
|
|
202
202
|
def contextual_hash_line?(message, tags, additional_context, additional_context_sanitized:)
|
|
@@ -231,7 +231,7 @@ module JsonLogging
|
|
|
231
231
|
existing_context = payload["context"].is_a?(Hash) ? payload["context"] : {}
|
|
232
232
|
payload["context"] = existing_context.merge(merged_context)
|
|
233
233
|
end
|
|
234
|
-
"#{JSON.
|
|
234
|
+
"#{JSON.generate(payload)}\n"
|
|
235
235
|
end
|
|
236
236
|
|
|
237
237
|
def deep_stringify_structure(obj)
|
|
@@ -65,11 +65,11 @@ module JsonLogging
|
|
|
65
65
|
def append_json_line(tree, severity:, timestamp:, field_overrides:)
|
|
66
66
|
extras = field_overrides.merge("severity" => severity, "timestamp" => timestamp)
|
|
67
67
|
# rubocop:disable Rails/Blank -- encoder path must not require ActiveSupport blank?
|
|
68
|
-
return "#{JSON.
|
|
68
|
+
return "#{JSON.generate(extras)}\n" if tree.nil? || tree.empty?
|
|
69
69
|
# rubocop:enable Rails/Blank
|
|
70
70
|
|
|
71
|
-
body = JSON.
|
|
72
|
-
extra_json = extras.map { |key, value| "#{JSON.
|
|
71
|
+
body = JSON.generate(tree)
|
|
72
|
+
extra_json = extras.map { |key, value| "#{JSON.generate(key.to_s)}:#{JSON.generate(value)}" }.join(",")
|
|
73
73
|
"#{body.chop},#{extra_json}}\n"
|
|
74
74
|
end
|
|
75
75
|
|
data/lib/json_logging/version.rb
CHANGED