ZLogger
ZLogger.hpp
//z 2014-07-15 16:43:51 L.169'26169 BG57IV3@XCL T1740119909.K.F1752546504[T1,L73,R1,V21]
//z 2014-07-15 16:43:51 L.169'26169 BG57IV3@XCL T1740119909.K.F1752546504[T1,L73,R1,V21]
#pragma once class ZLogger { public: //z gnu log level : DEBUG < INFO < WARN < TRACE < ERROR < ALERT < CRIT < FATAL < EMERG enum {kInfo,kWarning,kError}; public: static bool Log(LPCTSTR tszFormatString,...) { bool bReturn; va_list Arguments; va_start(Arguments, tszFormatString); bReturn = LogVA(kInfo,tszFormatString, Arguments); va_end(Arguments); return bReturn; } static bool Log(DWORD dwLogCode,LPCTSTR tszFormatString,...) { bool bReturn; va_list Arguments; va_start(Arguments, tszFormatString); bReturn = LogVA(dwLogCode,tszFormatString, Arguments); va_end(Arguments); return bReturn; } private: static bool LogVA(LPCTSTR tszFormatString, va_list Arguments) { return LogVA(kInfo, tszFormatString, Arguments); } static bool LogVA(DWORD dwLogCode,LPCTSTR tszFormatString, va_list Arguments) { TCHAR logMessage[LOG_LENGTH] = {0}; int nLevelLength = _snwprintf_s(logMessage,LOG_LENGTH,_TRUNCATE,_T("%s"),GetLogLevelDesc(dwLogCode)); int nLogLength = _vsnwprintf_s(logMessage+nLevelLength, LOG_LENGTH-nLevelLength, _TRUNCATE, tszFormatString, Arguments); //z exceed LOG_LENGTH if (nLogLength == -1) { } return true; } static LPCTSTR GetLogLevelDesc(DWORD dwLogCode) { switch (dwLogCode) { case kInfo: return _T("Info : "); break; case kWarning: return _T("Warning : "); break; case kError: return _T("Error : "); break; default: return _T("Other : "); } } static const int LOG_LENGTH=16; private: ZLogger(void){} ~ZLogger(void){} };//z 2014-07-15 16:43:51 L.169'26169 BG57IV3@XCL T1740119909.K.F1752546504[T1,L73,R1,V21]
//z 2014-07-18 15:34:40 L.166'30320 BG57IV3@XCL T3674969394.K.F2855961942[T9,L155,R6,V109] class RAK_DLL_EXPORT PacketFileLogger : public PacketLogger { public: PacketFileLogger(); virtual ~PacketFileLogger(); void StartLog(const char *filenamePrefix); virtual void WriteLog(const char *str); protected: FILE *packetLogFile; }; PacketFileLogger::PacketFileLogger() { packetLogFile=0; } PacketFileLogger::~PacketFileLogger() { if (packetLogFile) { fflush(packetLogFile); fclose(packetLogFile); } } void PacketFileLogger::StartLog(const char *filenamePrefix) { // Open file for writing char filename[256]; if (filenamePrefix) sprintf(filename, "%s_%i.csv", filenamePrefix, (int) RakNet::GetTimeMS()); else sprintf(filename, "PacketLog_%i.csv", (int) RakNet::GetTimeMS()); packetLogFile = fopen(filename, "wt"); LogHeader(); if (packetLogFile) { fflush(packetLogFile); } } void PacketFileLogger::WriteLog(const char *str) { if (packetLogFile) { fprintf(packetLogFile, "%s\n", str); fflush(packetLogFile); } }
static const char __func__[] = "function-name ";
@IS2120#CNBLOGS.T2169364049[T1,L65,R1,V259]:备忘
$ € ₤ ₭ ₪ ₩ ₮ ₦ ₱ ฿ ₡ ₫ ﷼ ¥ ﷼ ₫ ₡ ฿ ₱ ₦ ₮ ₩ ₪ ₭ ₤ € $