mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
新增http、mqtt运行库,实现mqtt功能, 新增spdlog
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user