mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-23 03:10:04 +08:00
支持日志分天以及自动清理
This commit is contained in:
parent
2020e23437
commit
0007734bbb
@ -127,6 +127,14 @@ public:
|
|||||||
"日志等级,LTrace~LError(0~4)",/*该选项说明文字*/
|
"日志等级,LTrace~LError(0~4)",/*该选项说明文字*/
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
|
(*_parser) << Option('m',/*该选项简称,如果是\x00则说明无简称*/
|
||||||
|
"max_day",/*该选项全称,每个选项必须有全称;不得为null或空字符串*/
|
||||||
|
Option::ArgRequired,/*该选项后面必须跟值*/
|
||||||
|
"7",/*该选项默认值*/
|
||||||
|
false,/*该选项是否必须赋值,如果没有默认值且为ArgRequired时用户必须提供该参数否则将抛异常*/
|
||||||
|
"日志等级最多保存天数",/*该选项说明文字*/
|
||||||
|
nullptr);
|
||||||
|
|
||||||
(*_parser) << Option('c',/*该选项简称,如果是\x00则说明无简称*/
|
(*_parser) << Option('c',/*该选项简称,如果是\x00则说明无简称*/
|
||||||
"config",/*该选项全称,每个选项必须有全称;不得为null或空字符串*/
|
"config",/*该选项全称,每个选项必须有全称;不得为null或空字符串*/
|
||||||
Option::ArgRequired,/*该选项后面必须跟值*/
|
Option::ArgRequired,/*该选项后面必须跟值*/
|
||||||
@ -216,11 +224,10 @@ int main(int argc,char *argv[]) {
|
|||||||
|
|
||||||
//设置日志
|
//设置日志
|
||||||
Logger::Instance().add(std::make_shared<ConsoleChannel>("ConsoleChannel", logLevel));
|
Logger::Instance().add(std::make_shared<ConsoleChannel>("ConsoleChannel", logLevel));
|
||||||
#if defined(__linux__) || defined(__linux)
|
auto fileChannel = std::make_shared<FileChannel>("FileChannel", exeDir() + "log/", logLevel);
|
||||||
Logger::Instance().add(std::make_shared<SysLogChannel>("SysLogChannel",logLevel));
|
//日志最多保存天数
|
||||||
#else
|
fileChannel->setMaxDay(cmd_main["max_day"]);
|
||||||
Logger::Instance().add(std::make_shared<FileChannel>("FileChannel", exePath() + ".log", logLevel));
|
Logger::Instance().add(fileChannel);
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
if (bDaemon) {
|
if (bDaemon) {
|
||||||
|
Loading…
Reference in New Issue
Block a user