From 0007734bbb533d7b69d082c3bf7c907513143908 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Tue, 6 Aug 2019 22:51:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=97=A5=E5=BF=97=E5=88=86?= =?UTF-8?q?=E5=A4=A9=E4=BB=A5=E5=8F=8A=E8=87=AA=E5=8A=A8=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/main.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/server/main.cpp b/server/main.cpp index e796d065..d3d4c27f 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -127,6 +127,14 @@ public: "日志等级,LTrace~LError(0~4)",/*该选项说明文字*/ nullptr); + (*_parser) << Option('m',/*该选项简称,如果是\x00则说明无简称*/ + "max_day",/*该选项全称,每个选项必须有全称;不得为null或空字符串*/ + Option::ArgRequired,/*该选项后面必须跟值*/ + "7",/*该选项默认值*/ + false,/*该选项是否必须赋值,如果没有默认值且为ArgRequired时用户必须提供该参数否则将抛异常*/ + "日志等级最多保存天数",/*该选项说明文字*/ + nullptr); + (*_parser) << Option('c',/*该选项简称,如果是\x00则说明无简称*/ "config",/*该选项全称,每个选项必须有全称;不得为null或空字符串*/ Option::ArgRequired,/*该选项后面必须跟值*/ @@ -216,11 +224,10 @@ int main(int argc,char *argv[]) { //设置日志 Logger::Instance().add(std::make_shared("ConsoleChannel", logLevel)); -#if defined(__linux__) || defined(__linux) - Logger::Instance().add(std::make_shared("SysLogChannel",logLevel)); -#else - Logger::Instance().add(std::make_shared("FileChannel", exePath() + ".log", logLevel)); -#endif + auto fileChannel = std::make_shared("FileChannel", exeDir() + "log/", logLevel); + //日志最多保存天数 + fileChannel->setMaxDay(cmd_main["max_day"]); + Logger::Instance().add(fileChannel); #if !defined(_WIN32) if (bDaemon) {