-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathNSWFL_Debug.H
58 lines (51 loc) · 2.38 KB
/
NSWFL_Debug.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
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright © NetworkDLS 2023, All rights reserved
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef _NSWFL_DEBUG_H_
#define _NSWFL_DEBUG_H_
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace NSWFL {
namespace Debug {
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifdef _DEBUG
#define Assert(sExpression, sMsg) \
if(sExpression)\
{ \
char sAssert[2048]; \
sprintf_s(sAssert, sizeof(sAssert), \
"A fatal error has occurred and the application must terminate.\r\n" \
"\tPlease take note of the following error message and conditions.\t\n\r\n" \
"Procedure: %s\r\n" \
"Source File: %s\r\n" \
"Build Date/Time: %s (%s)\r\n" \
"Expression: \"%s\"\r\n" \
"Line: %d\r\n\r\n" \
"%s", \
__FUNCTION__, __FILE__, __DATE__, __TIME__, #sExpression, __LINE__, sMsg); \
MessageBox(NULL, sAssert, "Fatal Application Error!", MB_ICONSTOP | MB_SYSTEMMODAL); \
}
#else
#define Assert(sExpression, sMsg)
#endif
typedef bool(*DebugConsoleHandler)(const char* sText, int iTextLength);
void RedirectIO(FILE* hFrom, HANDLE hTo);
bool OpenDebugConsole(const char* sTitle, DebugConsoleHandler pHandler);
bool OpenDebugConsole(const char* sTitle, DebugConsoleHandler pHandler, char* sInitialText);
void StartDebugConsoleHandler(DebugConsoleHandler pHandler);
bool OpenDebugConsole(const char* sTitle);
void DebugRedirectOutput(void);
void DebugRedirectInput(void);
void CloseDebugConsole(void);
typedef struct _tag_DEBUG_THREAD_DATA {
HANDLE hEvent;
DebugConsoleHandler Handler;
} _DEBUG_THREAD_DATA, * _LPDEBUG_THREAD_DATA;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
} //namespace::Debug
} //namespace::NSWFL
#endif