From e468c4dc99cd9b853e9e82dfb0f1cbd6d094dadb Mon Sep 17 00:00:00 2001 From: MrDave Date: Fri, 11 Sep 2020 22:06:02 -0600 Subject: [PATCH] Adjust log message formats --- src/logger.cpp | 25 +++++++++++++++++-------- src/util.cpp | 4 ++-- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/logger.cpp b/src/logger.cpp index 7ecf1f4a..1eab0713 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -144,12 +144,13 @@ void motion_log(int level, int type, int errno_flag,int fncname, const char *fmt mythreadname_get(threadname); if (log_mode == LOGMODE_FILE) { - n = snprintf(buf, sizeof(buf), "[%d:%s] [%s] [%s] [%s] ", - threadnr, threadname, log_level_str[level], log_type_str[type], - str_time()); + n = snprintf(buf, sizeof(buf), "%s [%s][%s][%02d:%s] " + , str_time(), log_level_str[level], log_type_str[type] + , threadnr, threadname ); } else { - n = snprintf(buf, sizeof(buf), "[%d:%s] [%s] [%s] ", - threadnr, threadname, log_level_str[level], log_type_str[type]); + n = snprintf(buf, sizeof(buf), "[%s][%s][%02d:%s] " + , log_level_str[level], log_type_str[type] + , threadnr, threadname ); } /* Prepend the format specifier for the function name */ @@ -196,9 +197,17 @@ void motion_log(int level, int type, int errno_flag,int fncname, const char *fmt flood_cnt++; } else { if (flood_cnt > 1){ - snprintf(flood_repeats,1024,"[%d:%s] [%s] [%s] Above message repeats %d times", - threadnr, threadname, log_level_str[level] - , log_type_str[type], flood_cnt-1); + if (log_mode == LOGMODE_FILE) { + snprintf(flood_repeats,1024,"%s [%s] [%s] [%02d:%s] Above message repeats %d times" + , str_time(), log_level_str[level], log_type_str[type] + , threadnr, threadname + , flood_cnt-1); + } else { + snprintf(flood_repeats,1024,"[%s] [%s] [%02d:%s] Above message repeats %d times" + , log_level_str[level], log_type_str[type] + , threadnr, threadname + , flood_cnt-1); + } switch (log_mode) { case LOGMODE_FILE: strncat(flood_repeats, "\n", 1024 - strlen(flood_repeats)); diff --git a/src/util.cpp b/src/util.cpp index c75d7e1b..0f65ef8d 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -490,9 +490,9 @@ void mythreadname_set(const char *abbr, int threadnbr, const char *threadname){ * formatting. */ - char tname[16]; + char tname[32]; if (abbr != NULL){ - snprintf(tname, sizeof(tname), "%s%d%s%s",abbr,threadnbr, + snprintf(tname, sizeof(tname), "%s%02d%s%s",abbr,threadnbr, threadname ? ":" : "", threadname ? threadname : ""); } else {