Skip to content

Commit fdeef91

Browse files
authored
Remove prepended warning in JSON-incompatible log reports (#58)
1 parent d368918 commit fdeef91

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ and this project adheres to
88

99
## [Unreleased]
1010

11+
### Changed
12+
13+
- Add log event metadata instead of prepending "[JSON incompatible term]" to
14+
log string data.
15+
1116
## [2.0.0] - 2025-02-26
1217

1318
### Changed

src/grisp_connect_log.erl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ jsonify_msg(#{msg := {report, Report}} = Event) ->
5858
maps:put(msg, Report, Event);
5959
false ->
6060
String = unicode:characters_to_binary(
61-
io_lib:format("[JSON incompatible term]~n~tp", [Report])
62-
),
63-
maps:put(msg, String, Event)
61+
io_lib:format("~tp", [Report])),
62+
Meta = maps:get(meta, Event, #{}),
63+
Event2 = Event#{meta => Meta#{incompatible_term => true}},
64+
maps:put(msg, String, Event2)
6465
end;
6566
jsonify_msg(#{msg := {FormatString, Term}} = Event) ->
6667
%FIXME: scan format and ensure unicode encoding

test/grisp_connect_log_SUITE.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ structured_logs_test(_) ->
168168
#{event => #{<<"errör"/utf8>> => false}},
169169
#{event => 1234},
170170
#{event => 0.1},
171-
<<"[JSON incompatible term]\n#{event => {äh,bäh}}"/utf8>>],
171+
<<"#{event => {äh,bäh}}"/utf8>>],
172172
% Ensure there is at least one log entry, so LastSeq is defined
173173
grisp_connect:log(error, ["dummy"]),
174174
LastSeq = log_reset(),

0 commit comments

Comments
 (0)