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

📄 logger.h

📁 三字经输入法源码
💻 H
字号:
/*********************************************************************************
**********************************************************************************
***
***  MODULE NAME	BSIPLogger.h
***
***  PROJECT		BattleSIP
***
***  DESCRIPTION	BSIPLogger includes a few macros that can be used to record 
***                 information of interest to the user. Log file is stored to 
***                 c:\Logs\BattleShip\debug.log. 
***
***					EXAMPLES:
***					#ifdef __DEBUGLOGGER__
***						//Writes 'Some text' to the log
***						WRITE_LOG(_L("Some text"));
***					#endif __DEBUGLOGGER__
***					
***					#ifdef __DEBUGLOGGER__
***						//Writes formated text to the log
***						TInt num1=100;
***						WRITE_LOG_FORMAT(_L("Writing a number to the log: %d"), num1);
***					#endif __DEBUGLOGGER__
***					
***					#ifdef __DEBUGLOGGER__
***						// Line begins with time only
***						SET_LOG_DATE_TIME( EFalse, ETrue);		
***					#endif __DEBUGLOGGER__
***					
***					#ifdef __DEBUGLOGGER__
***						WRITE_LOG(_L8("HexDump Test"));
***						const TText* hdr=_S("123456");
***						const TText* mgn=_S("      ");
***						const TUint8* ptr=_S8("abcdefghijklmnopqrstuxyz");
***						TInt len=26;
***						LOG_HEX_DUMP(hdr,mgn,ptr,len);
***					#endif __DEBUGLOGGER__
***
***
***
***
***  Version history
***  -----------------------------------------------------------------------------
***  Version Date			Author  Description
***
***  1.4	 27/FEB/2003	HAR     Config file BattleShipConf.h taken in use.
***  0.1	 03/JAN/2003	AHO     First draft
***
**********************************************************************************
*********************************************************************************/


//#define __DEBUGLOGGER__
#ifdef __DEBUGLOGGER__
#include <flogger.h>
_LIT(KDebugLogFileFullPath,"C:\\Logs\\hanease\\fep.log");

// log files are stored to KDebugLogDirFull folder
_LIT(KDebugLogDirFull,"C:\\Logs\\hanease\\");
_LIT(KDebugLogDir,"hanease");
_LIT(KDebugLogFileName,"fep.log");

#endif

#ifdef __DEBUGLOGGER__
#define INIT_LOGGER() CCoeEnv::Static()->FsSession().MkDirAll(KDebugLogDirFull);\
	                  CCoeEnv::Static()->FsSession().Delete(KDebugLogFileFullPath)
#else
#define INIT_LOGGER()
#endif
	
#ifdef __DEBUGLOGGER__
#define WRITE_LOG(AAA) RFileLogger::Write(KDebugLogDir,KDebugLogFileName,EFileLoggingModeAppend,AAA)
#else
#define WRITE_LOG(AAA)
#endif

#ifdef __DEBUGLOGGER__
#define WRITE_LOG_FORMAT(AAA,BBB) RFileLogger::WriteFormat(KDebugLogDir,KDebugLogFileName,EFileLoggingModeAppend,AAA,BBB)
#else
#define WRITE_LOG_FORMAT(AAA,BBB)
#endif

#ifdef __DEBUGLOGGER__
#define WRITE_LOG_DESC8(AAA) do{\
									TUint8 debugtemplogbuf[64];TInt debugtempoffset = 0;\
									while(AAA.Length()>debugtempoffset)\
										{\
										Mem::FillZ(debugtemplogbuf, 64);\
										Mem::Copy(debugtemplogbuf, AAA.Ptr() + debugtempoffset, 63>(AAA.Length()-debugtempoffset)?(AAA.Length()-debugtempoffset):63);\
										debugtempoffset += 63;\
										RFileLogger::WriteFormat(KDebugLogDir,KDebugLogFileName,EFileLoggingModeAppend,_L8("%s"),debugtemplogbuf);\
										}\
									}while(0)
