Commit 36107efe by ZhongJianfu

update:日志超限备份

parent 49ac57da
#include "my_easylogging.h"
// #include <ctime>
#include <ctime>
using namespace std;
INT32 G_LOG_ENABLE = 0; //调试中的变量,写0就好了。写1则开启相应打印
......@@ -46,7 +46,10 @@ void rolloutHandler(const char *filename, std::size_t size)
{
/// 备份日志
static unsigned int idx;
time_t nowtime;
struct tm *p;
time(&nowtime);
p = localtime(&nowtime);
#if defined(_WIN32)
cout << "###########LOG SIZE FULL#############" << endl;
std::stringstream ss;
......@@ -56,11 +59,14 @@ void rolloutHandler(const char *filename, std::size_t size)
replace(cc.begin(), cc.end(), '/', '\\');
system(cc.c_str());
#else
/*下面这段没有测试过 需要优化*/
/*下面这段 需要优化*/
// system("mkdir bin");
std::stringstream ss;
std::time_t t = std::time(0); // t is an integer type
ss << "mv "
<< filename << " ./log/log_backup_" << ++idx;
<< filename << " ./log/log_backup_" << ++idx << "_" << p->tm_year << p->tm_mon << p->tm_mday << ".log";
system(ss.str().c_str());
#endif
}
......
......@@ -4,7 +4,7 @@
TO_FILE = true
TO_STANDARD_OUTPUT = false
PERFORMANCE_TRACKING = false
MAX_LOG_FILE_SIZE = 1
MAX_LOG_FILE_SIZE = 209715200
FILENAME = "./log/info_%datetime{%Y%M%d}.log"
* INFO:
......
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