mirror of
https://github.com/FairRootGroup/FairLogger.git
synced 2025-10-13 16:46:46 +00:00
guard localtime with a mutex to avoid race
This commit is contained in:
parent
63820e5f2c
commit
1f600fa981
|
@ -575,9 +575,12 @@ void Logger::RemoveCustomSink(const string& key)
|
||||||
Logger& Logger::Log()
|
Logger& Logger::Log()
|
||||||
{
|
{
|
||||||
char tsstr[32];
|
char tsstr[32];
|
||||||
if (!strftime(tsstr, sizeof(tsstr), "%H:%M:%S", localtime(&(fMetaData.timestamp))))
|
|
||||||
{
|
{
|
||||||
tsstr[0] = 'u';
|
lock_guard<mutex> lock(fMtx); // localtime is not threadsafe, guard it
|
||||||
|
if (!strftime(tsstr, sizeof(tsstr), "%H:%M:%S", localtime(&(fMetaData.timestamp))))
|
||||||
|
{
|
||||||
|
tsstr[0] = 'u';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!fColored && LoggingToConsole()) || LoggingToFile())
|
if ((!fColored && LoggingToConsole()) || LoggingToFile())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user