#else
#define WRITE_LOG_DESC8(AAA)
#endif

#ifdef __DEBUGLOGGER__
#define WRITE_LOG_DESC(AAA) 	do{\
									TUint8 debugtemplogbuf[65];TInt debugtempoffset = 0;\
									while(AAA.Length()>debugtempoffset)\
										{\
										Mem::FillZ(debugtemplogbuf, 65);\
										Mem::Copy(debugtemplogbuf, AAA.Ptr() + debugtempoffset, 64>((AAA.Length()<<1)-debugtempoffset)?((AAA.Length()<<1)-debugtempoffset):64);\
										debugtempoffset += 64;\
										RFileLogger::WriteFormat(KDebugLogDir,KDebugLogFileName,EFileLoggingModeAppend,_L("%s"),debugtemplogbuf);\
										}\
									}while(0)
#else
#define WRITE_LOG_DESC(AAA)
#endif

#ifdef __DEBUGLOGGER__
#define WRITE_LOG_FORMAT2(AAA,BBB,CCC) RFileLogger::WriteFormat(KDebugLogDir,KDebugLogFileName,EFileLoggingModeAppend,AAA,BBB,CCC)
#else
#define WRITE_LOG_FORMAT2(AAA,BBB,CCC)
#endif

#ifdef __DEBUGLOGGER__
#define SET_LOG_DATE_TIME(AAA,BBB) RFileLogger::SetDateAndTime(KDebugLogDir,KDebugLogFileName,EFileLoggingModeAppend,AAA,BBB)
#else
#define SET_LOG_DATE_TIME(AAA,BBB)
#endif

#ifdef __DEBUGLOGGER__
// Gets the total number of cells allocated on the current thread's heap into a variable
#define ALLOCATED_CELLS(AAA) {AAA=User::CountAllocCells();};
#else
#define ALLOCATED_CELLS(AAA)
#endif

#ifdef __DEBUGLOGGER__
// Gets the allocated memory in bytes into a variable
#define ALLOCATED_SIZE(AAA) {User::AllocSize(AAA);};
#else
#define ALLOCATED_SIZE(AAA)
#endif

#ifdef __DEBUGLOGGER__
// Writes the total number of cells allocated on the current threads's heap to the log
#define WRITE_ALLOCATED_CELLS() (WRITE_LOG_FORMAT(KCountAllocCells,User::CountAllocCells()));
#else
#define WRITE_ALLOCATED_CELLS()
#endif

#ifdef __DEBUGLOGGER__
// Writes the allocated memory in bytes to the log
#define WRITE_ALLOCATED_SIZE() {TInt bytes; User::AllocSize(bytes); WRITE_LOG_FORMAT(KBytes,bytes);};
#else
#define WRITE_ALLOCATED_SIZE()
#endif

#ifdef __DEBUGLOGGER__
#define LOG_HEX_DUMP(AAA,BBB,CCC,DDD) RFileLogger::HexDump(KDebugLogDir,KDebugLogFileName,EFileLoggingModeAppend,AAA,BBB,CCC,DDD)
#else
#define LOG_HEX_DUMP(AAA,BBB,CCC,DDD)
#endif

#ifdef __DEBUGLOGGER__

class CMethodInOutLogger: public CBase
{
public:
	inline CMethodInOutLogger(TPtrC aMethod);
	inline ~CMethodInOutLogger();
private:
	TPtrC iMethod;
};

inline CMethodInOutLogger::CMethodInOutLogger(TPtrC aMethod)
: iMethod(aMethod)
{
	WRITE_LOG(KNullDesC);
	WRITE_LOG_FORMAT(_L(">>>%S"),&iMethod);
}

inline CMethodInOutLogger::~CMethodInOutLogger()
{
	WRITE_LOG_FORMAT(_L("<<<%S"),&iMethod);
	WRITE_LOG(KNullDesC);
}


#define LOG_METHOD(AAA) CMethodInOutLogger logger(AAA)
#else
#define LOG_METHOD(AAA)
#endif

⌨️ 快捷键说明

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