Commit 3831966b by guanghui.cui

日志文件:回滚日志前,把日志备份

parent aaef36b8
......@@ -33,21 +33,28 @@ INITIALIZE_EASYLOGGINGPP
//IOperation *dbOperation; //订单相关操作类
void app_stopped(int sig); //SIGINT(Ctrl + C)
void logRolloutHandler(const char* filename, std::size_t size)
{
/// 备份日志
std::string strLogPath = GetProcDir();
strLogPath.append(filename);
std::stringstream ss;
ss << "mv " << strLogPath.data() << " "<<strLogPath.data()<<"_bk";
system(ss.str().c_str());
}
int main()
{
/*HANDLE hObject = CreateMutex(NULL,FALSE,L"FmSingleMonitorConsole");
if(GetLastError() == ERROR_ALREADY_EXISTS)
{
CloseHandle(hObject);
MessageBox(NULL,L"程序已经运行!",NULL,NULL);
return FALSE;
}*/
el::Loggers::addFlag(el::LoggingFlag::StrictLogFileSizeCheck);
std::string strLogPath = GetProcDir();
strLogPath.append("log.conf");
el::Configurations conf(strLogPath.data());
/// 设置全部logger的配置
el::Loggers::reconfigureAllLoggers(conf);
/// 注册回调函数
el::Helpers::installPreRollOutCallback(logRolloutHandler);
InitSystem();
......@@ -193,6 +200,9 @@ int main()
//关闭socket
close(sockfd);
}
/// 注销回调函数
el::Helpers::uninstallPreRollOutCallback();
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment