-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbg.h
114 lines (79 loc) · 1.93 KB
/
dbg.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
* Copyright (c) 1998-2000 by KVA Software
* All rights reserved.
*
* File: dbg.h
* Contents: CDebugPrintf class definition
* Author: Vladimir Kirienko
*
* http://www.uran.net/kva
*/
#ifndef ______DBG_H______
#define ______DBG_H______
//#define USE_STL
#undef USE_STL
//#define USE_MFC
#undef USE_MFC
#undef USE_DEBUG_PRINTF
#if defined(_DEBUG) || defined(DEBUG_PRINTF)
#define USE_DEBUG_PRINTF
#endif
#ifdef USE_DEBUG_PRINTF
#ifdef USE_STL
#include <string>
using namespace std;
#endif
/*
* Macro definitions
*
*/
#define IFDEBUG( doit ) doit
#define PRINTF debug.printf
#define SHOWCONSOLE debug.ShowConsole();
#define HIDECONSOLE debug.HideConsole();
#define SHOW_ERROR debug.DisplayLastError();
#define CLOSE_LOG debug.CloseLog();
/*-----------------------------------------------------------------------
* Class : CDebugPrintf
* Prototype : class CDebugPrintf
* Description :
* Parent class :
* History :
*/
class CDebugPrintf
{
public:
CDebugPrintf();
~CDebugPrintf();
void printf( const char *fmt, ... );
#ifdef USE_STL
void printf( string& str ) { printf( str.c_str() ); }
void printf( string* str ) { printf( str->c_str() ); }
#endif
#ifdef USE_MFC
void printf( CString& str ) { printf( str.GetBuffer(1024) ); }
#endif
void CloseLog();
void ShowConsole();
void HideConsole();
void DisplayLastError();
private:
HANDLE m_hFile; // log-file handle
HANDLE m_hDebugMutex; //
CRITICAL_SECTION m_hLock; // lock for thread-safe access
DWORD m_dwStartTime; // application start time
bool m_bUseConsole; // use or not log-console with log-file
};
extern CDebugPrintf debug;
#else
#define IFDEBUG( doit )
#define SLASH /
#define COMMENT ;SLASH/
#define PRINTF COMMENT
#define SHOWCONSOLE COMMENT
#define HIDECONSOLE COMMENT
#define ERROR_MSG COMMENT
#define CLOSE_LOG COMMENT
#endif
#endif