Added time-stamp and process/thread information to the Windows debug logs.

This commit is contained in:
Juan Carlos Luciani 2008-01-02 17:45:07 +00:00
parent eda4718f3a
commit a8a4e9e975
3 changed files with 55 additions and 46 deletions

View File

@ -53,27 +53,30 @@
// } \ // } \
//} //}
#define DbgTrace(LEVEL, X, Y) { \ #define DbgTrace(LEVEL, X, Y) { \
char formatBuff[128]; \ char formatBuff[256]; \
char printBuff[256]; \ char printBuff[384]; \
FILE *pDebugFile; \ FILE *pDebugFile; \
if (LEVEL == 0 || KrbMechDebugLevel >= LEVEL) \ if (LEVEL == 0 || KrbMechDebugLevel >= LEVEL) \
{ \ { \
strcpy(formatBuff, "Krb5Mech "); \ SYSTEMTIME sysTime; \
strncat(formatBuff, X, sizeof(formatBuff) - 9); \ GetLocalTime(&sysTime); \
_snprintf(printBuff, sizeof(printBuff), formatBuff, Y); \ _snprintf(formatBuff, sizeof(formatBuff), "[%X-%X] [%02d:%02d:%02d] CASA_KrbMech ", GetCurrentProcessId(), GetCurrentThreadId(), sysTime.wHour, sysTime.wMinute, sysTime.wSecond); \
if (pKrbMechDebugLogFilePath) \ strncat(formatBuff, X, sizeof(formatBuff) - strlen(formatBuff) - 1); \
{ \ _snprintf(printBuff, sizeof(printBuff), formatBuff, Y); \
pDebugFile = fopen(pKrbMechDebugLogFilePath, "a+"); \ if (pKrbMechDebugLogFilePath) \
if (pDebugFile) \ { \
{ \ pDebugFile = fopen(pKrbMechDebugLogFilePath, "a+"); \
fwrite(printBuff, strlen(printBuff), 1, pDebugFile); \ if (pDebugFile) \
fclose(pDebugFile); \ { \
} \ fwrite(printBuff, strlen(printBuff), 1, pDebugFile); \
} \ fflush(pDebugFile); \
else \ fclose(pDebugFile); \
OutputDebugString(printBuff); \ } \
} \ } \
} else \
OutputDebugString(printBuff); \
} \
}
#define INT32_MAX (2147483647) #define INT32_MAX (2147483647)
#define UINT32_MAX (4294967295U) #define UINT32_MAX (4294967295U)

View File

@ -51,27 +51,30 @@
// } \ // } \
//} //}
#define DbgTrace(LEVEL, X, Y) { \ #define DbgTrace(LEVEL, X, Y) { \
char formatBuff[128]; \ char formatBuff[256]; \
char printBuff[256]; \ char printBuff[384]; \
FILE *pDebugFile; \ FILE *pDebugFile; \
if (LEVEL == 0 || PwdMechDebugLevel >= LEVEL) \ if (LEVEL == 0 || PwdMechDebugLevel >= LEVEL) \
{ \ { \
strcpy(formatBuff, "CASA_PwdMech "); \ SYSTEMTIME sysTime; \
strncat(formatBuff, X, sizeof(formatBuff) - 8); \ GetLocalTime(&sysTime); \
_snprintf(printBuff, sizeof(printBuff), formatBuff, Y); \ _snprintf(formatBuff, sizeof(formatBuff), "[%X-%X] [%02d:%02d:%02d] CASA_PwdMech ", GetCurrentProcessId(), GetCurrentThreadId(), sysTime.wHour, sysTime.wMinute, sysTime.wSecond); \
if (pPwdMechDebugLogFilePath) \ strncat(formatBuff, X, sizeof(formatBuff) - strlen(formatBuff) - 1); \
{ \ _snprintf(printBuff, sizeof(printBuff), formatBuff, Y); \
pDebugFile = fopen(pPwdMechDebugLogFilePath, "a+"); \ if (pPwdMechDebugLogFilePath) \
if (pDebugFile) \ { \
{ \ pDebugFile = fopen(pPwdMechDebugLogFilePath, "a+"); \
fwrite(printBuff, strlen(printBuff), 1, pDebugFile); \ if (pDebugFile) \
fclose(pDebugFile); \ { \
} \ fwrite(printBuff, strlen(printBuff), 1, pDebugFile); \
} \ fflush(pDebugFile); \
else \ fclose(pDebugFile); \
OutputDebugString(printBuff); \ } \
} \ } \
} else \
OutputDebugString(printBuff); \
} \
}
#define INT32_MAX (2147483647) #define INT32_MAX (2147483647)
#define UINT32_MAX (4294967295U) #define UINT32_MAX (4294967295U)

View File

@ -53,13 +53,15 @@
// } \ // } \
//} //}
#define DbgTrace(LEVEL, X, Y) { \ #define DbgTrace(LEVEL, X, Y) { \
char formatBuff[128]; \ char formatBuff[256]; \
char printBuff[256]; \ char printBuff[384]; \
FILE *pDebugFile; \ FILE *pDebugFile; \
if (LEVEL == 0 || DebugLevel >= LEVEL) \ if (LEVEL == 0 || DebugLevel >= LEVEL) \
{ \ { \
strcpy(formatBuff, "CASA_AuthToken "); \ SYSTEMTIME sysTime; \
strncat(formatBuff, X, sizeof(formatBuff) - 10); \ GetLocalTime(&sysTime); \
_snprintf(formatBuff, sizeof(formatBuff), "[%X-%X] [%02d:%02d:%02d] CASA_AuthToken ", GetCurrentProcessId(), GetCurrentThreadId(), sysTime.wHour, sysTime.wMinute, sysTime.wSecond); \
strncat(formatBuff, X, sizeof(formatBuff) - strlen(formatBuff) - 1); \
_snprintf(printBuff, sizeof(printBuff), formatBuff, Y); \ _snprintf(printBuff, sizeof(printBuff), formatBuff, Y); \
if (g_pDebugLogFilePath) \ if (g_pDebugLogFilePath) \
{ \ { \
@ -67,6 +69,7 @@ FILE *pDebugFile; \
if (pDebugFile) \ if (pDebugFile) \
{ \ { \
fwrite(printBuff, strlen(printBuff), 1, pDebugFile); \ fwrite(printBuff, strlen(printBuff), 1, pDebugFile); \
fflush(pDebugFile); \
fclose(pDebugFile); \ fclose(pDebugFile); \
} \ } \
} \ } \