In order to cope gracefully with Log*()
calls that are invoked prior to logging being fully configured (indicated by calling StartLogging()
we buffer early log messages in m_msgs_before_open
. This has a couple of minor issues:
- if there are many such log messages the buffer can become arbitrarily large; this can be a problem for users of libkernel that might not wish to worry about logging at all, and as a result never invoke
StartLogging()
- early log messages are formatted before the formatting options are configured, leading to inconsistent output
Fix those issues by buffering the log info prior to formatting it, and setting a limit on the size of the buffer (dropping the oldest lines, and reporting the number of lines skipped).
Also adds some thread safety annotations, and the ability to invoke LogInstance().DisableLogging()
if you want to disable logging entirely, for a minor efficiency improvement.