9.3. Logging Thread¶
Calls to the macros presented in Logging Messages merely add the log entry to a ready-to-consume queue.
Upon creation, the logging module spawns a thread that awakes every time an entry is added to the queue.
When awaken, this thread feeds all the entries in the queue to all the registered Consumers.
Once the work is done, the thread falls back into idle state.
This strategy prevents the module from blocking the application thread when a logging operation is performed.
However, sometimes applications may want to wait until the logging routine is done to continue their operation.
The logging module provides this capability via the member function
Furthermore, it is possible to completely eliminate the thread and its resources using member function
// Block current thread until the log queue is empty. Log::Flush(); // Stop the loggin thread and free its resources. Log::KillThread();
A call to any of the macros present in Logging Messages will spawn the logging thread even if it has
been previously killed with