MSG(): check log_level early

Improve MSG() in a way that LOG() is - check the log_level first and if
not printed, just skip. Previously the eventual arguments were evaluated
and also log_msg() was called (althoug exitted immediately).
This commit is contained in:
Martin Pulec
2024-09-26 10:00:22 +02:00
parent 3501981441
commit 3e791253b4

View File

@@ -94,7 +94,8 @@ void log_msg(int log_level, const char *format, ...) __attribute__((format (prin
void log_msg_once(int log_level, uint32_t id, const char *msg, ...) __attribute__((format (printf, 3, 4)));
void log_perror(int log_level, const char *msg);
#define MSG(l, fmt, ...) \
log_msg(LOG_LEVEL_##l, "%s" fmt, MOD_NAME, ##__VA_ARGS__)
if (log_level >= LOG_LEVEL_##l) \
log_msg(LOG_LEVEL_##l, "%s" fmt, MOD_NAME, ##__VA_ARGS__)
bool parse_log_cfg(const char *conf_str,
int *log_lvl,