1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009, 2011, 2013-2014 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 class CTraceToOutputDebugString
26 static CTraceToOutputDebugString
& Instance()
28 if (m_pInstance
== NULL
)
29 m_pInstance
= new CTraceToOutputDebugString
;
35 return Instance().m_bActive
;
38 // Non Unicode output helper
39 void operator()(PCSTR pszFormat
, ...)
44 va_start(ptr
, pszFormat
);
45 TraceV(pszFormat
,ptr
);
50 // Unicode output helper
51 void operator()(PCWSTR pszFormat
, ...)
56 va_start(ptr
, pszFormat
);
57 TraceV(pszFormat
,ptr
);
63 CTraceToOutputDebugString()
65 m_LastTick
= GetTickCount();
66 m_bActive
= !!CRegStdDWORD(_T("Software\\TortoiseGit\\DebugOutputString"), FALSE
);
68 ~CTraceToOutputDebugString()
75 static CTraceToOutputDebugString
* m_pInstance
;
77 // Non Unicode output helper
78 void TraceV(PCSTR pszFormat
, va_list args
) const
80 // Format the output buffer
82 _vsnprintf_s(szBuffer
, _countof(szBuffer
), _countof(szBuffer
)-1, pszFormat
, args
);
83 OutputDebugStringA(szBuffer
);
86 // Unicode output helper
87 void TraceV(PCWSTR pszFormat
, va_list args
) const
89 wchar_t szBuffer
[1024];
90 _vsnwprintf_s(szBuffer
, _countof(szBuffer
), _countof(szBuffer
)-1, pszFormat
, args
);
91 OutputDebugStringW(szBuffer
);
99 if (GetTickCount() - m_LastTick
> 10000)
101 m_LastTick
= GetTickCount();
102 m_bActive
= !!CRegStdDWORD(_T("Software\\TortoiseGit\\DebugOutputString"), FALSE
);