新增http、mqtt运行库,实现mqtt功能, 新增spdlog

This commit is contained in:
lixiaoyuan
2025-09-01 20:08:40 +08:00
parent e0b64a20c4
commit 94e467b65e
245 changed files with 54182 additions and 117 deletions

View File

@@ -3,7 +3,7 @@
#include <fstream>
#include "common/JsonN.h"
#include "Logger.h"
#include "common/Spdlogger.h"
#include "AppData.h"
AppOption Config::option;
@@ -14,10 +14,10 @@ bool Config::init(std::string filename)
bool ret = NJson::load(filename, jsonroot);
if (!ret)
{
XLOGE() << "[APP] load config failed, filename=" << filename;
spdlog::error("[config] load config file failed, filename={}", filename);
return false;
}
XLOGI() << "[APP] load config success, filename=" << filename;
spdlog::info("[config] load config file success, filename={}", filename);
if (jsonroot.contains("database"))
{
@@ -28,17 +28,20 @@ bool Config::init(std::string filename)
option.database.passwd = json.contains("passwd") ? json.at("passwd") : "";
option.database.dbname = json.contains("dbname") ? json.at("dbname") : "";
XLOGI() << "[APP] load database config end. host=" << option.database.host;
spdlog::info("[config] parse database success. host={}", option.database.host);
}
else
{
XLOGI() << "[APP] load database config error: not found. host=" << option.database.host;
spdlog::info("[config] parse database failed: not found. host={}", option.database.host);
}
if (jsonroot.contains("token"))
if (jsonroot.contains("http"))
{
std::string token = jsonroot["token"];
option.useToken = !token.empty();
NJsonNode json = jsonroot.at("http");
std:string token;
NJson::read(json, "token", token);
option.http.useToken = !token.empty();
NJson::read(json, "port", option.http.port);
}
return true;