[asterisk-commits] mjordan: trunk r347997 - in /trunk: ./ configs/ include/asterisk/ main/ utils/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 12 13:35:11 CST 2011


Author: mjordan
Date: Mon Dec 12 13:35:08 2011
New Revision: 347997

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=347997
Log:
Backed out core changes from r346391

During testing, it was discovered that there were a number of side effects
introduced by r346391 and subsequent check-ins related to it (r346429,
r346617, and r346655).  This included the /main/stdtime/ test 'hanging',
as well as the remote console option failing to receive the appropriate output
after a period of time.

I only backed out the changes to main/ and utils/, as this was adequate
to reverse the behavior experienced.

(issue ASTERISK-18974)

Modified:
    trunk/CHANGES
    trunk/UPGRADE.txt
    trunk/configs/logger.conf.sample
    trunk/include/asterisk/logger.h
    trunk/main/asterisk.c
    trunk/main/cli.c
    trunk/main/config.c
    trunk/main/loader.c
    trunk/main/logger.c
    trunk/utils/ael_main.c
    trunk/utils/hashtest.c
    trunk/utils/hashtest2.c
    trunk/utils/refcounter.c

Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=347997&r1=347996&r2=347997
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Mon Dec 12 13:35:08 2011
@@ -72,16 +72,6 @@
 -------------
  * Allow the built in variables ${NUMBER}, ${IPADDR} and ${SECRET} to be
    used within the dynamic weight attribute when specifying a mapping.
-
-Core changes
-------------
- * Each logging destination and console now have an independent notion of the
-   current verbosity level.  Logger.conf now allows an optional argument to
-   the 'verbose' specifier, indicating the level of verbosity sent to that
-   particular logging destination.  Additionally, remote consoles now each
-   have their own verbosity level.  While 'core set verbose' still works to
-   affect the core console verbosity, 'remote set verbose' will now set a
-   separate level for each remote console without affecting any other console.
 
 Dialplan functions
 ------------------

Modified: trunk/UPGRADE.txt
URL: http://svnview.digium.com/svn/asterisk/trunk/UPGRADE.txt?view=diff&rev=347997&r1=347996&r2=347997
==============================================================================
--- trunk/UPGRADE.txt (original)
+++ trunk/UPGRADE.txt Mon Dec 12 13:35:08 2011
@@ -39,10 +39,6 @@
    - cdr.conf: [general] and [csv] sections
    - dnsmgr.conf
    - dsp.conf
-
- - The 'verbose' setting in logger.conf now takes an optional argument,
-   specifying the verbosity level for each logging destination.  The default,
-   if not otherwise specified, is a verbosity of 3.
 
 AMI:
   - DBDelTree now correctly returns an error when 0 rows are deleted just as

Modified: trunk/configs/logger.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/logger.conf.sample?view=diff&rev=347997&r1=347996&r2=347997
==============================================================================
--- trunk/configs/logger.conf.sample (original)
+++ trunk/configs/logger.conf.sample Mon Dec 12 13:35:08 2011
@@ -73,7 +73,7 @@
 ;    notice
 ;    warning
 ;    error
-;    verbose(<level>)
+;    verbose
 ;    dtmf
 ;    fax
 ;    security
@@ -92,10 +92,6 @@
 ; that there is no value in specifying both "*" and specific level names for
 ; a filename; the "*" level means all levels, and the remaining level names
 ; will be ignored.
-;
-; Verbose takes an additional argument, in the form of an integer level.
-; Messages with higher levels will be ignored.  If verbose is specified at
-; all, it will default to 3.
 ;
 ; We highly recommend that you DO NOT turn on debug mode if you are simply
 ; running a production system.  Debug mode turns on a LOT of extra messages,

Modified: trunk/include/asterisk/logger.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/logger.h?view=diff&rev=347997&r1=347996&r2=347997
==============================================================================
--- trunk/include/asterisk/logger.h (original)
+++ trunk/include/asterisk/logger.h Mon Dec 12 13:35:08 2011
@@ -68,20 +68,19 @@
 void __attribute__((format(printf, 5, 6))) ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...);
 
 /*! Send a verbose message (based on verbose level)
- *	\brief This works like ast_log, but prints verbose messages to the console depending on verbosity level set.
- *	ast_verbose(VERBOSE_PREFIX_3 "Whatever %s is happening\n", "nothing");
- *	This will print the message to the console if the verbose level is set to a level >= 3
- *	Note the absence of a comma after the VERBOSE_PREFIX_3.  This is important.
- *	VERBOSE_PREFIX_1 through VERBOSE_PREFIX_4 are defined.
- *  \version 11 added level parameter
- */
-void __attribute__((format(printf, 5, 6))) __ast_verbose(const char *file, int line, const char *func, int level, const char *fmt, ...);
-
-#define ast_verbose(...) __ast_verbose(__FILE__, __LINE__, __PRETTY_FUNCTION__, -1, __VA_ARGS__)
-
-void __attribute__((format(printf, 5, 0))) __ast_verbose_ap(const char *file, int line, const char *func, int level, const char *fmt, va_list ap);
-
-#define ast_verbose_ap(fmt, ap)	__ast_verbose_ap(__FILE__, __LINE__, __PRETTY_FUNCTION__, -1, fmt, ap)
+ 	\brief This works like ast_log, but prints verbose messages to the console depending on verbosity level set.
+ 	ast_verbose(VERBOSE_PREFIX_3 "Whatever %s is happening\n", "nothing");
+ 	This will print the message to the console if the verbose level is set to a level >= 3
+ 	Note the abscence of a comma after the VERBOSE_PREFIX_3.  This is important.
+ 	VERBOSE_PREFIX_1 through VERBOSE_PREFIX_3 are defined.
+ */
+void __attribute__((format(printf, 4, 5))) __ast_verbose(const char *file, int line, const char *func, const char *fmt, ...);
+
+#define ast_verbose(...) __ast_verbose(__FILE__, __LINE__, __PRETTY_FUNCTION__,  __VA_ARGS__)
+
+void __attribute__((format(printf, 4, 0))) __ast_verbose_ap(const char *file, int line, const char *func, const char *fmt, va_list ap);
+
+#define ast_verbose_ap(fmt, ap)	__ast_verbose_ap(__FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, ap)
 
 void __attribute__((format(printf, 2, 3))) ast_child_verbose(int level, const char *fmt, ...);
 
@@ -241,7 +240,20 @@
 
 #define VERBOSITY_ATLEAST(level) (option_verbose >= (level) || (ast_opt_verb_module && ast_verbose_get_by_module(AST_MODULE) >= (level)))
 
-#define ast_verb(level, ...) __ast_verbose(__FILE__, __LINE__, __PRETTY_FUNCTION__, level, __VA_ARGS__)
+#define ast_verb(level, ...) do { \
+	if (VERBOSITY_ATLEAST((level)) ) { \
+		if (level >= 4) \
+			ast_verbose(VERBOSE_PREFIX_4 __VA_ARGS__); \
+		else if (level == 3) \
+			ast_verbose(VERBOSE_PREFIX_3 __VA_ARGS__); \
+		else if (level == 2) \
+			ast_verbose(VERBOSE_PREFIX_2 __VA_ARGS__); \
+		else if (level == 1) \
+			ast_verbose(VERBOSE_PREFIX_1 __VA_ARGS__); \
+		else \
+			ast_verbose(__VA_ARGS__); \
+	} \
+} while (0)
 
 #ifndef _LOGGER_BACKTRACE_H
 #define _LOGGER_BACKTRACE_H

Modified: trunk/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/asterisk.c?view=diff&rev=347997&r1=347996&r2=347997
==============================================================================
--- trunk/main/asterisk.c (original)
+++ trunk/main/asterisk.c Mon Dec 12 13:35:08 2011
@@ -1751,6 +1751,11 @@
 {
 	const char *c;
 
+	/* Check for verboser preamble */
+	if (*s == 127) {
+		s++;
+	}
+
 	if (!strncmp(s, cmp, strlen(cmp))) {
 		c = s + strlen(cmp);
 		term_color(outbuf, cmp, COLOR_GRAY, 0, maxout);
@@ -1759,25 +1764,10 @@
 	return NULL;
 }
 
-/* These gymnastics are due to platforms which designate char as unsigned by
- * default. Level is the negative character -- offset by 1, because \0 is the
- * EOS delimiter. */
-#define VERBOSE_MAGIC2LEVEL(x) (((char) -*(signed char *) (x)) - 1)
-#define VERBOSE_HASMAGIC(x)	(*(signed char *) (x) < 0)
-
 static void console_verboser(const char *s)
 {
 	char tmp[80];
 	const char *c = NULL;
-	char level = 0;
-
-	if (VERBOSE_HASMAGIC(s)) {
-		level = VERBOSE_MAGIC2LEVEL(s);
-		s++;
-		if (level > option_verbose) {
-			return;
-		}
-	}
 
 	if ((c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_4)) ||
 	    (c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_3)) ||
@@ -1786,11 +1776,14 @@
 		fputs(tmp, stdout);
 		fputs(c, stdout);
 	} else {
+		if (*s == 127) {
+			s++;
+		}
 		fputs(s, stdout);
 	}
 
 	fflush(stdout);
-
+	
 	/* Wake up a poll()ing console */
 	if (ast_opt_console && consolethread != AST_PTHREADT_NULL) {
 		pthread_kill(consolethread, SIGURG);
@@ -1839,26 +1832,8 @@
 		else
 			ast_safe_system(getenv("SHELL") ? getenv("SHELL") : "/bin/sh");
 		ret = 1;
-	} else if (strncasecmp(s, "remote set verbose ", 19) == 0) {
-		if (strncasecmp(s + 19, "atleast ", 8) == 0) {
-			int tmp;
-			if (sscanf(s + 27, "%d", &tmp) != 1) {
-				fprintf(stderr, "Usage: remote set verbose [atleast] <level>\n");
-			} else {
-				if (tmp > option_verbose) {
-					option_verbose = tmp;
-				}
-				fprintf(stdout, "Set remote console verbosity to %d\n", option_verbose);
-			}
-		} else {
-			if (sscanf(s + 19, "%d", &option_verbose) != 1) {
-				fprintf(stderr, "Usage: remote set verbose [atleast] <level>\n");
-			} else {
-				fprintf(stdout, "Set remote console verbosity to %d\n", option_verbose);
-			}
-		}
-		ret = 1;
-	} else if ((strncasecmp(s, "quit", 4) == 0 || strncasecmp(s, "exit", 4) == 0) &&
+	}
+	if ((strncasecmp(s, "quit", 4) == 0 || strncasecmp(s, "exit", 4) == 0) &&
 	    (s[4] == '\0' || isspace(s[4]))) {
 		quit_handler(0, 0, 0, 0);
 		ret = 1;
@@ -2161,23 +2136,6 @@
 #endif /* ! LOW_MEMORY */
 };
 
