You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
2.0 KiB
44 lines
2.0 KiB
#include "main_control_service.hpp"
|
|
|
|
#include "version.hpp"
|
|
using namespace iflytop;
|
|
using namespace core;
|
|
using namespace std;
|
|
|
|
void MainControlService::initialize() {
|
|
GET_TO_SERVICE(m_zwebService);
|
|
|
|
// 监听从webservice来的websocket消息
|
|
m_zwebService->startWork([this](const json& command, json& receipt) {
|
|
try {
|
|
processReceiveMessage(kzwebService, command, receipt);
|
|
} catch (const std::exception& e) {
|
|
logger->error("process message fail {}", string(e.what()));
|
|
} catch (...) {
|
|
logger->error("process message fail {}", "catch unknown exception");
|
|
}
|
|
});
|
|
};
|
|
void MainControlService::processReceiveMessage(fromwhere_t fromwhere, const json& in, json& receipt) {
|
|
logger->info("process receive message from {},{}", fromwhere2str(fromwhere), in.dump());
|
|
|
|
if (in["command"] == "getVersion") {
|
|
receipt["version"] = VERSION;
|
|
}
|
|
|
|
/*********************************************************************************************************************
|
|
* ================================================日志动态配置接口================================================= *
|
|
*********************************************************************************************************************/
|
|
else if (in["command"] == "loggerSetLevel") {
|
|
int loggerLevel = in["loggerLevel"];
|
|
string loggerName = in["loggerName"];
|
|
logger->info("loggerSetLevel {} {}", loggerName, loggerLevel);
|
|
SpdLoggerFactory::Instance().createLogger(loggerName)->set_level((level::level_enum)loggerLevel);
|
|
} else if (in["command"] == "loggerGetAllLoggers") {
|
|
receipt["loggers"] = SpdLoggerFactory::Instance().loggerNames();
|
|
}
|
|
|
|
/*********************************************************************************************************************
|
|
* ======================================================其他======================================================= *
|
|
*********************************************************************************************************************/
|
|
}
|