extern_interface/logqueueconfig/log.cpp

43 lines
1.3 KiB
C++
Executable File

#include "log.h"
namespace QUEUE_LOG_COFIG
{
void* WriteLogThread(void* param)
{
CLogFile* pLog = (CLogFile*)(param);
pLog->writeQueue2File();//
}
}
using namespace QUEUE_LOG_COFIG;
typedef void* voidPtr;
//--------------------------------------------------------------------------------------------------------------
extern "C" voidPtr __attribute__((visibility("default"))) OpenLogFile(const char* strPath, const char* strFileName, bool bLogByDay)
{
//CLogFile* p = new CLogFile(strPath, strFileName, bLogByDay, 1);//use queue
CLogFile* p = new CLogFile(strPath, strFileName, false, 1);//use queue 2021.11.09
return (voidPtr)p;
}
//-----------------------------------------------------------------------------------------------------------------
extern "C" int __attribute__((visibility("default"))) WriteLog(void* pLogFile, const char* fmt, ...)
{
if (!pLogFile)
return -1;
char strInfo[INFO_BUF_LEN];
va_list arglist;
va_start(arglist, fmt);
vsprintf(strInfo, fmt, arglist);
va_end(arglist);
((CLogFile*)pLogFile)->append_one_item(0, strInfo);
return 0;
}
//-----------------------------------------------------------------------------------------------------------------
extern "C" void __attribute__((visibility("default"))) CloseLog(void* pLogFile)
{
((CLogFile*)pLogFile)->close_log_file();
return;
}