summaryrefslogtreecommitdiff
path: root/protocols/Gadu-Gadu/src/gg.cpp
diff options
context:
space:
mode:
authorSzymon Tokarz <wsx22@o2.pl>2012-11-03 00:42:26 +0000
committerSzymon Tokarz <wsx22@o2.pl>2012-11-03 00:42:26 +0000
commitb6c5e03eb8c6e746ec4b1f28c472c93305986bbf (patch)
tree7007abe8c39ee405d6fd9cc1f23287fc836eaaec /protocols/Gadu-Gadu/src/gg.cpp
parent3a0bfdecae261d7a33c2114ec47dda0eaafe6572 (diff)
GaduGadu-Gadu protocol
- more info logged to netlog at debug version. schould help track multithread issues - netlog logging messages fixes git-svn-id: http://svn.miranda-ng.org/main/trunk@2157 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Gadu-Gadu/src/gg.cpp')
-rw-r--r--protocols/Gadu-Gadu/src/gg.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/protocols/Gadu-Gadu/src/gg.cpp b/protocols/Gadu-Gadu/src/gg.cpp
index b75b439af0..401eecf43c 100644
--- a/protocols/Gadu-Gadu/src/gg.cpp
+++ b/protocols/Gadu-Gadu/src/gg.cpp
@@ -154,7 +154,7 @@ void GGPROTO::cleanuplastplugin(DWORD version)
if (version < PLUGIN_MAKE_VERSION(0, 0, 1, 4))
{
#ifdef DEBUGMODE
- netlog("gg_cleanuplastplugin(%d): Cleaning junk Phone settings from < 0.0.1.4 ...", version);
+ netlog("cleanuplastplugin() version=%d Cleaning junk Phone settings from < 0.0.1.4 ...", version);
#endif
// Look for contact in DB
hContact = db_find_first();
@@ -175,7 +175,7 @@ void GGPROTO::cleanuplastplugin(DWORD version)
if (version < PLUGIN_MAKE_VERSION(0, 0, 3, 5))
{
#ifdef DEBUGMODE
- netlog("gg_cleanuplastplugin(%d): Cleaning junk Nick settings from < 0.0.3.5 ...", version);
+ netlog("cleanuplastplugin(): version=%d Cleaning junk Nick settings from < 0.0.3.5 ...", version);
#endif
// Look for contact in DB
hContact = db_find_first();
@@ -479,6 +479,10 @@ const char *ggdebug_eventtype(gg_event *e)
return ggdebug_eventype2string[i].text;
}
+//////////////////////////////////////////////////////////
+// Log funcion
+#define PREFIXLEN 6 //prefix present in DEBUGMODE contains GetCurrentThreadId()
+
#ifdef DEBUGMODE
void gg_debughandler(int level, const char *format, va_list ap)
{
@@ -487,7 +491,13 @@ void gg_debughandler(int level, const char *format, va_list ap)
char *nl = strrchr(szFormat, '\n');
if (nl) *nl = 0;
- strncpy(szText, "[libgadu] \0", sizeof(szText));
+ strncpy(szText + PREFIXLEN, "[libgadu] \0", sizeof(szText) - PREFIXLEN);
+
+ char prefix[6];
+ mir_snprintf(prefix, PREFIXLEN, "%lu", GetCurrentThreadId());
+ size_t prefixLen = strlen(prefix);
+ if (prefixLen < PREFIXLEN) memset(prefix + prefixLen, ' ', PREFIXLEN - prefixLen);
+ memcpy(szText, prefix, PREFIXLEN);
mir_vsnprintf(szText + strlen(szText), sizeof(szText) - strlen(szText), szFormat, ap);
CallService(MS_NETLIB_LOG, (WPARAM) NULL, (LPARAM) szText);
@@ -495,17 +505,25 @@ void gg_debughandler(int level, const char *format, va_list ap)
}
#endif
-//////////////////////////////////////////////////////////
-// Log funcion
int GGPROTO::netlog(const char *fmt, ...)
{
va_list va;
char szText[1024];
+ memset(szText, '\0', PREFIXLEN + 1);
+
+#ifdef DEBUGMODE
+ char prefix[6];
+ mir_snprintf(prefix, PREFIXLEN, "%lu", GetCurrentThreadId());
+ size_t prefixLen = strlen(prefix);
+ if (prefixLen < PREFIXLEN) memset(prefix + prefixLen, ' ', PREFIXLEN - prefixLen);
+ memcpy(szText, prefix, PREFIXLEN);
+#endif
va_start(va, fmt);
- mir_vsnprintf(szText, sizeof(szText), fmt, va);
+ mir_vsnprintf(szText + strlen(szText), sizeof(szText) - strlen(szText), fmt, va);
va_end(va);
+
return CallService(MS_NETLIB_LOG, (WPARAM)netlib, (LPARAM) szText);
}
@@ -517,6 +535,7 @@ BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved)
crc_gentable();
hInstance = hInst;
#ifdef DEBUGMODE
+ gg_debug_level = GG_DEBUG_FUNCTION;
gg_debug_handler = gg_debughandler;
#endif
return TRUE;