Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/windirstat.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorOliver Schneider <oliver@assarbad.net>2014-01-27 02:11:59 +0400
committerOliver Schneider <oliver@assarbad.net>2014-01-27 02:11:59 +0400
commit3e53ded94714323f8603215eabacc8bffcd77a08 (patch)
tree23f28370f6d12a9d1431b4b8088425dd184e8ce2 /common
parent5c08cdf538e5d28d552309cc1aec99a37def2067 (diff)
Limiting the output from VTRACE()
Diffstat (limited to 'common')
-rw-r--r--common/tracer.cpp31
-rw-r--r--common/tracer.h16
2 files changed, 38 insertions, 9 deletions
diff --git a/common/tracer.cpp b/common/tracer.cpp
index 6acdf98..b2899d5 100644
--- a/common/tracer.cpp
+++ b/common/tracer.cpp
@@ -40,6 +40,7 @@
CWDSTracerConsole::CWDSTracerConsole()
{
::AllocConsole();
+ ::SetConsoleTitle(_T("WinDirStat debug trace output"));
// Standard output
int hCrt = _open_osfhandle((intptr_t)::GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
FILE *hf = _fdopen(hCrt, "w");
@@ -60,8 +61,8 @@ CWDSTracerConsole::~CWDSTracerConsole()
CWDSTracer::CWDSTracer(LPCSTR srcfile, LPCSTR fctname, unsigned int srcline)
: m_srcfile(srcfile)
- , m_srcfunc(fctname)
, m_srcline(srcline)
+ , m_srcfunc(fctname)
// we can rely on the format with back slashes, no need to check forward slashes here
, m_srcbasename((srcfile) ? strrchr(srcfile, '\\') : NULL)
{
@@ -76,8 +77,18 @@ void CWDSTracer::operator()(LPCSTR format, ...) // ANSI
va_start(args, format);
str.FormatV(format, args);
va_end(args);
- CStringA strDbg;
- strDbg.Format("[%hs:%u:%hs] %hs\n", m_srcbasename, m_srcline, m_srcfunc, str.GetBuffer());
+ CStringA strDbg, strPfx;
+# if (VTRACE_DETAIL == VTRACE_FILE_LINE_FUNC)
+ strPfx.Format("%hs:%u|%hs", m_srcbasename, m_srcline, m_srcfunc);
+# elif (VTRACE_DETAIL == VTRACE_FILE_LINE)
+ strPfx.Format("%hs:%u", m_srcbasename, m_srcline);
+# elif (VTRACE_DETAIL == VTRACE_FUNC)
+ strPfx = m_srcfunc;
+# endif
+ if(strPfx.IsEmpty())
+ strDbg.Format("%hs\n", str.GetBuffer());
+ else
+ strDbg.Format("[%hs] %hs\n", strPfx.GetBuffer(), str.GetBuffer());
# if !VTRACE_TO_CONSOLE || (VTRACE_TO_CONSOLE && !VTRACE_NO_OUTPUTDEBUGSTRING)
OutputDebugStringA(strDbg.GetBuffer());
# endif
@@ -93,8 +104,18 @@ void CWDSTracer::operator()(LPCWSTR format, ...) // Unicode
va_start(args, format);
str.FormatV(format, args);
va_end(args);
- CStringW strDbg;
- strDbg.Format(L"[%hs:%u:%hs] %ws\n", m_srcbasename, m_srcline, m_srcfunc, str.GetBuffer());
+ CStringW strDbg, strPfx;
+# if (VTRACE_DETAIL == VTRACE_FILE_LINE_FUNC)
+ strPfx.Format(L"%hs:%u|%hs", m_srcbasename, m_srcline, m_srcfunc);
+# elif (VTRACE_DETAIL == VTRACE_FILE_LINE)
+ strPfx.Format(L"%hs:%u", m_srcbasename, m_srcline);
+# elif (VTRACE_DETAIL == VTRACE_FUNC)
+ strPfx = m_srcfunc;
+# endif
+ if(strPfx.IsEmpty())
+ strDbg.Format(L"%ws\n", str.GetBuffer());
+ else
+ strDbg.Format(L"[%ws] %ws\n", strPfx.GetBuffer(), str.GetBuffer());
# if !VTRACE_TO_CONSOLE || (VTRACE_TO_CONSOLE && !VTRACE_NO_OUTPUTDEBUGSTRING)
OutputDebugStringW(strDbg.GetBuffer());
# endif
diff --git a/common/tracer.h b/common/tracer.h
index 3ee72dc..1089f73 100644
--- a/common/tracer.h
+++ b/common/tracer.h
@@ -33,6 +33,14 @@
#endif // Check for "#pragma once" support
#ifdef _DEBUG
+#define VTRACE_FILE_LINE_FUNC 3
+#define VTRACE_FILE_LINE 2
+#define VTRACE_FUNC 1
+
+#ifndef VTRACE_DETAIL
+# define VTRACE_DETAIL 3
+#endif
+
#if VTRACE_TO_CONSOLE
class CWDSTracerConsole
{
@@ -50,16 +58,16 @@ public:
void operator()(LPCWSTR format, ...);
private:
const CStringA m_srcfile;
- const CStringA m_srcfunc;
unsigned int m_srcline;
LPCSTR m_srcbasename;
+ LPCSTR m_srcfunc;
CWDSTracer& operator=(const CWDSTracer&); // hide it
};
// Use as VTRACE(format, ...) ... *must* be on one long line ;)
# define VTRACE CWDSTracer(__##FILE##__, __##FUNCTION##__, __##LINE##__)
-#else // not _DEBUG, ... please note that this trick works _because_ of the VC++ preprocessor
-# define VTRACE /##/
+#else
+# define VTRACE __noop
#endif // _DEBUG
-#endif // __TRACER_H_VER__ \ No newline at end of file
+#endif // __TRACER_H_VER__