From 4f75e15665f18da26ee14188ffdfda343986b6cc Mon Sep 17 00:00:00 2001
From: Mark Michelson <mmichelson@digium.com>
Date: Fri, 14 Dec 2007 18:47:44 +0000
Subject: [PATCH] After reading Russell's e-mail to the dev list stating that
 checking option_verbose is not equivalent to the check done by ast_verb, I
 wrote a macro, VERBOSITY_LEVEL, which does this check. I did a quick look in
 the source and used this macro in some places where option_verbose was used.

I also converted some verbose messages in logger.c to use ast_verb instead of ast_verbose.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@93042 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 funcs/func_timeout.c      | 2 +-
 include/asterisk/logger.h | 4 +++-
 main/logger.c             | 6 ++----
 main/manager.c            | 2 +-
 main/pbx.c                | 2 +-
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/funcs/func_timeout.c b/funcs/func_timeout.c
index 3eb4f32223..5bff202e2d 100644
--- a/funcs/func_timeout.c
+++ b/funcs/func_timeout.c
@@ -106,7 +106,7 @@ static int timeout_write(struct ast_channel *chan, const char *cmd, char *data,
 	case 'a':
 	case 'A':
 		ast_channel_setwhentohangup(chan, x);
-		if(option_verbose > 2) {
+		if (VERBOSITY_LEVEL(2)) {
 			if (chan->whentohangup) {
 				struct timeval tv = { chan->whentohangup, 0 };
 				ast_strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S.%3q %Z",
diff --git a/include/asterisk/logger.h b/include/asterisk/logger.h
index cc4abb906a..09c099f067 100644
--- a/include/asterisk/logger.h
+++ b/include/asterisk/logger.h
@@ -154,8 +154,10 @@ unsigned int ast_verbose_get_by_file(const char *file);
 		ast_log(LOG_DEBUG, __VA_ARGS__); \
 } while (0)
 
+#define VERBOSITY_LEVEL(level) (option_verbose >= (level) || (ast_opt_verb_file && ast_verbose_get_by_file(__FILE__) >= (level)))
+
 #define ast_verb(level, ...) do { \
-	if (option_verbose >= (level) || (ast_opt_verb_file && ast_verbose_get_by_file(__FILE__) >= (level)) ) { \
+	if (VERBOSITY_LEVEL((level)) ) { \
 		if (level >= 4) \
 			ast_verbose(VERBOSE_PREFIX_4 __VA_ARGS__); \
 		else if (level == 3) \
diff --git a/main/logger.c b/main/logger.c
index a1769f2e7b..c82862e6b5 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -586,8 +586,7 @@ static int reload_logger(int rotate)
 		eventlog = fopen(old, "a");
 		if (eventlog) {
 			ast_log(LOG_EVENT, "Restarted Asterisk Event Logger\n");
-			if (option_verbose)
-				ast_verbose("Asterisk Event Logger restarted\n");
+			ast_verb(1, "Asterisk Event Logger restarted\n");
 		} else {
 			ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno));
 			res = -1;
@@ -605,8 +604,7 @@ static int reload_logger(int rotate)
 			ast_queue_log("NONE", "NONE", "NONE", "CONFIGRELOAD", "%s", "");
 			AST_RWLIST_WRLOCK(&logchannels);
 			ast_log(LOG_EVENT, "Restarted Asterisk Queue Logger\n");
-			if (option_verbose)
-				ast_verbose("Asterisk Queue Logger restarted\n");
+			ast_verb(1, "Asterisk Queue Logger restarted\n");
 		} else {
 			ast_log(LOG_ERROR, "Unable to create queue log: %s\n", strerror(errno));
 			res = -1;
diff --git a/main/manager.c b/main/manager.c
index 4f93e98413..28158f4824 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -2677,7 +2677,7 @@ static void purge_sessions(int n_max)
 		if (s->sessiontimeout && (now > s->sessiontimeout) && !s->inuse) {
 			AST_LIST_REMOVE_CURRENT(list);
 			ast_atomic_fetchadd_int(&num_sessions, -1);
-			if (s->authenticated && (option_verbose > 1) && manager_displayconnects(s)) {
+			if (s->authenticated && (VERBOSITY_LEVEL(1)) && manager_displayconnects(s)) {
 				ast_verb(2, "HTTP Manager '%s' timed out from %s\n",
 					s->username, ast_inet_ntoa(s->sin.sin_addr));
 			}
diff --git a/main/pbx.c b/main/pbx.c
index e0a55ef3a2..cc269f3f1f 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -2649,7 +2649,7 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con,
 			c->priority = priority;
 			pbx_substitute_variables(passdata, sizeof(passdata), c, e);
 			ast_debug(1, "Launching '%s'\n", app->name);
-			if (option_verbose > 2) {
+			if (VERBOSITY_LEVEL(2)) {
 				char tmp[80], tmp2[80], tmp3[EXT_DATA_SIZE];
 				ast_verb(3, "Executing [%s@%s:%d] %s(\"%s\", \"%s\") %s\n",
 					exten, context, priority,
-- 
GitLab