Opened 4 years ago
Last modified 4 years ago
#13594 new Bugs
init_from_settings does not allow repeated calls
Reported by: | Owned by: | Andrey Semashev | |
---|---|---|---|
Milestone: | To Be Determined | Component: | log |
Version: | Boost 1.67.0 | Severity: | Problem |
Keywords: | Cc: |
Description
I have an application that causes init_from_settings to be called repeatedly, which does not quite work as I expected. I noticed that this causes memory use to grow, presumably because old sinks are not removed and new sinks are added which each call, which (to me) is unexpected behaviour. I understand that sinks can be removed by calling remove_all_sinks() before (re)initialization, but it would be much nicer when init_from_settings would just configure the logging system 'from scratch' (I am not currently sure that I can fully revert the system to an uninitialized state before calling init_from_settings).
The current behavior is by design as the library does not discriminate between sinks added by init_from_settings or by the user manually. Removing all sinks from init_from_settings would remove sinks that might not have been added by that call previously, which is not quite the expected behavior either.
Calling remove_all_sinks from the application does remove all sinks, so if that is what you want then this is the way to go. The only other thing init_from_settings does is configuration of the logging core by setting the global filter and enabling/disabling logging completely, which replaces the previous configuration.