pPowerManger 网页日志监控指向实际日志文件:HttpServer 新增 setLogFilePath,OnStartUp 与 loguru 共用同一路径(修复 systemd 工作目录下相对路径打开失败)
This commit is contained in:
@@ -246,6 +246,9 @@ bool PowerManger::OnStartUp()
|
||||
loguru::add_file(logPath.c_str(), loguru::Append, loguru::Verbosity_MAX);
|
||||
LOG_F(INFO, "日志文件路径: %s", logPath.c_str());
|
||||
|
||||
// 网页日志监控使用同一文件(默认相对路径在 systemd WorkingDirectory 下打不开)
|
||||
if (m_httpServer) m_httpServer->setLogFilePath(logPath);
|
||||
|
||||
// 初始化数据库:dbpath 未配置则默认当前目录
|
||||
if (dbPath.empty()) dbPath = "power_data.db";
|
||||
LOG_F(INFO, "数据库存储路径: %s", dbPath.c_str());
|
||||
|
||||
@@ -86,6 +86,11 @@ private:
|
||||
static const size_t MAX_CACHE_SIZE = 1000; // 最大缓存条数
|
||||
static const size_t MAX_WS_BACKLOG = 256 * 1024; // WebSocket发送积压阈值,超过则跳过推送
|
||||
|
||||
public:
|
||||
// 设置被监控的日志文件路径(须与 logpath 配置一致;
|
||||
// 默认相对路径在 systemd WorkingDirectory 下会打开失败)
|
||||
void setLogFilePath(const std::string& path) { m_logFilePath = path; }
|
||||
|
||||
};
|
||||
|
||||
#endif // HTTP_SERVER_H
|
||||
|
||||
Reference in New Issue
Block a user