otp
otp copied to clipboard
cth_log_redirect could support more logger configuration
Is your feature request related to a problem? Please describe.
When using cth_log_redirect progress logs get enabled automatically (because of how logger works by default). In some cases, these can get very verbose and increase the size of test logs by megabytes.
The actual case is starting hackney with {ssl_options, tls_certificate_check:options(Host)} which will include all system certificates as binaries in the start arguments. This results in logging megabytes of binary data to the log every time Hackney starts.
Describe the solution you'd like
The module cth_log_redirect should copy additional logger configuration such as filters and filter_default so that one can use e.g. logger_filters:progress/2 as a filter for the test logs.
Describe alternatives you've considered Completely replace our HTTP client implementation just to avoid blowing up the size of the test logs.
Additional context Would most likely require minimal changes here: https://github.com/erlang/otp/blob/e6cc8082e6b4676298de677e53e32b006d0168b3/lib/common_test/src/cth_log_redirect.erl#L134-L141
Would be happy to do a PR if there is agreement that this change is desirable.
I think this sounds like good idea and matches to other initiatives aiming at taming CT output. Maybe @garazdawi could also comment about preferred shape of such PR, since this is relates to both CT and logger ...
I'd propose replacing the above snippet with the following change:
HandlerConfig =
case logger:get_handler_config(default) of
{ok, Default} ->
maps:with([level, formatter, filters, filter_default], Default);
_Else ->
#{
level => info,
formatter => {?DEFAULT_FORMATTER, ?DEFAULT_FORMAT_CONFIG}
}
end,
Please create a PR. I guess you intended to use maps:with/2 in your snippet ...
👍 Yes, you are correct (I've updated the suggestion snippet)
Short status update: got stuck with the tests. I haven't figured out how they work exactly and how to add a new test for this case yet.
CT tests are sometimes tricky. Can you push PR without tests at this stage?