diff --git a/configs/logger.conf.sample b/configs/logger.conf.sample index f7e32abb38622f50d3a576e74b60f99c568030b4..04a308437dfa1e4f31b72d9265d637b8bf54ee32 100755 --- a/configs/logger.conf.sample +++ b/configs/logger.conf.sample @@ -15,6 +15,7 @@ console => notice,warning,error ;console => notice,warning,error,debug messages => notice,warning,error +;full => notice,warning,error,debug,verbose ;syslog keyword : This special keyword logs to syslog facility ; diff --git a/include/asterisk/logger.h b/include/asterisk/logger.h index 9278e2b5451361bb235b7a99e770ed8f1595e27c..c2598b40d327f6fdbc6cc4d37608f2d5d6019508 100755 --- a/include/asterisk/logger.h +++ b/include/asterisk/logger.h @@ -88,6 +88,12 @@ extern void ast_console_puts(const char *string); #define __LOG_ERROR 4 #define LOG_ERROR __LOG_ERROR, _A_ +#ifdef LOG_VERBOSE +#undef LOG_VERBOSE +#endif +#define __LOG_VERBOSE 5 +#define LOG_VERBOSE __LOG_VERBOSE, _A_ + #if defined(__cplusplus) || defined(c_plusplus) } #endif diff --git a/logger.c b/logger.c index 42b4013eccacb97b66204619d7357ef9123ea67a..5e1aa3030c3bc43a0c00073babdc360a3e47a8e4 100755 --- a/logger.c +++ b/logger.c @@ -38,9 +38,10 @@ static int syslog_level_map[] = { LOG_INFO, /* arbitrary equivalent of LOG_EVENT */ LOG_NOTICE, LOG_WARNING, - LOG_ERR + LOG_ERR, + LOG_DEBUG }; -#define SYSLOG_NLEVELS 5 +#define SYSLOG_NLEVELS 6 #include <asterisk/logger.h> @@ -75,7 +76,8 @@ static char *levels[] = { "EVENT", "NOTICE", "WARNING", - "ERROR" + "ERROR", + "VERBOSE" }; static int colors[] = { @@ -83,7 +85,8 @@ static int colors[] = { COLOR_BRBLUE, COLOR_YELLOW, COLOR_BRRED, - COLOR_RED + COLOR_RED, + COLOR_GREEN }; static int make_components(char *s, int lineno) @@ -106,6 +109,8 @@ static int make_components(char *s, int lineno) res |= (1 << __LOG_EVENT); else if (!strcasecmp(w, "debug")) res |= (1 << __LOG_DEBUG); + else if (!strcasecmp(w, "verbose")) + res |= (1 << __LOG_VERBOSE); else { fprintf(stderr, "Logfile Warning: Unknown keyword '%s' at line %d of logger.conf\n", w, lineno); } @@ -386,12 +391,12 @@ static void ast_log_vsyslog(int level, const char *file, int line, const char *f fprintf(stderr, "ast_log_vsyslog called with bogus level: %d\n", level); return; } - if(file && line && function) { - snprintf(buf, sizeof(buf), "%s[%ld]: %s:%d in %s: ", - levels[level], (long)pthread_self(), file, line, function); - } else { + if(level == __LOG_VERBOSE) { snprintf(buf, sizeof(buf), "VERBOSE[%ld]: ", (long)pthread_self()); level = __LOG_DEBUG; + } else { + snprintf(buf, sizeof(buf), "%s[%ld]: %s:%d in %s: ", + levels[level], (long)pthread_self(), file, line, function); } vsnprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), fmt, args); syslog(syslog_level_map[level], buf); @@ -445,20 +450,22 @@ void ast_log(int level, const char *file, int line, const char *function, const char linestr[128]; char tmp1[80], tmp2[80], tmp3[80], tmp4[80]; - sprintf(linestr, "%d", line); - snprintf(buf, sizeof(buf), "%s %s[%ld]: %s:%s %s: ", - date, - term_color(tmp1, levels[level], colors[level], 0, sizeof(tmp1)), - (long)pthread_self(), - term_color(tmp2, file, COLOR_BRWHITE, 0, sizeof(tmp2)), - term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)), - term_color(tmp4, function, COLOR_BRWHITE, 0, sizeof(tmp4))); - - ast_console_puts(buf); - va_start(ap, fmt); - vsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); - ast_console_puts(buf); + if(level != __LOG_VERBOSE) { + sprintf(linestr, "%d", line); + snprintf(buf, sizeof(buf), "%s %s[%ld]: %s:%s %s: ", + date, + term_color(tmp1, levels[level], colors[level], 0, sizeof(tmp1)), + (long)pthread_self(), + term_color(tmp2, file, COLOR_BRWHITE, 0, sizeof(tmp2)), + term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)), + term_color(tmp4, function, COLOR_BRWHITE, 0, sizeof(tmp4))); + + ast_console_puts(buf); + va_start(ap, fmt); + vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + ast_console_puts(buf); + } } else if ((chan->logmask & (1 << level)) && (chan->fileptr)) { snprintf(buf, sizeof(buf), "%s %s[%ld]: ", date, levels[level], (long)pthread_self()); @@ -538,6 +545,8 @@ extern void ast_verbose(const char *fmt, ...) } /* else fprintf(stdout, stuff + opos); */ + ast_log(LOG_VERBOSE, stuff); + if (fmt[strlen(fmt)-1] != '\n') replacelast = 1; else