日志:日志文件路径支持 mission 配置 logpath
- 移除 main.cpp 中硬编码的 pPowerManger.log - OnStartUp 读取 logpath 配置后调用 loguru::add_file - 不配置则默认当前目录 pPowerManger.log,板上配置为 h100/data 目录
This commit is contained in:
@@ -184,6 +184,7 @@ bool PowerManger::OnStartUp()
|
||||
reportConfigWarning("No config block found for " + GetAppName());
|
||||
|
||||
std::string dbPath; // 数据库路径,不配置则默认当前目录 power_data.db
|
||||
std::string logPath; // 日志文件路径,不配置则默认当前目录 pPowerManger.log
|
||||
|
||||
STRING_LIST::iterator p;
|
||||
for(p=sParams.begin(); p!=sParams.end(); p++) {
|
||||
@@ -203,6 +204,10 @@ bool PowerManger::OnStartUp()
|
||||
dbPath = value;
|
||||
handled = true;
|
||||
}
|
||||
else if(param == "logpath") {
|
||||
logPath = value;
|
||||
handled = true;
|
||||
}
|
||||
|
||||
if(!handled)
|
||||
reportUnhandledConfigWarning(orig);
|
||||
@@ -211,6 +216,11 @@ bool PowerManger::OnStartUp()
|
||||
|
||||
registerVariables();
|
||||
|
||||
// 初始化日志文件:logpath 未配置则默认当前目录
|
||||
if (logPath.empty()) logPath = "pPowerManger.log";
|
||||
loguru::add_file(logPath.c_str(), loguru::Append, loguru::Verbosity_MAX);
|
||||
LOG_F(INFO, "日志文件路径: %s", logPath.c_str());
|
||||
|
||||
// 初始化数据库:dbpath 未配置则默认当前目录
|
||||
if (dbPath.empty()) dbPath = "power_data.db";
|
||||
LOG_F(INFO, "数据库存储路径: %s", dbPath.c_str());
|
||||
|
||||
Reference in New Issue
Block a user