aboutsummaryrefslogtreecommitdiffstats
path: root/src/kvilib/ext/kvi_debugcontext.cpp
diff options
context:
space:
mode:
authorGravatar Szymon Tomasz Stefanek2010-07-14 13:31:37 +0000
committerGravatar Szymon Tomasz Stefanek2010-07-14 13:31:37 +0000
commit484d98ded2038f4dd262d546b4e0fe460d907bd4 (patch)
tree4e9541dab6a937b8f580912e8c7d6decce42ef68 /src/kvilib/ext/kvi_debugcontext.cpp
parentupdated some mediaplayer homepage urls and some other typos, thanks xoffice (diff)
downloadKVIrc-484d98ded2038f4dd262d546b4e0fe460d907bd4.tar.gz
KVIrc-484d98ded2038f4dd262d546b4e0fe460d907bd4.tar.bz2
KVIrc-484d98ded2038f4dd262d546b4e0fe460d907bd4.zip
Rewrite parts of the regchan module in order to
avoid the heavy usage of pointers. Add some new nice debug macros and tools. git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@4669 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/kvilib/ext/kvi_debugcontext.cpp')
-rw-r--r--src/kvilib/ext/kvi_debugcontext.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/kvilib/ext/kvi_debugcontext.cpp b/src/kvilib/ext/kvi_debugcontext.cpp
new file mode 100644
index 000000000..160057f2b
--- /dev/null
+++ b/src/kvilib/ext/kvi_debugcontext.cpp
@@ -0,0 +1,70 @@
+//=============================================================================
+//
+// File : kvi_debugcontext.cpp
+// Creation date : Tue 13 Jul 2010 23:27:23
+// Project : KVIrc Irc client
+// Author : Szymon Stefanek <pragma at kvirc dot net>
+//
+//=============================================================================
+
+#include "kvi_debugcontext.h"
+
+#include "kvi_stdarg.h"
+#include "kvi_string.h"
+#include "kvi_debug.h"
+
+
+static KviStr g_szIndentPrefix;
+
+KviDebugContext::KviDebugContext(const char * szContext,...)
+{
+ kvi_va_list list;
+ kvi_va_start(list,szContext);
+
+ m_szContext.vsprintf(szContext,list);
+
+ kvi_va_end(list);
+
+ static KviStr szEnterMark = ">> %s";
+
+ KviStr szPrefix = g_szIndentPrefix;
+ szPrefix.append(szEnterMark);
+
+ qDebug(szPrefix.ptr(),m_szContext.ptr());
+
+ g_szIndentPrefix.append(" ");
+}
+
+
+KviDebugContext::~KviDebugContext()
+{
+ KVI_ASSERT(g_szIndentPrefix.len() >= 2);
+
+ g_szIndentPrefix.cutRight(2);
+
+ static KviStr szExitMark = "<< %s";
+
+ KviStr szPrefix = g_szIndentPrefix;
+ szPrefix.append(szExitMark);
+
+ qDebug(szPrefix.ptr(),m_szContext.ptr());
+}
+
+void KviDebugContext::trace(const char * szFmt,...)
+{
+ kvi_va_list list;
+ kvi_va_start(list,szFmt);
+
+ KviStr szOut;
+ szOut.vsprintf(szFmt,list);
+
+ kvi_va_end(list);
+
+ static KviStr szEnterMark = "-- %s";
+
+ KviStr szPrefix = g_szIndentPrefix;
+ szPrefix.append(szEnterMark);
+
+ qDebug(szPrefix.ptr(),szOut.ptr());
+}
+