zms: Use fmt to construct the log ID

This commit is contained in:
Peter Keresztes Schmidt 2021-02-02 16:20:17 +01:00
parent 1a6b26f2ab
commit 589e5fec26
2 changed files with 7 additions and 5 deletions

View File

@ -108,6 +108,7 @@ target_link_libraries(zms
PRIVATE PRIVATE
zm-core-interface zm-core-interface
zm zm
fmt::fmt
${ZM_EXTRA_LIBS} ${ZM_EXTRA_LIBS}
${ZM_BIN_LIBS} ${ZM_BIN_LIBS}
${CMAKE_DL_LIBS}) ${CMAKE_DL_LIBS})

View File

@ -24,6 +24,7 @@
#include "zm_monitorstream.h" #include "zm_monitorstream.h"
#include "zm_eventstream.h" #include "zm_eventstream.h"
#include "zm_fifo.h" #include "zm_fifo.h"
#include <fmt/format.h>
#include <string> #include <string>
bool ValidateAccess(User *user, int mon_id) { bool ValidateAccess(User *user, int mon_id) {
@ -81,8 +82,7 @@ int main(int argc, const char *argv[], char **envp) {
nph = true; nph = true;
} }
char log_id_string[32] = "zms"; logInit("zms");
logInit(log_id_string);
zmLoadStaticConfig(); zmLoadStaticConfig();
zmDbConnect(); zmDbConnect();
zmLoadDBConfig(); zmLoadDBConfig();
@ -181,12 +181,13 @@ int main(int argc, const char *argv[], char **envp) {
} // end if possible parameter names } // end if possible parameter names
} // end foreach parm } // end foreach parm
std::string logId;
if ( monitor_id ) { if ( monitor_id ) {
snprintf(log_id_string, sizeof(log_id_string), "zms_m%d", monitor_id); logId = fmt::format("zms_m{}", monitor_id);
} else { } else {
snprintf(log_id_string, sizeof(log_id_string), "zms_e%" PRIu64, event_id); logId = fmt::format("zms_e{}", event_id);
} }
logInit(log_id_string); logInit(logId.c_str());
if ( config.opt_use_auth ) { if ( config.opt_use_auth ) {
User *user = nullptr; User *user = nullptr;