void logf(const char* fmt, ...)
{
va_list args;
- va_start(args, fmt);
static bool logToEEfailed = false;
//
// We remember when the EE failed to log, because vlogf()
// If it fails to log an LL_INFO1000 message once
// it will always fail when logging an LL_INFO1000 message.
//
- if (logToEEfailed)
+ if (!logToEEfailed)
{
- logf_stdout(fmt, args);
+ va_start(args, fmt);
+ if (!vlogf(LL_INFO1000, fmt, args))
+ logToEEfailed = true;
+ va_end(args);
}
- else if (!vlogf(LL_INFO1000, fmt, args))
+
+ if (logToEEfailed)
{
- logToEEfailed = true;
-
- // The vlogf call may have modified args, so we need to reset it
- va_end(args);
+ // if the EE refuses to log it, we try to send it to stdout
va_start(args, fmt);
-
logf_stdout(fmt, args);
+ va_end(args);
}
#if 0 // Enable this only when you need it
else
_ASSERTE ( cArgs >= 0 && cArgs <= 7 );
va_list Args;
- va_start(Args, format);
if(InlinedStressLogOn(facility, level))
{
if (msgs == 0)
return;
}
+ va_start(Args, format);
msgs->LogMsg (facility, cArgs, format, Args);
+ va_end(Args);
}
// Stress Log ETW feature available only on the desktop versions of the runtime
#if !defined(FEATURE_CORECLR)
// The previous LogMsg call could have modified the Args, so we need to reset it
- va_end(Args);
- va_start(Args, format);
if(InlinedETWLogOn(facility, level))
{
#define MAX_STRESSLOG_DATA_ETW_LENGTH 256
CHAR logMessage[MAX_STRESSLOG_DATA_ETW_LENGTH];
+ va_start(Args, format);
ULONG messageLength = (USHORT)_vsnprintf_s(logMessage, COUNTOF(logMessage), MAX_STRESSLOG_DATA_ETW_LENGTH-1, format, Args);
+ va_end(Args);
if(messageLength >= 0 &&
messageLength < MAX_STRESSLOG_DATA_ETW_LENGTH) // this condition has been added to make prefast happy
#undef MAX_STRESSLOG_DATA_ETW_LENGTH
}
#endif // !FEATURE_CORECLR
-
- va_end(Args);
#endif //!DACCESS_COMPILE
}