Commit 4202c102 authored by Adrian Buehlmann's avatar Adrian Buehlmann

shellext: disable debug output per default

To have debug output enabled
- compile with THG_DEBUG set (debug build)
- double-click the file DebugShellExt.reg
- restart explorer

--HG--
branch : stable
parent 7b7599d33425
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\TortoiseHg]
"DebugShellExt"="1"
......@@ -2,7 +2,8 @@
OBJECTS_DIRSTATE = TortoiseUtils.obj \
Direntry.obj \
Directory.obj \
Winstat.obj
Winstat.obj \
ThgDebug.obj
OBJECTS_THGSGELL = $(OBJECTS_DIRSTATE) \
InitStatus.obj \
......@@ -15,7 +16,8 @@ OBJECTS_THGSGELL = $(OBJECTS_DIRSTATE) \
Dirstatecache.obj \
DirectoryStatus.obj \
Thgstatus.obj \
QueryDirstate.obj
QueryDirstate.obj \
ThgDebug.obj
LIBS = User32.lib Ole32.lib Shlwapi.lib Shell32.lib Advapi32.lib
DEFFILE = ShellExt.def
......
......@@ -151,6 +151,9 @@ The shell extension emits trace output (TDEBUG_TRACE macro calls in the sources)
can be captured by using for example the tool **DebugView** from Microsoft sysinternals (see
http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx).
The debug output must be enabled in the registry. Double click the file
"DebugShellExt.reg" and restart explorer.
Example output (copied via clipboard):
{{{
......
// Copyright (C) 2009 Adrian Buehlmann
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
#include "ThgDebug.h"
#include "TortoiseUtils.h"
#include <string>
bool ThgDebug::regDebugShellExt()
{
std::string val;
return GetRegistryConfig("DebugShellExt", val) != 0 && val == "1";
}
bool ThgDebug::enabled()
{
static bool e = regDebugShellExt();
return e;
}
// Copyright (C) 2009 Adrian Buehlmann
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
#ifndef THGDEBUG_H
#define THGDEBUG_H
class ThgDebug
{
public:
static bool enabled();
private:
ThgDebug();
static bool regDebugShellExt();
};
#endif
......@@ -15,6 +15,8 @@
#include <assert.h>
#include <string>
#include "ThgDebug.h"
#define ASSERT assert
......@@ -24,18 +26,18 @@
// TDEBUG_TRACE() prints debugging messages to Windows' debugger display.
// The messages can be viewed with Sysinternals DebugView, which may be
// downloaded from Microsoft TechNet.
#define TDEBUG_TRACE(s) do { \
#define TDEBUG_TRACE(s) if (ThgDebug::enabled()) { \
std::stringstream _the_msg; \
_the_msg << "[THG] " << s; \
std::string _the_str = _the_msg.str(); \
OutputDebugStringA(_the_str.c_str()); \
} while (0)
#define TDEBUG_TRACEW(s) do { \
}
#define TDEBUG_TRACEW(s) if (ThgDebug::enabled()) { \
std::basic_stringstream<wchar_t> _the_msg; \
_the_msg << L"[THG] " << s; \
std::wstring _the_str = _the_msg.str(); \
OutputDebugStringW(_the_str.c_str()); \
} while (0)
}
#define TDEBUG_ENTER TDEBUG_TRACE
#else
#define TDEBUG_TRACE(s)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment