We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
As discussed in the forum https://erlangforums.com/t/logstasher-is-erlang-logger-formatter-for-logstash/1026/2
Just applying term_to_binary to any list that happens to be a valid iolist is not always intuitive
term_to_binary
The one trying to log smth like that:
Tags = ["foo", "bar", "baz"], logger:info(#{label => something_happened, tags => Tags})
would rater expect it to be logged as
{"label": "something_happened", "tags": ["foo", "bar", "baz"]}
than
{"label": "something_happened", "tags": "foobarbaz"}
In our project we ended up with smth like
term_to_json([C | _] = List) when is_integer(C) -> case io_lib:char_list(S) of true -> unicode:characters_to_binary(List, utf8); %% string() or specific form of unicode:chardata() false -> lists:map(fun term_to_json/1, List) % JS array end;
Another issue is that calling iolist_to_binary is not guaranteed to succeed if it's guarded by io_lib:char_list:
iolist_to_binary
io_lib:char_list
> S = "привет", io_lib:char_list(S). true > iolist_to_binary(S). ** exception error: bad argument in function iolist_to_binary/1 called as iolist_to_binary([1087,1088,1080,1074,1077,1090]) *** argument 1: not an iodata term
unicode:characters_to_binary(S, utf8) might be a better choice.
unicode:characters_to_binary(S, utf8)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
As discussed in the forum https://erlangforums.com/t/logstasher-is-erlang-logger-formatter-for-logstash/1026/2
Just applying
term_to_binary
to any list that happens to be a valid iolist is not always intuitiveThe one trying to log smth like that:
would rater expect it to be logged as
than
In our project we ended up with smth like
Another issue is that calling
iolist_to_binary
is not guaranteed to succeed if it's guarded byio_lib:char_list
:unicode:characters_to_binary(S, utf8)
might be a better choice.The text was updated successfully, but these errors were encountered: