C++日志模块DLL,源码

时间:2019-08-11 10:48:21
【文件属性】:
文件名称:C++日志模块DLL,源码
文件大小:7KB
文件格式:RAR
更新时间:2019-08-11 10:48:21
C++ 日志模块 Dll QT版本 //xxxx.h //log level #define LL_DEBUG 0 #define LL_INFO 1 #define LL_WARN 2 #define LL_ERROR 3 #define LL_ALARM 4 #define GetCurFileName (__FILE__) #define GetCurCodeLine (__LINE__) #define GetCurCodeFunctionName (__FUNCTION__) #define Write_Log(LEVEL, FMTLOG) WriteLog(LEVEL, FMTLOG, GetCurFileName, GetCurCodeLine, GetCurCodeFunctionName) void WriteLog(int, QString, QString, int, QString); //xxxx.cpp void WriteLog(int loglevel, QString strlogstr, QString strfilename, int iline, QString strfunname) { QString g_logdllpath(g_runPath + "/dependences/LoggingModeDLL.dll"); HINSTANCE hDll = LoadLibrary(g_logdllpath.toStdWString().data()); typedef int (__cdecl *MYFUNC)(int, char*, char*, int, char*); MYFUNC execfunc = (MYFUNC)GetProcAddress(hDll, "WriteLog"); execfunc(loglevel, const_cast(strlogstr.toLatin1().data()), const_cast(strfilename.toLatin1().data()), iline, const_cast(strfunname.toLatin1().data())); } MFC 版本 //xxxx.h //log level #define LL_DEBUG 0 #define LL_INFO 1 #define LL_WARN 2 #define LL_ERROR 3 #define LL_ALARM 4 #define GetCurFileName (__FILE__) #define GetCurCodeLine (__LINE__) #define GetCurCodeFunctionName (__FUNCTION__) #define Write_Log(LEVEL, FMTLOG) WriteLog(LEVEL, FMTLOG, GetCurFileName, GetCurCodeLine, GetCurCodeFunctionName) void WriteLog(int, CString, CString, int, CString); void WriteLog(int loglevel, CString strlogstr, CString strfilename, int iline, CString strfunname) { CString g_logdllpath(".\\LoggingModeDLL.dll"); HINSTANCE hDll = LoadLibrary(g_logdllpath.GetBuffer()); typedef int (__cdecl *MYFUNC)(int, char*, char*, int, char*); MYFUNC execfunc = (MYFUNC)GetProcAddress(hDll, "WriteLog"); execfunc(loglevel, const_cast(strlogstr.GetBuffer()), const_cast(strfilename.GetBuffer()), iline, const_cast(strfunname.GetBuffer())); }
【文件预览】:
LoggingModal
----CMakeLists.txt(947B)
----UnitTest()
--------CmakeLists.txt(166B)
--------UnitTest.cpp(2KB)
----LogOpration()
--------LogOprationCpp()
--------LogOprationHeader()

网友评论