Added time-stamp and process/thread information to the Windows debug logs.
This commit is contained in:
		| @@ -51,27 +51,30 @@ | ||||
| //   }                                                     \ | ||||
| //} | ||||
| #define DbgTrace(LEVEL, X, Y) {                                  \ | ||||
| char formatBuff[128];                                            \ | ||||
| char printBuff[256];                                             \ | ||||
| FILE  *pDebugFile;                                               \ | ||||
|    if (LEVEL == 0 || PwdMechDebugLevel >= LEVEL)                 \ | ||||
|    {                                                             \ | ||||
|       strcpy(formatBuff, "CASA_PwdMech ");                       \ | ||||
|       strncat(formatBuff, X, sizeof(formatBuff) - 8);            \ | ||||
|       _snprintf(printBuff, sizeof(printBuff), formatBuff, Y);    \ | ||||
|       if (pPwdMechDebugLogFilePath)                              \ | ||||
|       {                                                          \ | ||||
|          pDebugFile = fopen(pPwdMechDebugLogFilePath, "a+");     \ | ||||
|          if (pDebugFile)                                         \ | ||||
|          {                                                       \ | ||||
|             fwrite(printBuff, strlen(printBuff), 1, pDebugFile); \ | ||||
|             fclose(pDebugFile);                                  \ | ||||
|          }                                                       \ | ||||
|       }                                                          \ | ||||
|       else                                                       \ | ||||
|          OutputDebugString(printBuff);                           \ | ||||
|    }                                                             \ | ||||
| } | ||||
| char formatBuff[256];                                            \ | ||||
| char printBuff[384];                                             \ | ||||
| FILE  *pDebugFile;                                               \ | ||||
|    if (LEVEL == 0 || PwdMechDebugLevel >= LEVEL)                 \ | ||||
|    {                                                             \ | ||||
|       SYSTEMTIME sysTime;                                        \ | ||||
|       GetLocalTime(&sysTime);                                    \ | ||||
|       _snprintf(formatBuff, sizeof(formatBuff), "[%X-%X] [%02d:%02d:%02d] CASA_PwdMech ", GetCurrentProcessId(), GetCurrentThreadId(), sysTime.wHour, sysTime.wMinute, sysTime.wSecond); \ | ||||
|       strncat(formatBuff, X, sizeof(formatBuff) - strlen(formatBuff) - 1); \ | ||||
|       _snprintf(printBuff, sizeof(printBuff), formatBuff, Y);    \ | ||||
|       if (pPwdMechDebugLogFilePath)                              \ | ||||
|       {                                                          \ | ||||
|          pDebugFile = fopen(pPwdMechDebugLogFilePath, "a+");     \ | ||||
|          if (pDebugFile)                                         \ | ||||
|          {                                                       \ | ||||
|             fwrite(printBuff, strlen(printBuff), 1, pDebugFile); \ | ||||
|             fflush(pDebugFile);                                  \ | ||||
|             fclose(pDebugFile);                                  \ | ||||
|          }                                                       \ | ||||
|       }                                                          \ | ||||
|       else                                                       \ | ||||
|          OutputDebugString(printBuff);                           \ | ||||
|    }                                                             \ | ||||
| } | ||||
|  | ||||
| #define INT32_MAX (2147483647) | ||||
| #define UINT32_MAX (4294967295U) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user