From 4bea2efb74be2eab9b66421b54bfb7a786566819 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 12 Jul 2014 13:26:26 +0000 Subject: netlib: - added a thread id to a log; - get rid of that (NULL) git-svn-id: http://svn.miranda-ng.org/main/trunk@9771 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/netlib/netliblog.cpp | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'src/modules/netlib/netliblog.cpp') diff --git a/src/modules/netlib/netliblog.cpp b/src/modules/netlib/netliblog.cpp index 92409ddeb6..8b09f49d1d 100644 --- a/src/modules/netlib/netliblog.cpp +++ b/src/modules/netlib/netliblog.cpp @@ -302,35 +302,28 @@ static INT_PTR NetlibLog(WPARAM wParam, LPARAM lParam) } /* if the Netlib user handle is NULL, just pretend its not */ - NetlibUser nludummy; - if (nlu == NULL) { - if (!logOptions.toLog) - return 1; - nlu = &nludummy; - nlu->user.szSettingsModule = "(NULL)"; - } - else if (!nlu->toLog) + if (nlu != NULL && !nlu->toLog) return 1; LARGE_INTEGER liTimeNow; char szTime[32], szHead[128]; switch (logOptions.timeFormat) { case TIMEFORMAT_HHMMSS: - GetTimeFormatA(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, - NULL, NULL, szTime, SIZEOF(szTime)); + GetTimeFormatA(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, NULL, NULL, szTime, SIZEOF(szTime)); + strcat(szTime, " "); break; case TIMEFORMAT_MILLISECONDS: QueryPerformanceCounter(&liTimeNow); liTimeNow.QuadPart -= mirandaStartTime; - mir_snprintf(szTime, SIZEOF(szTime), "%I64u.%03I64u", liTimeNow.QuadPart / perfCounterFreq, + mir_snprintf(szTime, SIZEOF(szTime), "%I64u.%03I64u ", liTimeNow.QuadPart / perfCounterFreq, 1000 * (liTimeNow.QuadPart % perfCounterFreq) / perfCounterFreq); break; case TIMEFORMAT_MICROSECONDS: QueryPerformanceCounter(&liTimeNow); liTimeNow.QuadPart -= mirandaStartTime; - mir_snprintf(szTime, SIZEOF(szTime), "%I64u.%06I64u", liTimeNow.QuadPart / perfCounterFreq, + mir_snprintf(szTime, SIZEOF(szTime), "%I64u.%06I64u ", liTimeNow.QuadPart / perfCounterFreq, 1000000 * (liTimeNow.QuadPart % perfCounterFreq) / perfCounterFreq); break; @@ -338,12 +331,12 @@ static INT_PTR NetlibLog(WPARAM wParam, LPARAM lParam) szTime[0] = '\0'; break; } - if (logOptions.timeFormat || logOptions.showUser) - mir_snprintf(szHead, SIZEOF(szHead) - 1, "[%s%s%s] ", szTime, - (logOptions.showUser && logOptions.timeFormat) ? " " : "", - logOptions.showUser ? nlu->user.szSettingsModule : ""); + + char *szUser = (logOptions.showUser) ? (nlu == NULL ? NULL : nlu->user.szSettingsModule) : NULL; + if (szUser) + mir_snprintf(szHead, SIZEOF(szHead) - 1, "[%s%04X] [%s] ", szTime, GetCurrentThreadId(), szUser); else - szHead[0] = 0; + mir_snprintf(szHead, SIZEOF(szHead) - 1, "[%s%04X] ", szTime, GetCurrentThreadId()); if (logOptions.toOutputDebugString) { if (szHead[0]) -- cgit v1.2.3