in agent/native/ext/log.cpp [630:686]
void vLogWithLogger(
Logger* logger
, bool isForced
, LogLevel statementLevel
, StringView category
, StringView filePath
, UInt lineNumber
, StringView funcName
, String msgPrintfFmt
, va_list msgPrintfFmtArgs
)
{
if ( g_logMutex == NULL )
{
#ifndef PHP_WIN32
ELASTIC_APM_LOG_DIRECT_CRITICAL( "g_logMutex is NULL; filePath: %.*s, lineNumber: %d, funcName: %.*s, msgPrintfFmt: %s"
, (int)filePath.length, filePath.begin, lineNumber, (int)funcName.length, funcName.begin, msgPrintfFmt );
#endif
return;
}
if ( g_isInLogContext )
{
#ifndef PHP_WIN32
ELASTIC_APM_LOG_DIRECT_CRITICAL( "Trying to re-enter logging; filePath: %.*s, lineNumber: %d, funcName: %.*s, msgPrintfFmt: %s"
, (int)filePath.length, filePath.begin, lineNumber, (int)funcName.length, funcName.begin, msgPrintfFmt );
#endif
return;
}
g_isInLogContext = true;
bool shouldUnlockMutex = false;
// Don't log for logging mutex to avoid spamming the log
ResultCode resultCode = lockMutexNoLogging( g_logMutex, &shouldUnlockMutex, __FUNCTION__ );
if ( resultCode != resultSuccess )
{
ELASTIC_APM_LOG_DIRECT_CRITICAL( "Failed to lock g_logMutex, resultCode: %s (%d); filePath: %.*s, lineNumber: %d, funcName: %.*s, msgPrintfFmt: %s"
, resultCodeToString( resultCode ), resultCode, (int)filePath.length, filePath.begin, lineNumber, (int)funcName.length, funcName.begin, msgPrintfFmt );
goto finally;
}
vLogWithLoggerImpl( logger
, isForced
, statementLevel
, category
, filePath
, lineNumber
, funcName
, msgPrintfFmt
, msgPrintfFmtArgs );
finally:
// Don't log for logging mutex to avoid spamming the log
unlockMutexNoLogging( g_logMutex, &shouldUnlockMutex, __FUNCTION__ );
g_isInLogContext = false;
}