logger: Pass std::string as ID during logInit

This commit is contained in:
Peter Keresztes Schmidt 2021-02-02 16:36:42 +01:00
parent 6dc132df27
commit e18750bb79
4 changed files with 8 additions and 8 deletions

View File

@ -556,13 +556,13 @@ void Logger::logPrint(bool hex, const char * const filepath, const int line, con
} }
} // end logPrint } // end logPrint
void logInit(const char *name, const Logger::Options &options) { void logInit(const std::string &id, const Logger::Options &options) {
if (Logger::smInstance) { if (Logger::smInstance) {
delete Logger::smInstance; delete Logger::smInstance;
} }
Logger::smInstance = new Logger(); Logger::smInstance = new Logger();
Logger::smInstance->initialise(name, options); Logger::smInstance->initialise(id, options);
} }
void logTerm() { void logTerm() {

View File

@ -137,7 +137,7 @@ private:
static void usrHandler(int sig); static void usrHandler(int sig);
public: public:
friend void logInit(const char *name, const Options &options); friend void logInit(const std::string &id, const Options &options);
friend void logTerm(); friend void logTerm();
static Logger *fetch() { static Logger *fetch() {
@ -177,7 +177,7 @@ public:
void logPrint(bool hex, const char * const filepath, const int line, const int level, const char *fstring, ...); void logPrint(bool hex, const char * const filepath, const int line, const int level, const char *fstring, ...);
}; };
void logInit(const char *name, const Logger::Options &options=Logger::Options()); void logInit(const std::string &id, const Logger::Options &options=Logger::Options());
void logTerm(); void logTerm();
inline const std::string &logId() { inline const std::string &logId() {
return Logger::fetch()->id(); return Logger::fetch()->id();

View File

@ -183,11 +183,11 @@ int main(int argc, char *argv[]) {
logId = fmt::format("zmc_m{}", monitor_id); logId = fmt::format("zmc_m{}", monitor_id);
} }
logInit(logId.c_str()); logInit(logId);
zmLoadStaticConfig(); zmLoadStaticConfig();
zmDbConnect(); zmDbConnect();
zmLoadDBConfig(); zmLoadDBConfig();
logInit(logId.c_str()); logInit(logId);
hwcaps_detect(); hwcaps_detect();
@ -410,7 +410,7 @@ int main(int argc, char *argv[]) {
monitor->Reload(); monitor->Reload();
} }
logTerm(); logTerm();
logInit(logId.c_str()); logInit(logId);
zm_reload = false; zm_reload = false;
} // end if zm_reload } // end if zm_reload
} // end while ! zm_terminate outer connection loop } // end while ! zm_terminate outer connection loop

View File

@ -187,7 +187,7 @@ int main(int argc, const char *argv[], char **envp) {
} else { } else {
logId = fmt::format("zms_e{}", event_id); logId = fmt::format("zms_e{}", event_id);
} }
logInit(logId.c_str()); logInit(logId);
if ( config.opt_use_auth ) { if ( config.opt_use_auth ) {
User *user = nullptr; User *user = nullptr;