Index: main/logger.c =================================================================== --- main/logger.c (revision 221969) +++ main/logger.c (working copy) @@ -94,6 +94,10 @@ static int filesize_reload_needed; static int global_logmask = -1; +__thread char lastmsg[4096] = ""; +__thread int lastmsg_count = 0; +#define LOG_SUPPRESS_IDENTICAL_MESSAGES 5 + enum rotatestrategy { SEQUENTIAL = 1 << 0, /* Original method - create a new file, in order */ ROTATE = 1 << 1, /* Rotate all files, such that the oldest file has the highest suffix */ @@ -1090,7 +1094,7 @@ struct timeval now = ast_tvnow(); int res = 0; va_list ap; - + if (!(buf = ast_str_thread_get(&log_buf, LOG_BUF_INIT_SIZE))) return; @@ -1124,7 +1128,22 @@ /* Ignore anything that never gets logged anywhere */ if (!(global_logmask & (1 << level))) return; - + + if (!strcasecmp(fmt,lastmsg)) { + lastmsg_count++; + if (lastmsg_count>LOG_SUPPRESS_IDENTICAL_MESSAGES) { + return; + } + } else { + if (lastmsg_count>LOG_SUPPRESS_IDENTICAL_MESSAGES) { + int repeats = lastmsg_count-LOG_SUPPRESS_IDENTICAL_MESSAGES; + lastmsg_count=0; + ast_log(level, file, line, function, "Message repeats %d times\n", repeats); + } + lastmsg_count=0; + ast_copy_string(lastmsg, fmt, sizeof(lastmsg)); + } + /* Build string */ va_start(ap, fmt); res = ast_str_set_va(&buf, BUFSIZ, fmt, ap);