⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trace.h

📁 自己写的是用于所有VC开发平台和linux平台软件开发的trace功能函数。可自定module,evel, 系统时间开关
💻 H
字号:
#ifndef __TRACE_H__
#define __TRACE_H__

#define COMPILER_IS_VS2003 0

#define MAX_LOG_STR_LENGTH          512
#define MAX_SYSTEM_TIME_BUF_LENGTH  64
#define MAX_FUNC_NAME_LENGTH        32 

const unsigned long TRACE_LEVEL_ENTER_OPEN  = 0x00000001;
const unsigned long TRACE_LEVEL_RETURN_OPEN = 0x00000002;
const unsigned long TRACE_LEVEL_PARAM_OPEN  = 0x00000004;
const unsigned long TRACE_LEVEL_INFO_OPEN   = 0x00000008;
const unsigned long TRACE_LEVEL_DEBUG_OPEN[] =
{
  0x00000010,   // DEBUG1
  0x00000020,   // DEBUG2
  0x00000040,   // DEBUG3
  0x00000080,   // DEBUG4
  0x00000100,   // DEBUG5
  0x00000200,   // DEBUG6
  0x00000400,   // DEBUG7
  0x00000800,   // DEBUG8
  0x00001000,   // DEBUG9
};
const unsigned long TRACE_LEVEL_ERROR_OPEN  = 0x00002000;

const unsigned long TRACE_TO_FILE_ENTER_OPEN = 0x00000001;
const unsigned long TRACE_TO_FILE_RETURN_OPEN = 0x00000002;
const unsigned long TRACE_TO_FILE_PARAM_OPEN = 0x00000004;
const unsigned long TRACE_TO_FILE_INFO_OPEN = 0x00000008;
const unsigned long TRACE_TO_FILE_DEBUG_OPEN[]=
{
  0x00000010,   // DEBUG1
  0x00000020,   // DEBUG2
  0x00000040,   // DEBUG3
  0x00000080,   // DEBUG4
  0x00000100,   // DEBUG5
  0x00000200,   // DEBUG6
  0x00000400,   // DEBUG7
  0x00000800,   // DEBUG8
  0x00001000,   // DEBUG9	
};
const unsigned long TRACE_TO_FILE_ERROR_OPEN = 0x00002000;

void setTraceLevel(unsigned long traceLevelFlags);
void setTraceOutputMode(unsigned long traceOutputMode);
void setSystemTimeOn(unsigned long isSystemTimeOn);
void initTraceCfg(unsigned long traceOutputMode,unsigned long traceLevelFlags,unsigned long isSystemTimeOn);
void getSysTime(char systemTimeBuffer[MAX_SYSTEM_TIME_BUF_LENGTH]);
void LogOutput(char* logStr);
bool _Enter(const char*format,...);
bool _Return(const char*format,...);
bool _Param(const char*format,...);
bool _Info(const char*format,...);
bool _Debug(int level, const char* format,...);
bool _Error(const char*format,...);
char* getFuncName(char name[]);
int getLineNumber(int line);
char* getFileName(char file[]);

#define tEnter getFuncName(__FUNCTION__) != NULL && \
               getLineNumber(__LINE__) >= 0 && \
			   getFileName(__FILE__) != NULL && _Enter

#define tReturn getFuncName(__FUNCTION__) != NULL && \
	            getLineNumber(__LINE__) >= 0 && \
                getFileName(__FILE__) != NULL && _Return

#define tParam getFuncName(__FUNCTION__) != NULL && \
	           getLineNumber(__LINE__) >= 0 && \
               getFileName(__FILE__) != NULL && _Param

#define tInfo getFuncName(__FUNCTION__) != NULL && \
	          getLineNumber(__LINE__) >= 0 && \
              getFileName(__FILE__) != NULL && _Info

#define tDebug getFuncName(__FUNCTION__) != NULL && \
	           getLineNumber(__LINE__) >= 0 && \
               getFileName(__FILE__) != NULL && _Debug

#define tError getFuncName(__FUNCTION__) != NULL && \
	           getLineNumber(__LINE__) >= 0 && \
               getFileName(__FILE__) != NULL && _Error

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -