Skip to content
Snippets Groups Projects
Commit b53e8178 authored by Mark Spencer's avatar Mark Spencer
Browse files

Add verbose messages to be logged (bug #599)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2079 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 80f23eb9
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
console => notice,warning,error console => notice,warning,error
;console => notice,warning,error,debug ;console => notice,warning,error,debug
messages => notice,warning,error messages => notice,warning,error
;full => notice,warning,error,debug,verbose
;syslog keyword : This special keyword logs to syslog facility ;syslog keyword : This special keyword logs to syslog facility
; ;
......
...@@ -88,6 +88,12 @@ extern void ast_console_puts(const char *string); ...@@ -88,6 +88,12 @@ extern void ast_console_puts(const char *string);
#define __LOG_ERROR 4 #define __LOG_ERROR 4
#define LOG_ERROR __LOG_ERROR, _A_ #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) #if defined(__cplusplus) || defined(c_plusplus)
} }
#endif #endif
......
...@@ -38,9 +38,10 @@ static int syslog_level_map[] = { ...@@ -38,9 +38,10 @@ static int syslog_level_map[] = {
LOG_INFO, /* arbitrary equivalent of LOG_EVENT */ LOG_INFO, /* arbitrary equivalent of LOG_EVENT */
LOG_NOTICE, LOG_NOTICE,
LOG_WARNING, LOG_WARNING,
LOG_ERR LOG_ERR,
LOG_DEBUG
}; };
#define SYSLOG_NLEVELS 5 #define SYSLOG_NLEVELS 6
#include <asterisk/logger.h> #include <asterisk/logger.h>
...@@ -75,7 +76,8 @@ static char *levels[] = { ...@@ -75,7 +76,8 @@ static char *levels[] = {
"EVENT", "EVENT",
"NOTICE", "NOTICE",
"WARNING", "WARNING",
"ERROR" "ERROR",
"VERBOSE"
}; };
static int colors[] = { static int colors[] = {
...@@ -83,7 +85,8 @@ static int colors[] = { ...@@ -83,7 +85,8 @@ static int colors[] = {
COLOR_BRBLUE, COLOR_BRBLUE,
COLOR_YELLOW, COLOR_YELLOW,
COLOR_BRRED, COLOR_BRRED,
COLOR_RED COLOR_RED,
COLOR_GREEN
}; };
static int make_components(char *s, int lineno) static int make_components(char *s, int lineno)
...@@ -106,6 +109,8 @@ static int make_components(char *s, int lineno) ...@@ -106,6 +109,8 @@ static int make_components(char *s, int lineno)
res |= (1 << __LOG_EVENT); res |= (1 << __LOG_EVENT);
else if (!strcasecmp(w, "debug")) else if (!strcasecmp(w, "debug"))
res |= (1 << __LOG_DEBUG); res |= (1 << __LOG_DEBUG);
else if (!strcasecmp(w, "verbose"))
res |= (1 << __LOG_VERBOSE);
else { else {
fprintf(stderr, "Logfile Warning: Unknown keyword '%s' at line %d of logger.conf\n", w, lineno); 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 ...@@ -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); fprintf(stderr, "ast_log_vsyslog called with bogus level: %d\n", level);
return; return;
} }
if(file && line && function) { if(level == __LOG_VERBOSE) {
snprintf(buf, sizeof(buf), "%s[%ld]: %s:%d in %s: ",
levels[level], (long)pthread_self(), file, line, function);
} else {
snprintf(buf, sizeof(buf), "VERBOSE[%ld]: ", (long)pthread_self()); snprintf(buf, sizeof(buf), "VERBOSE[%ld]: ", (long)pthread_self());
level = __LOG_DEBUG; 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); vsnprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), fmt, args);
syslog(syslog_level_map[level], buf); syslog(syslog_level_map[level], buf);
...@@ -445,20 +450,22 @@ void ast_log(int level, const char *file, int line, const char *function, const ...@@ -445,20 +450,22 @@ void ast_log(int level, const char *file, int line, const char *function, const
char linestr[128]; char linestr[128];
char tmp1[80], tmp2[80], tmp3[80], tmp4[80]; char tmp1[80], tmp2[80], tmp3[80], tmp4[80];
sprintf(linestr, "%d", line); if(level != __LOG_VERBOSE) {
snprintf(buf, sizeof(buf), "%s %s[%ld]: %s:%s %s: ", sprintf(linestr, "%d", line);
date, snprintf(buf, sizeof(buf), "%s %s[%ld]: %s:%s %s: ",
term_color(tmp1, levels[level], colors[level], 0, sizeof(tmp1)), date,
(long)pthread_self(), term_color(tmp1, levels[level], colors[level], 0, sizeof(tmp1)),
term_color(tmp2, file, COLOR_BRWHITE, 0, sizeof(tmp2)), (long)pthread_self(),
term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)), term_color(tmp2, file, COLOR_BRWHITE, 0, sizeof(tmp2)),
term_color(tmp4, function, COLOR_BRWHITE, 0, sizeof(tmp4))); 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); ast_console_puts(buf);
vsnprintf(buf, sizeof(buf), fmt, ap); va_start(ap, fmt);
va_end(ap); vsnprintf(buf, sizeof(buf), fmt, ap);
ast_console_puts(buf); va_end(ap);
ast_console_puts(buf);
}
} else if ((chan->logmask & (1 << level)) && (chan->fileptr)) { } else if ((chan->logmask & (1 << level)) && (chan->fileptr)) {
snprintf(buf, sizeof(buf), "%s %s[%ld]: ", date, snprintf(buf, sizeof(buf), "%s %s[%ld]: ", date,
levels[level], (long)pthread_self()); levels[level], (long)pthread_self());
...@@ -538,6 +545,8 @@ extern void ast_verbose(const char *fmt, ...) ...@@ -538,6 +545,8 @@ extern void ast_verbose(const char *fmt, ...)
} /* else } /* else
fprintf(stdout, stuff + opos); */ fprintf(stdout, stuff + opos); */
ast_log(LOG_VERBOSE, stuff);
if (fmt[strlen(fmt)-1] != '\n') if (fmt[strlen(fmt)-1] != '\n')
replacelast = 1; replacelast = 1;
else else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment