提交 1f1cb63f authored 作者: blu's avatar blu

big refacting of communitation architect

上级 3d6a7e11
...@@ -213,7 +213,7 @@ int saveLocalConfigration(json &config, string fileName) ...@@ -213,7 +213,7 @@ int saveLocalConfigration(json &config, string fileName)
std::ofstream o(fileName); std::ofstream o(fileName);
o << std::setw(4) << config << std::endl; o << std::setw(4) << config << std::endl;
}catch(exception &e) { }catch(exception &e) {
spdlog::error("saveLocalConfigration failed to write configuration to file {}: {}\n{}", fileName, e.what(), config.dump(4)); spdlog::error("saveLocalConfigration failed to write configuration to file {}: {}\n{}", fileName, e.what(), config.dump());
return -2; return -2;
} }
......
...@@ -138,7 +138,7 @@ namespace LVDB { ...@@ -138,7 +138,7 @@ namespace LVDB {
ret = cb(modname, m, pUser); ret = cb(modname, m, pUser);
cnt++; cnt++;
if(ret <0) { if(ret <0) {
spdlog::error("failed to traverse and callback config on module: {}", m.dump(4)); spdlog::error("failed to traverse and callback config on module: {}", m.dump());
return ret; return ret;
} }
} }
...@@ -151,7 +151,7 @@ namespace LVDB { ...@@ -151,7 +151,7 @@ namespace LVDB {
ret = cb(mn,m, pUser); ret = cb(mn,m, pUser);
cnt++; cnt++;
if(ret <0) { if(ret <0) {
spdlog::error("failed to traverse and callback config on module: {}", m.dump(4)); spdlog::error("failed to traverse and callback config on module: {}", m.dump());
return ret; return ret;
} }
} }
...@@ -340,7 +340,7 @@ togo_end: ...@@ -340,7 +340,7 @@ togo_end:
} }
} }
ret = setValue(value.dump(4), key,fileName, NULL); ret = setValue(value.dump(), key,fileName, NULL);
return ret; return ret;
} }
...@@ -366,7 +366,7 @@ togo_end: ...@@ -366,7 +366,7 @@ togo_end:
// {"sn":string, "updatetime": string, "lastboot": string} // {"sn":string, "updatetime": string, "lastboot": string}
int _validateSn(const json &info) { int _validateSn(const json &info) {
if(info.count("sn") == 0 || info["sn"].size() == 0) { if(info.count("sn") == 0 || info["sn"].size() == 0) {
spdlog::error("invalid sn config:{}", info.dump(4)); spdlog::error("invalid sn config:{}", info.dump());
return -1; return -1;
} }
......
...@@ -80,7 +80,7 @@ private: ...@@ -80,7 +80,7 @@ private:
json deltaCfg = json(); json deltaCfg = json();
if(newConfig.count("data") == 0 || newConfig["data"].size() == 0) { if(newConfig.count("data") == 0 || newConfig["data"].size() == 0) {
ret["code"] = 1; ret["code"] = 1;
ret["msg"] = "evcloudsvc invalid config body received: " + newConfig.dump(4); ret["msg"] = "evcloudsvc invalid config body received: " + newConfig.dump();
spdlog::error(ret["msg"].get<string>()); spdlog::error(ret["msg"].get<string>());
} }
else { else {
...@@ -153,7 +153,7 @@ private: ...@@ -153,7 +153,7 @@ private:
this->configMap["mod2mgr"][modKey] = k; this->configMap["mod2mgr"][modKey] = k;
} }
else { else {
string msg = "evcloudsvc invalid config: " + data.dump(4);; string msg = "evcloudsvc invalid config: " + data.dump();;
ret["code"] = -1; ret["code"] = -1;
ret["msg"] = msg; ret["msg"] = msg;
spdlog::error(msg); spdlog::error(msg);
...@@ -179,7 +179,7 @@ private: ...@@ -179,7 +179,7 @@ private:
//save //save
iret = LVDB::setLocalConfig(v, k); iret = LVDB::setLocalConfig(v, k);
if(iret < 0) { if(iret < 0) {
string msg = "failed to save config " + k + " -> " + v.dump(4); string msg = "failed to save config " + k + " -> " + v.dump();
spdlog::error(msg); spdlog::error(msg);
ret["code"] = iret; ret["code"] = iret;
ret["msg"] = msg; ret["msg"] = msg;
......
...@@ -110,7 +110,7 @@ class EvDaemon{ ...@@ -110,7 +110,7 @@ class EvDaemon{
} }
// startup other submodules // startup other submodules
spdlog::info("dump: {}", v.dump(4)); spdlog::info("dump: {}", v.dump());
json &ipcs = v["ipcs"]; json &ipcs = v["ipcs"];
for(auto &ipc : ipcs) { for(auto &ipc : ipcs) {
json &modules = ipc["modules"]; json &modules = ipc["modules"];
...@@ -222,7 +222,7 @@ class EvDaemon{ ...@@ -222,7 +222,7 @@ class EvDaemon{
json *cfg = cfgutils::findModuleConfig(peerId, jret["data"]); json *cfg = cfgutils::findModuleConfig(peerId, jret["data"]);
json diff = json::diff(this->config, jret["data"]); json diff = json::diff(this->config, jret["data"]);
// TODO: // TODO:
spdlog::info("evdaemon {} config diff: {}", devSn, diff.dump(4)); spdlog::info("evdaemon {} config diff: {}", devSn, diff.dump());
if(cfg == NULL) { if(cfg == NULL) {
spdlog::error("evdaemon failed to find module {} in config {}", peerId, jret["data"].dump()); spdlog::error("evdaemon failed to find module {} in config {}", peerId, jret["data"].dump());
...@@ -415,7 +415,7 @@ class EvDaemon{ ...@@ -415,7 +415,7 @@ class EvDaemon{
// its configuration message // its configuration message
if(meta == EV_MSG_META_CONFIG) { if(meta == EV_MSG_META_CONFIG) {
if(data.size() == 0) { if(data.size() == 0) {
spdlog::error("evdaemon {} received invalid empty config"); spdlog::error("evdaemon {} received invalid empty config", devSn);
}else{ }else{
json diff = json::diff(this->config, data); json diff = json::diff(this->config, data);
if(diff.size() != 0) { if(diff.size() != 0) {
...@@ -424,7 +424,7 @@ class EvDaemon{ ...@@ -424,7 +424,7 @@ class EvDaemon{
spdlog::info("evdaemon {} received cloud config diff. origin:\n{}\nnew\n{}", devSn, this->config.dump(), data.dump()); spdlog::info("evdaemon {} received cloud config diff. origin:\n{}\nnew\n{}", devSn, this->config.dump(), data.dump());
// TODO: detailed diff on submodules // TODO: detailed diff on submodules
}else{ }else{
spdlog::info("evdaemon {} received same configuration and ignored: {}", data.dump()); spdlog::info("evdaemon {} received same configuration and ignored: {}", devSn, data.dump());
} }
} }
} }
...@@ -486,7 +486,7 @@ class EvDaemon{ ...@@ -486,7 +486,7 @@ class EvDaemon{
newConfig["data"] = json::parse(req.body)["data"]; newConfig["data"] = json::parse(req.body)["data"];
LVDB::setLocalConfig(newConfig); LVDB::setLocalConfig(newConfig);
spdlog::info("evmgr new config: {}", newConfig.dump(4)); spdlog::info("evmgr new config: {}", newConfig.dump());
// TODO: restart other components // TODO: restart other components
// //
}catch(exception &e) { }catch(exception &e) {
...@@ -529,7 +529,7 @@ class EvDaemon{ ...@@ -529,7 +529,7 @@ class EvDaemon{
exit(1); exit(1);
} }
spdlog::info("evdaemon boot \n{}",info.dump(4)); spdlog::info("evdaemon boot \n{}",info.dump());
devSn = info["sn"]; devSn = info["sn"];
......
...@@ -70,7 +70,7 @@ private: ...@@ -70,7 +70,7 @@ private:
// //
if(config["addr"].get<string>() == "*" || config["addr"].get<string>() == "0.0.0.0") { if(config["addr"].get<string>() == "*" || config["addr"].get<string>() == "0.0.0.0") {
spdlog::error("invalid mgr address: {} in config:\n{}", config["addr"].get<string>(), config.dump(4)); spdlog::error("invalid mgr address: {} in config:\n{}", config["addr"].get<string>(), config.dump());
goto error_exit; goto error_exit;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论