diff --git a/src/logger_journald_h.erl b/src/logger_journald_h.erl index 09ed3a3..8ac2ce1 100644 --- a/src/logger_journald_h.erl +++ b/src/logger_journald_h.erl @@ -335,16 +335,21 @@ ensure_bytes(V) when is_list(V) -> _ -> V catch error:badarg -> - try unicode:characters_to_binary(V) - catch error:badarg -> - io_lib:format("~w", [V]) - end + non_io_list_to_bytes(V) end; ensure_bytes(V) when is_integer(V) -> integer_to_binary(V); ensure_bytes(V) when is_atom(V) -> atom_to_binary(V, utf8). +non_io_list_to_bytes(V) -> + try + unicode:characters_to_binary(V) + catch + error:badarg -> + iolist_to_binary(io_lib:format("~w", [V])) + end. + %% Overlaod protection overload_init(#{id := Name} = _Conf) ->