X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/9d7269d8d8333fc1ff47bedcaf488142570b1258..59fa9c93d72d1e065274dadc44a53595fd54648a:/projects/rscriptd/main.cpp?ds=sidebyside diff --git a/projects/rscriptd/main.cpp b/projects/rscriptd/main.cpp index 27e4d747..1baca9e8 100644 --- a/projects/rscriptd/main.cpp +++ b/projects/rscriptd/main.cpp @@ -77,7 +77,7 @@ int StartScriptExecuter(char * procName, int msgKey, int * msgID) int StartScriptExecuter(char *, int msgKey, int * msgID) #endif { -STG_LOGGER & WriteServLog = GetStgLogger(); +auto & WriteServLog = STG::Logger::get(); if (*msgID == -11) // If msgID == -11 - first call. Create queue { @@ -140,7 +140,7 @@ return 0; //----------------------------------------------------------------------------- void StopScriptExecuter(int msgID) { -STG_LOGGER & WriteServLog = GetStgLogger(); +auto & WriteServLog = STG::Logger::get(); for (int i = 0; i < 5; ++i) { @@ -176,11 +176,7 @@ else KillExecuters(); } //----------------------------------------------------------------------------- -#ifdef NO_DAEMON -int ForkAndWait(const std::string &) -#else -int ForkAndWait(const std::string & confDir) -#endif +int ForkAndWait() { #ifndef NO_DAEMON pid_t childPid = fork(); @@ -235,8 +231,8 @@ else if (cfg->Error()) { - STG_LOGGER & WriteServLog = GetStgLogger(); - WriteServLog.SetLogFileName("/var/log/rscriptd.log"); + auto & WriteServLog = STG::Logger::get(); + WriteServLog.setFileName("/var/log/rscriptd.log"); WriteServLog("Error reading config file!"); delete cfg; return EXIT_FAILURE; @@ -252,17 +248,17 @@ cfg->ReadInt("UserTimeout", &userTimeout, 60); cfg->ReadString("ScriptOnConnect", &onConnect, "/etc/rscriptd/OnConnect"); cfg->ReadString("ScriptOnDisconnect", &onDisconnect, "/etc/rscriptd/OnDisconnect"); -if (ForkAndWait(confDir) < 0) +if (ForkAndWait() < 0) { - STG_LOGGER & WriteServLog = GetStgLogger(); + auto & WriteServLog = STG::Logger::get(); WriteServLog("Fork error!"); delete cfg; return EXIT_FAILURE; } -STG_LOGGER & WriteServLog = GetStgLogger(); +auto & WriteServLog = STG::Logger::get(); PIDFile pidFile("/var/run/rscriptd.pid"); -WriteServLog.SetLogFileName(logFileName); +WriteServLog.setFileName(logFileName); WriteServLog("rscriptd v. %s", SERVER_VERSION); for (int i = 0; i < execNum; i++) @@ -270,8 +266,7 @@ for (int i = 0; i < execNum; i++) int ret = StartScriptExecuter(argv[0], execMsgKey, &msgID); if (ret < 0) { - STG_LOGGER & WriteServLog = GetStgLogger(); - WriteServLog("Start Script Executer error!"); + STG::Logger::get()("Start Script Executer error!"); delete cfg; return EXIT_FAILURE; }