kernel: Allow arbitrary binary Logger formatters
Data from formatters that is already in binary format is passed through as-is to the handler, allowing for binary logging. Lists are still assumed to possibly contain unicode data and will be converted with unicode:characters_to_binary/1 as before.
This opens up for re-using the Logger framework as is with a simple formatter that e.g. calls term_to_binary/1 for binary logging:
-module(my_binlog).
-export([start_binlog/0, format/2]).
start_binlog() ->
logger:add_handler(default, logger_std_h, #{formatter => {my_binlog, #{}}}).
format(Event, _Config) -> term_to_binary(Event).
This will write reports in the Erlang term format to disk.
CT Test Results
2 files 65 suites 57m 6s :stopwatch: 1 352 tests 1 217 :heavy_check_mark: 135 :zzz: 0 :x: 1 528 runs 1 354 :heavy_check_mark: 174 :zzz: 0 :x:
Results for commit 9be5b827.
:recycle: This comment has been updated with latest results.
To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.
See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.
Artifacts
// Erlang/OTP Github Action Bot
Took a look at the test logs and couldn't find any obvious relation to my changes. Are the Kernel tests flaky normally? Any hints as to why these particular failures?
The test failure in logger_std_h_SUITE is most likely due to changes in this PR. The others are due to #6314
@garazdawi Thanks, I did spot the Logger test case on Friday but forgot to push. I can rebase on master as soon as the fix for the other tests is in.
@garazdawi I tried rebasing on the latest master after the changes in #6314 were merged, but I still see the same errors. Is there anything else I need to do, or are the failures actually related to this change?
I did a mistake in #6314, should be fixed in maint/master now.