-struct el_read_char_state_struct {
-	unsigned int line_full:1;
-	unsigned int prev_line_full:1;
-	char prev_line_verbosity;
-};
-
-static int el_read_char_state_init(void *ptr)
-{
-	struct el_read_char_state_struct *state = ptr;
-	state->line_full = 1;
-	state->prev_line_full = 1;
-	state->prev_line_verbosity = 0;
-	return 0;
-}
-
-AST_THREADSTORAGE_CUSTOM(el_read_char_state, el_read_char_state_init, ast_free_ptr);
-
 static int ast_el_read_char(EditLine *editline, char *cp)
 {
 	int num_read = 0;
@@ -2187,7 +2145,6 @@
 	int max;
 #define EL_BUF_SIZE 512
 	char buf[EL_BUF_SIZE];
-	struct el_read_char_state_struct *state = ast_threadstorage_get(&el_read_char_state, sizeof(*state));
 
 	for (;;) {
 		max = 1;
@@ -2217,8 +2174,7 @@
 			}
 		}
 		if (fds[0].revents) {
-			char level = 0;
-			char *curline = buf, *nextline;
+			char *tmp;
 			res = read(ast_consock, buf, sizeof(buf) - 1);
 			/* if the remote side disappears exit */
 			if (res < 1) {
@@ -2251,37 +2207,22 @@
 
 			buf[res] = '\0';
 
+			/* Strip preamble from asynchronous events, too */
+			for (tmp = buf; *tmp; tmp++) {
+				if (*tmp == 127) {
+					memmove(tmp, tmp + 1, strlen(tmp));
+					tmp--;
+					res--;
+				}
+			}
+
 			/* Write over the CLI prompt */
 			if (!ast_opt_exec && !lastpos) {
 				if (write(STDOUT_FILENO, "\r", 5) < 0) {
 				}
 			}
-
-			do {
-				state->prev_line_full = state->line_full;
-				if ((nextline = strchr(curline, '\n'))) {
-					state->line_full = 1;
-					nextline++;
-				} else {
-					state->line_full = 0;
-					nextline = strchr(curline, '\0');
-				}
-
-				if (state->prev_line_full && VERBOSE_HASMAGIC(curline)) {
-					level = VERBOSE_MAGIC2LEVEL(curline);
-					curline++;
-				} else {
-					level = state->prev_line_verbosity;
-				}
-				if ((!state->prev_line_full && state->prev_line_verbosity <= option_verbose) || (state->prev_line_full && level <= option_verbose)) {
-					if (write(STDOUT_FILENO, curline, nextline - curline) < 0) {
-					}
-				}
-
-				state->prev_line_verbosity = level;
-				curline = nextline;
-			} while (!ast_strlen_zero(curline));
-
+			if (write(STDOUT_FILENO, buf, res) < 0) {
+			}
 			if ((res < EL_BUF_SIZE - 1) && ((buf[res-1] == '\n') || (buf[res-2] == '\n'))) {
 				*cp = CC_REFRESH;
 				return(1);
@@ -2792,20 +2733,22 @@
 	else
 		pid = -1;
 	if (!data) {
-		if (!ast_opt_mute) {
+		char tmp[80];
+		snprintf(tmp, sizeof(tmp), "core set verbose atleast %d", option_verbose);
+		fdsend(ast_consock, tmp);
+		snprintf(tmp, sizeof(tmp), "core set debug atleast %d", option_debug);
+		fdsend(ast_consock, tmp);
+		if (!ast_opt_mute)
 			fdsend(ast_consock, "logger mute silent");
-		} else {
+		else 
 			printf("log and verbose output currently muted ('logger mute' to unmute)\n");
-		}
 	}
 
 	if (ast_opt_exec && data) {  /* hack to print output then exit if asterisk -rx is used */
-		int linefull = 1, prev_linefull = 1, prev_line_verbose = 0;
 		struct pollfd fds;
 		fds.fd = ast_consock;
 		fds.events = POLLIN;
 		fds.revents = 0;
-
 		while (ast_poll(&fds, 1, 60000) > 0) {
 			char buffer[512] = "", *curline = buffer, *nextline;
 			int not_written = 1;
@@ -2819,34 +2762,18 @@
 			}
 
 			do {
-				prev_linefull = linefull;
 				if ((nextline = strchr(curline, '\n'))) {
-					linefull = 1;
 					nextline++;
 				} else {
-					linefull = 0;
 					nextline = strchr(curline, '\0');
 				}
 
 				/* Skip verbose lines */
-				/* Prev line full? | Line is verbose | Last line verbose? | Print
-				 * TRUE            | TRUE*           | TRUE               | FALSE
-				 * TRUE            | TRUE*           | FALSE              | FALSE
-				 * TRUE            | FALSE*          | TRUE               | TRUE
-				 * TRUE            | FALSE*          | FALSE              | TRUE
-				 * FALSE           | TRUE            | TRUE*              | FALSE
-				 * FALSE           | TRUE            | FALSE*             | TRUE
-				 * FALSE           | FALSE           | TRUE*              | FALSE
-				 * FALSE           | FALSE           | FALSE*             | TRUE
-				 */
-				if ((!prev_linefull && !prev_line_verbose) || (prev_linefull && *curline > 0)) {
-					prev_line_verbose = 0;
+				if (*curline != 127) {
 					not_written = 0;
 					if (write(STDOUT_FILENO, curline, nextline - curline) < 0) {
 						ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
 					}
-				} else {
-					prev_line_verbose = 1;
 				}
 				curline = nextline;
 			} while (!ast_strlen_zero(curline));
@@ -2885,6 +2812,14 @@
 			if (ebuf[strlen(ebuf)-1] == '\n')
 				ebuf[strlen(ebuf)-1] = '\0';
 			if (!remoteconsolehandler(ebuf)) {
+				/* Strip preamble from output */
+				char *temp;
+				for (temp = ebuf; *temp; temp++) {
+					if (*temp == 127) {
+						memmove(temp, temp + 1, strlen(temp));
+						temp--;
+					}
+				}
 				res = write(ast_consock, ebuf, strlen(ebuf) + 1);
 				if (res < 1) {
 					ast_log(LOG_WARNING, "Unable to write: %s\n", strerror(errno));

Modified: trunk/main/cli.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/cli.c?view=diff&rev=347997&r1=347996&r2=347997
==============================================================================
--- trunk/main/cli.c (original)
+++ trunk/main/cli.c Mon Dec 12 13:35:08 2011
@@ -380,20 +380,6 @@
 		}
 	}
 	return NULL;
-}
-
-static char *handle_localverbose(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-	switch (cmd) {
-	case CLI_INIT:
-		e->command = "remote set verbose";
-		e->usage = "Usage: remote set verbose <level>\n";
-		return NULL;
-	case CLI_GENERATE:
-		return NULL;
-	}
-	ast_cli(a->fd, "This is the main console.  Use 'core set verbose' instead.\n");
-	return CLI_FAILURE;
 }
 
 static char *handle_verbose(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
@@ -1682,8 +1668,6 @@
 
 	AST_CLI_DEFINE(handle_showchan, "Display information on a specific channel"),
 
-	AST_CLI_DEFINE(handle_localverbose, "Set level of remote console verbosity"),
-
 	AST_CLI_DEFINE(handle_core_set_debug_channel, "Enable/disable debugging on a channel"),
 
 	AST_CLI_DEFINE(handle_verbose, "Set level of debug/verbose chattiness"),

Modified: trunk/main/config.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/config.c?view=diff&rev=347997&r1=347996&r2=347997
==============================================================================
--- trunk/main/config.c (original)
+++ trunk/main/config.c Mon Dec 12 13:35:08 2011
@@ -1503,6 +1503,8 @@
 		if (cfmtime)
 			cfmtime->mtime = statbuf.st_mtime;
 
+		ast_verb(2, "Parsing '%s': ", fn);
+			fflush(stdout);
 		if (!(f = fopen(fn, "r"))) {
 			ast_debug(1, "No file to parse: %s\n", fn);
 			ast_verb(2, "Parsing '%s': Not found (%s)\n", fn, strerror(errno));

Modified: trunk/main/loader.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/loader.c?view=diff&rev=347997&r1=347996&r2=347997
==============================================================================
--- trunk/main/loader.c (original)
+++ trunk/main/loader.c Mon Dec 12 13:35:08 2011
@@ -797,11 +797,8 @@
 	case AST_MODULE_LOAD_SUCCESS:
 		if (!ast_fully_booted) {
 			ast_verb(1, "%s => (%s)\n", mod->resource, term_color(tmp, mod->info->description, COLOR_BROWN, COLOR_BLACK, sizeof(tmp)));
-			if (ast_opt_console && !option_verbose) {
-				/* This never looks good on anything but the root console, so
-				 * it's best not to try to funnel it through the logger. */
-				fprintf(stdout, ".");
-			}
+			if (ast_opt_console && !option_verbose)
+				ast_verbose( ".");
 		} else {
 			ast_verb(1, "Loaded %s => (%s)\n", mod->resource, mod->info->description);
 		}

Modified: trunk/main/logger.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/logger.c?view=diff&rev=347997&r1=347996&r2=347997
==============================================================================
--- trunk/main/logger.c (original)
+++ trunk/main/logger.c Mon Dec 12 13:35:08 2011
@@ -101,8 +101,6 @@
 	int disabled;
 	/*! syslog facility */
 	int facility;
-	/*! Verbosity level */
-	int verbosity;
 	/*! Type of log channel */
 	enum logtypes type;
 	/*! logfile logging file pointer */
@@ -211,23 +209,18 @@
 
 static void logger_queue_init(void);
 
-static unsigned int make_components(const char *s, int lineno, int *verbosity)
+static unsigned int make_components(const char *s, int lineno)
 {
 	char *w;
 	unsigned int res = 0;
 	char *stringp = ast_strdupa(s);
 	unsigned int x;
 
-	*verbosity = 3;
-
 	while ((w = strsep(&stringp, ","))) {
 		w = ast_skip_blanks(w);
 
 		if (!strcmp(w, "*")) {
 			res = 0xFFFFFFFF;
-			break;
-		} else if (!strncasecmp(w, "verbose(", 8) && sscanf(w + 8, "%d)", verbosity) == 1) {
-			res |= (1 << __LOG_VERBOSE);
 			break;
 		} else for (x = 0; x < ARRAY_LEN(levels); x++) {
 			if (levels[x] && !strcasecmp(w, levels[x])) {
@@ -307,7 +300,7 @@
 		}
 		chan->type = LOGTYPE_FILE;
 	}
-	chan->logmask = make_components(chan->components, lineno, &chan->verbosity);
+	chan->logmask = make_components(chan->components, lineno);
 
 	return chan;
 }
@@ -440,6 +433,11 @@
 	char *msg = NULL, *emsg = NULL, *sptr, *eptr;
 	va_list ap, aq;
 	int size;
+
+	/* Don't bother, if the level isn't that high */
+	if (option_verbose < level) {
+		return;
+	}
 
 	va_start(ap, fmt);
 	va_copy(aq, ap);
@@ -970,23 +968,15 @@
 	syslog(syslog_level, "%s", buf);
 }
 
-/* These gymnastics are due to platforms which designate char as unsigned by
- * default. Level is the negative character -- offset by 1, because \0 is the
- * EOS delimiter. */
-#define VERBOSE_MAGIC2LEVEL(x) (((char) -*(signed char *) (x)) - 1)
-#define VERBOSE_HASMAGIC(x)	(*(signed char *) (x) < 0)
-
 /*! \brief Print a normal log message to the channels */
 static void logger_print_normal(struct logmsg *logmsg)
 {
 	struct logchannel *chan = NULL;
 	char buf[BUFSIZ];
 	struct verb *v = NULL;
-	int level = 0;
 
 	if (logmsg->level == __LOG_VERBOSE) {
 		char *tmpmsg = ast_strdupa(logmsg->message + 1);
-		level = VERBOSE_MAGIC2LEVEL(logmsg->message);
 		/* Iterate through the list of verbosers and pass them the log message string */
 		AST_RWLIST_RDLOCK(&verbosers);
 		AST_RWLIST_TRAVERSE(&verbosers, v, list)
@@ -1000,13 +990,8 @@
 	if (!AST_RWLIST_EMPTY(&logchannels)) {
 		AST_RWLIST_TRAVERSE(&logchannels, chan, list) {
 			/* If the channel is disabled, then move on to the next one */
-			if (chan->disabled) {
+			if (chan->disabled)
 				continue;
-			}
-			if (logmsg->level == __LOG_VERBOSE && level > chan->verbosity) {
-				continue;
-			}
-
 			/* Check syslog channels */
 			if (chan->type == LOGTYPE_SYSLOG && (chan->logmask & (1 << logmsg->level))) {
 				ast_log_vsyslog(logmsg);
@@ -1234,11 +1219,20 @@
 		}
 		return;
 	}
+	
+	/* don't display LOG_DEBUG messages unless option_verbose _or_ option_debug
+	   are non-zero; LOG_DEBUG messages can still be displayed if option_debug
+	   is zero, if option_verbose is non-zero (this allows for 'level zero'
+	   LOG_DEBUG messages to be displayed, if the logmask on any channel
+	   allows it)
+	*/
+	if (!option_verbose && !option_debug && (level == __LOG_DEBUG))
+		return;
 
 	/* Ignore anything that never gets logged anywhere */
 	if (level != __LOG_VERBOSE && !(global_logmask & (1 << level)))
 		return;
-
+	
 	/* Build string */
 	va_start(ap, fmt);
 	res = ast_str_set_va(&buf, BUFSIZ, fmt, ap);
@@ -1498,31 +1492,13 @@
 #endif /* defined(HAVE_BKTR) */
 }
 
-void __ast_verbose_ap(const char *file, int line, const char *func, int level, const char *fmt, va_list ap)
+void __ast_verbose_ap(const char *file, int line, const char *func, const char *fmt, va_list ap)
 {
 	struct ast_str *buf = NULL;
 	int res = 0;
-	const char *prefix = level >= 4 ? VERBOSE_PREFIX_4 : level == 3 ? VERBOSE_PREFIX_3 : level == 2 ? VERBOSE_PREFIX_2 : level == 1 ? VERBOSE_PREFIX_1 : "";
-	signed char magic = level > 127 ? -128 : -level - 1; /* 0 => -1, 1 => -2, etc.  Can't pass NUL, as it is EOS-delimiter */
-
-	/* For compatibility with modules still calling ast_verbose() directly instead of using ast_verb() */
-	if (level < 0) {
-		if (!strncmp(fmt, VERBOSE_PREFIX_4, strlen(VERBOSE_PREFIX_4))) {
-			magic = -5;
-		} else if (!strncmp(fmt, VERBOSE_PREFIX_3, strlen(VERBOSE_PREFIX_3))) {
-			magic = -4;
-		} else if (!strncmp(fmt, VERBOSE_PREFIX_2, strlen(VERBOSE_PREFIX_2))) {
-			magic = -3;
-		} else if (!strncmp(fmt, VERBOSE_PREFIX_1, strlen(VERBOSE_PREFIX_1))) {
-			magic = -2;
-		} else {
-			magic = -1;
-		}
-	}
-
-	if (!(buf = ast_str_thread_get(&verbose_buf, VERBOSE_BUF_INIT_SIZE))) {
+
+	if (!(buf = ast_str_thread_get(&verbose_buf, VERBOSE_BUF_INIT_SIZE)))
 		return;
-	}
 
 	if (ast_opt_timestamp) {
 		struct timeval now;
@@ -1533,12 +1509,12 @@
 		now = ast_tvnow();
 		ast_localtime(&now, &tm, NULL);
 		ast_strftime(date, sizeof(date), dateformat, &tm);
-		datefmt = alloca(strlen(date) + 3 + strlen(prefix) + strlen(fmt) + 1);
-		sprintf(datefmt, "%c[%s] %s%s", (char) magic, date, prefix, fmt);
+		datefmt = alloca(strlen(date) + 3 + strlen(fmt) + 1);
+		sprintf(datefmt, "%c[%s] %s", 127, date, fmt);
 		fmt = datefmt;
 	} else {
-		char *tmp = alloca(strlen(prefix) + strlen(fmt) + 2);
-		sprintf(tmp, "%c%s%s", (char) magic, prefix, fmt);
+		char *tmp = alloca(strlen(fmt) + 2);
+		sprintf(tmp, "%c%s", 127, fmt);
 		fmt = tmp;
 	}
 
@@ -1546,19 +1522,18 @@
 	res = ast_str_set_va(&buf, 0, fmt, ap);
 
 	/* If the build failed then we can drop this allocated message */
-	if (res == AST_DYNSTR_BUILD_FAILED) {
+	if (res == AST_DYNSTR_BUILD_FAILED)
 		return;
-	}
 
 	ast_log(__LOG_VERBOSE, file, line, func, "%s", ast_str_buffer(buf));
 }
 
-void __ast_verbose(const char *file, int line, const char *func, int level, const char *fmt, ...)
+void __ast_verbose(const char *file, int line, const char *func, const char *fmt, ...)
 {
 	va_list ap;
 
 	va_start(ap, fmt);
-	__ast_verbose_ap(file, line, func, level, fmt, ap);
+	__ast_verbose_ap(file, line, func, fmt, ap);
 	va_end(ap);
 }
 
@@ -1570,7 +1545,7 @@
 	va_list ap;
 
 	va_start(ap, fmt);
-	__ast_verbose_ap("", 0, "", 0, fmt, ap);
+	__ast_verbose_ap("", 0, "", fmt, ap);
 	va_end(ap);
 }
 
@@ -1617,7 +1592,7 @@
 	global_logmask = 0;
 
 	AST_RWLIST_TRAVERSE(&logchannels, cur, list) {
-		cur->logmask = make_components(cur->components, cur->lineno, &cur->verbosity);
+		cur->logmask = make_components(cur->components, cur->lineno);
 		global_logmask |= cur->logmask;
 	}
 

Modified: trunk/utils/ael_main.c
URL: http://svnview.digium.com/svn/asterisk/trunk/utils/ael_main.c?view=diff&rev=347997&r1=347996&r2=347997
==============================================================================
--- trunk/utils/ael_main.c (original)
+++ trunk/utils/ael_main.c Mon Dec 12 13:35:08 2011
@@ -122,7 +122,7 @@
 void ast_context_destroy(void);
 void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...);
 char *ast_process_quotes_and_slashes(char *start, char find, char replace_with);
-void __ast_verbose(const char *file, int line, const char *func, int level, const char *fmt, ...);
+void __ast_verbose(const char *file, int line, const char *func, const char *fmt, ...);
 struct ast_app *pbx_findapp(const char *app);
 void filter_leading_space_from_exprs(char *str);
 void filter_newlines(char *str);

Modified: trunk/utils/hashtest.c
URL: http://svnview.digium.com/svn/asterisk/trunk/utils/hashtest.c?view=diff&rev=347997&r1=347996&r2=347997
==============================================================================
--- trunk/utils/hashtest.c (original)
+++ trunk/utils/hashtest.c Mon Dec 12 13:35:08 2011
@@ -356,7 +356,7 @@
 	va_end(vars);
 }
 
-void __ast_verbose(const char *file, int line, const char *func, int level, const char *fmt, ...)
+void __ast_verbose(const char *file, int line, const char *func, const char *fmt, ...)
 {
         va_list vars;
         va_start(vars,fmt);

Modified: trunk/utils/hashtest2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/utils/hashtest2.c?view=diff&rev=347997&r1=347996&r2=347997
==============================================================================
--- trunk/utils/hashtest2.c (original)
+++ trunk/utils/hashtest2.c Mon Dec 12 13:35:08 2011
@@ -368,7 +368,7 @@
 	va_end(vars);
 }
 
-void __ast_verbose(const char *file, int line, const char *func, int level, const char *fmt, ...)
+void __ast_verbose(const char *file, int line, const char *func, const char *fmt, ...)
 {
         va_list vars;
         va_start(vars,fmt);

Modified: trunk/utils/refcounter.c
URL: http://svnview.digium.com/svn/asterisk/trunk/utils/refcounter.c?view=diff&rev=347997&r1=347996&r2=347997
==============================================================================
--- trunk/utils/refcounter.c (original)
+++ trunk/utils/refcounter.c Mon Dec 12 13:35:08 2011
@@ -259,7 +259,7 @@
 	va_end(vars);
 }
 
-void __ast_verbose(const char *file, int line, const char *func, int level, const char *fmt, ...)
+void __ast_verbose(const char *file, int line, const char *func, const char *fmt, ...)
 {
         va_list vars;
         va_start(vars,fmt);




More information about the asterisk-commits mailing list