Using Google's logging library (glog-0.3.2), are the individual entries sent to the log wrapped by a mutex? That is, can other entries corrupt the entry currently being saved?
I guess that translates to: is glog threadsafe?
And if the logger is set to echo to console as well as to file, short of having my own mutex, is there any way to block printf
/cout
from corrupting the output from LOG()
? I suspect not but wondered if perhaps there is a way to lock the mutex that can wrap several statements.
Yes, glog can be threadsafe.
Raw Logging
The header file can be used for thread-safe logging, which does not allocate any memory or acquire any locks. Therefore, the macros defined in this header file can be used by low-level memory allocation and synchronization code. Please check src/glog/raw_logging.h.in for detail.