Initial commit
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
#ifndef DebugH
|
||||
#define DebugH
|
||||
|
||||
#ifdef _DEBUG_CPP_
|
||||
int g_nDebugFlag=0xFFFF;
|
||||
#else
|
||||
extern int g_nDebugFlag;
|
||||
#endif
|
||||
|
||||
enum EDPrintDest{
|
||||
e_NoDest,
|
||||
e_ToFile,
|
||||
e_ToNet,
|
||||
e_ToScreen,
|
||||
e_ToDebug
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DEBUG_FILE "ComposeServiceLog.txt"
|
||||
#define DEBUG_HOST "127.0.0.1"
|
||||
#define DEBUG_TCPPORT 2510
|
||||
#define MAX_DEBUG_PRINT 10240
|
||||
|
||||
/*Debug代码*/
|
||||
int DebugPrint(const char *fmt,...);
|
||||
void DebugModuleInitialize(int nDebug,EDPrintDest nDest,char *sHost=DEBUG_HOST);
|
||||
void DebugModuleClose();
|
||||
void GetDebugParams( int &nDebug, EDPrintDest &nDest, void **pChan );
|
||||
long GetMemoryUsage();
|
||||
void CheckMemoryUsage(int iParam=0);
|
||||
|
||||
#ifdef _WIN32
|
||||
void DllDebugModuleClose();
|
||||
void __declspec(dllexport) DllDebugModuleInitialize(int nDebug,EDPrintDest nDest,void* pChannel);
|
||||
typedef void (*PFDLLDEBUGINITIALIZE)(int nDebug,EDPrintDest nDest,void* pChannel);
|
||||
#endif
|
||||
|
||||
/*条件判断语句*/
|
||||
#define DEBUG_COMMON 0x0001
|
||||
#define DEBUG_CLIENTAPP 0x0002
|
||||
#define DEBUG_SYSMANAGER 0x0004
|
||||
#define DEBUG_CLIENTMANAGER 0x0008
|
||||
#define DEBUG_NODEMANAGER 0x0010
|
||||
#define DEBUG_CONFMANAGER 0x0020
|
||||
#define DEBUG_CONFCONTROL 0x0080
|
||||
#define DEBUG_GATEKEEPER 0x0100
|
||||
#define DEBUG_MCUSTACK 0x0200
|
||||
#define DEBUG_NETMANAGER 0x0400
|
||||
#define DEBUG_CONNECTION 0x0040
|
||||
|
||||
#define IF_DEBUGOUT(f) if (g_nDebugFlag & (f))
|
||||
#define IF_DEBUG_COMMON(A) IF_DEBUGOUT(DEBUG_COMMON) {A;};
|
||||
#define IF_DEBUG_CLIENTAPP(A) IF_DEBUGOUT(DEBUG_CLIENTAPP) {A;};
|
||||
#define IF_DEBUG_SYSMANAGER(A) IF_DEBUGOUT(DEBUG_SYSMANAGER) {A;};
|
||||
#define IF_DEBUG_CLIENTMANAGER(A) IF_DEBUGOUT()DEBUG_CLIENTMANAGER {A;};
|
||||
#define IF_DEBUG_NODEMANAGER(A) IF_DEBUGOUT(DEBUG_NODEMANAGER) {A;};
|
||||
#define IF_DEBUG_CONFMANAGER(A) IF_DEBUGOUT(DEBUG_CONFMANAGER) {A;};
|
||||
#define IF_DEBUG_CONFCONTROL(A) IF_DEBUGOUT(DEBUG_CONFCONTROL) {A;};
|
||||
#define IF_DEBUG_GATEKEEPER(A) IF_DEBUGOUT(DEBUG_GATEKEEPER) {A;};
|
||||
#define IF_DEBUG_MCUSTACK(A) IF_DEBUGOUT(DEBUG_MCUSTACK) {A;};
|
||||
#define IF_DEBUG_NETMANAGER(A) IF_DEBUGOUT(DEBUG_NETMANAGER) {A;};
|
||||
#define IF_DEBUG_CONNECTION(A) IF_DEBUGOUT(DEBUG_CONNECTION) {A;}
|
||||
|
||||
/*跟踪消息的编号相关定义*/
|
||||
#define TRACE_NUMBER(nMajor,nGrade) (nMajor<<10)|(nGrade)
|
||||
#define TRACE_MAJOR(nType) (nType>>10)
|
||||
#define TRACE_GRADE(nType) (nType&0x03)
|
||||
|
||||
enum ETraceMajorType{ // 出错的模块编号
|
||||
e_Trace_Common=0x1, // 公共部分
|
||||
e_Trace_ClientApp, // 客户端程序
|
||||
e_Trace_SysManager, // 系统管理
|
||||
e_Trace_ClientManager, // 客户端管理
|
||||
e_Trace_NodeManager, // 节点管理
|
||||
e_Trace_ConfManager, // 会议管理
|
||||
e_Trace_TemplateManager, // 模板管理
|
||||
e_Trace_ConfControl, // 会议控制
|
||||
e_Trace_GateKeeper, // Gatekeeper
|
||||
e_Trace_MCUStack, // MCU协议栈
|
||||
e_Trace_NetManager // 网络管理
|
||||
};
|
||||
|
||||
enum ETraceGrade{ // 错误等级
|
||||
e_Trace_Severe, // 严重的错误可能引起异常
|
||||
e_Trace_Major, // 断言出错,值得关注
|
||||
e_Trace_Normal // 一般跟踪消息
|
||||
};
|
||||
|
||||
/*****************************************
|
||||
// Debug接口的用法示例
|
||||
//
|
||||
IF_DEBUG_COMMON(DebugPrint("%X:In %s Line %d 用来建立连接的地址非法\n",
|
||||
TRACE_NUMBER(e_Trace_Common,e_Trace_Major),
|
||||
__FILE__,__LINE__))
|
||||
*****************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // DebugH
|
||||
Reference in New Issue
Block a user