From e18750bb795fa7e96f11515534ccf22f595165f3 Mon Sep 17 00:00:00 2001 From: Peter Keresztes Schmidt Date: Tue, 2 Feb 2021 16:36:42 +0100 Subject: [PATCH] logger: Pass std::string as ID during logInit --- src/zm_logger.cpp | 4 ++-- src/zm_logger.h | 4 ++-- src/zmc.cpp | 6 +++--- src/zms.cpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/zm_logger.cpp b/src/zm_logger.cpp index 16f66835c..aef3e45fa 100644 --- a/src/zm_logger.cpp +++ b/src/zm_logger.cpp @@ -556,13 +556,13 @@ void Logger::logPrint(bool hex, const char * const filepath, const int line, con } } // end logPrint -void logInit(const char *name, const Logger::Options &options) { +void logInit(const std::string &id, const Logger::Options &options) { if (Logger::smInstance) { delete Logger::smInstance; } Logger::smInstance = new Logger(); - Logger::smInstance->initialise(name, options); + Logger::smInstance->initialise(id, options); } void logTerm() { diff --git a/src/zm_logger.h b/src/zm_logger.h index ee358b206..80b6e7ba7 100644 --- a/src/zm_logger.h +++ b/src/zm_logger.h @@ -137,7 +137,7 @@ private: static void usrHandler(int sig); public: - friend void logInit(const char *name, const Options &options); + friend void logInit(const std::string &id, const Options &options); friend void logTerm(); 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 logInit(const char *name, const Logger::Options &options=Logger::Options()); +void logInit(const std::string &id, const Logger::Options &options=Logger::Options()); void logTerm(); inline const std::string &logId() { return Logger::fetch()->id(); diff --git a/src/zmc.cpp b/src/zmc.cpp index 578841729..fc3fe78a3 100644 --- a/src/zmc.cpp +++ b/src/zmc.cpp @@ -183,11 +183,11 @@ int main(int argc, char *argv[]) { logId = fmt::format("zmc_m{}", monitor_id); } - logInit(logId.c_str()); + logInit(logId); zmLoadStaticConfig(); zmDbConnect(); zmLoadDBConfig(); - logInit(logId.c_str()); + logInit(logId); hwcaps_detect(); @@ -410,7 +410,7 @@ int main(int argc, char *argv[]) { monitor->Reload(); } logTerm(); - logInit(logId.c_str()); + logInit(logId); zm_reload = false; } // end if zm_reload } // end while ! zm_terminate outer connection loop diff --git a/src/zms.cpp b/src/zms.cpp index b462e1352..9ad8f32c8 100644 --- a/src/zms.cpp +++ b/src/zms.cpp @@ -187,7 +187,7 @@ int main(int argc, const char *argv[], char **envp) { } else { logId = fmt::format("zms_e{}", event_id); } - logInit(logId.c_str()); + logInit(logId); if ( config.opt_use_auth ) { User *user = nullptr;