Allow each logging destination and console to have its own notion of the verbosity...
authorTilghman Lesher <tilghman@meg.abyt.es>
Tue, 29 Nov 2011 18:43:16 +0000 (18:43 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Tue, 29 Nov 2011 18:43:16 +0000 (18:43 +0000)
Review: https://reviewboard.asterisk.org/r/1599

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@346391 65c4cc65-6c06-0410-ace0-fbb531ad65f3

23 files changed:
CHANGES
UPGRADE.txt
addons/chan_ooh323.c
addons/res_config_mysql.c
apps/app_rpt.c
apps/app_verbose.c
apps/app_voicemail.c
channels/chan_sip.c
channels/chan_skinny.c
channels/chan_usbradio.c
codecs/codec_dahdi.c
configs/logger.conf.sample
include/asterisk/logger.h
main/asterisk.c
main/bridging.c
main/cli.c
main/dial.c
main/logger.c
main/say.c
res/res_clialiases.c
res/res_fax.c
res/res_jabber.c
res/res_musiconhold.c

diff --git a/CHANGES b/CHANGES
index 5dc8623..3554d45 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -64,6 +64,16 @@ DUNDi changes
  * 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.
+
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 1.8 to Asterisk 10 -------------------
 ------------------------------------------------------------------------------
index dee0194..ac88afd 100644 (file)
@@ -20,7 +20,7 @@
 ===
 ===========================================================
 
-From 10 to 12:
+From 10 to 11:
 
 func_enum:
  - ENUM query functions now return a count of -1 on lookup error to
@@ -36,6 +36,10 @@ Configuration Files:
    - 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
     the DBDel action does.
index 1592c1a..bca7a8b 100644 (file)
@@ -361,8 +361,9 @@ static struct ast_channel *ooh323_new(struct ooh323_pvt *i, int state,
        struct ast_format tmpfmt;
        int features = 0;
 
-       if (gH323Debug)
-               ast_verbose("---   ooh323_new - %s\n", host);
+       if (gH323Debug) {
+               ast_verb(0, "---   ooh323_new - %s\n", host);
+       }
 
        ast_format_clear(&tmpfmt);
        /* Don't hold a h323 pvt lock while we allocate a channel */
@@ -480,8 +481,9 @@ static struct ast_channel *ooh323_new(struct ooh323_pvt *i, int state,
 
        if(ch)   ast_channel_unlock(ch);
 
-       if (gH323Debug)
-               ast_verbose("+++   h323_new\n");
+       if (gH323Debug) {
+               ast_verb(0, "+++   h323_new\n");
+       }
 
        return ch;
 }
@@ -492,8 +494,9 @@ static struct ooh323_pvt *ooh323_alloc(int callref, char *callToken)
 {
        struct ooh323_pvt *pvt = NULL;
 
-       if (gH323Debug)
-               ast_verbose("---   ooh323_alloc\n");
+       if (gH323Debug) {
+               ast_verb(0, "---   ooh323_alloc\n");
+       }
 
        if (!(pvt = ast_calloc(1, sizeof(*pvt)))) {
                ast_log(LOG_ERROR, "Couldn't allocate private ooh323 structure\n");
@@ -542,8 +545,9 @@ static struct ooh323_pvt *ooh323_alloc(int callref, char *callToken)
        iflist = pvt;
        ast_mutex_unlock(&iflock);
 
-       if (gH323Debug)
-               ast_verbose("+++   ooh323_alloc\n");
+       if (gH323Debug) {
+               ast_verb(0, "+++   ooh323_alloc\n");
+       }
 
        return pvt;
 }
@@ -566,7 +570,7 @@ static struct ast_channel *ooh323_request(const char *type, struct ast_format_ca
        int port = 0;
 
        if (gH323Debug)
-               ast_verbose("---   ooh323_request - data %s format %s\n", (char*)data,  
+               ast_verb(0, "---   ooh323_request - data %s format %s\n", (char*)data,  
                                                                                ast_getformatname_multiple(formats,FORMAT_STRING_SIZE,cap));
 
        if (!(ast_format_cap_has_type(cap, AST_FORMAT_TYPE_AUDIO))) {
@@ -719,7 +723,7 @@ static struct ast_channel *ooh323_request(const char *type, struct ast_format_ca
 
        restart_monitor();
        if (gH323Debug)
-               ast_verbose("+++   ooh323_request\n");
+               ast_verb(0, "+++   ooh323_request\n");
 
        return chan;
 
@@ -731,7 +735,7 @@ static struct ooh323_pvt* find_call(ooCallData *call)
        struct ooh323_pvt *p;
 
        if (gH323Debug)
-               ast_verbose("---   find_call\n");
+               ast_verb(0, "---   find_call\n");
 
        ast_mutex_lock(&iflock);
 
@@ -743,7 +747,7 @@ static struct ooh323_pvt* find_call(ooCallData *call)
        ast_mutex_unlock(&iflock);
 
        if (gH323Debug)
-               ast_verbose("+++   find_call\n");
+               ast_verb(0, "+++   find_call\n");
 
        return p;
 }
@@ -753,7 +757,7 @@ struct ooh323_user *find_user(const char * name, const char* ip)
        struct ooh323_user *user;
 
        if (gH323Debug)
-      ast_verbose("---   find_user: %s, %s\n",name,ip);
+      ast_verb(0, "---   find_user: %s, %s\n",name,ip);
 
        ast_mutex_lock(&userl.lock);
 
@@ -769,7 +773,7 @@ struct ooh323_user *find_user(const char * name, const char* ip)
        ast_mutex_unlock(&userl.lock);
 
        if (gH323Debug)
-               ast_verbose("+++   find_user\n");
+               ast_verb(0, "+++   find_user\n");
 
        return user;
 }
@@ -779,13 +783,13 @@ struct ooh323_peer *find_friend(const char *name, int port)
        struct ooh323_peer *peer;  
 
        if (gH323Debug)
-               ast_verbose("---   find_friend \"%s\"\n", name);
+               ast_verb(0, "---   find_friend \"%s\"\n", name);
 
 
        ast_mutex_lock(&peerl.lock);
        for (peer = peerl.peers; peer; peer = peer->next) {
                if (gH323Debug) {
-                       ast_verbose("           comparing with \"%s\"\n", peer->ip);
+                       ast_verb(0, "           comparing with \"%s\"\n", peer->ip);
                }
                if (!strcmp(peer->ip, name)) {
                        if (port <= 0 || (port > 0 && peer->port == port)) {
@@ -797,9 +801,9 @@ struct ooh323_peer *find_friend(const char *name, int port)
 
        if (gH323Debug) {
                if (peer) {
-                       ast_verbose("           found matching friend\n");
+                       ast_verb(0, "           found matching friend\n");
                }
-               ast_verbose("+++   find_friend \"%s\"\n", name);
+               ast_verb(0, "+++   find_friend \"%s\"\n", name);
        }
 
        return peer;            
@@ -811,13 +815,13 @@ struct ooh323_peer *find_peer(const char * name, int port)
        struct ooh323_peer *peer;
 
        if (gH323Debug)
-               ast_verbose("---   find_peer \"%s\"\n", name);
+               ast_verb(0, "---   find_peer \"%s\"\n", name);
 
 
        ast_mutex_lock(&peerl.lock);
        for (peer = peerl.peers; peer; peer = peer->next) {
                if (gH323Debug) {
-                       ast_verbose("           comparing with \"%s\"\n", peer->ip);
+                       ast_verb(0, "           comparing with \"%s\"\n", peer->ip);
                }
                if (!strcasecmp(peer->name, name))
                        break;
@@ -836,9 +840,9 @@ struct ooh323_peer *find_peer(const char * name, int port)
 
        if (gH323Debug) {
                if (peer) {
-                       ast_verbose("           found matching peer\n");
+                       ast_verb(0, "           found matching peer\n");
                }
-               ast_verbose("+++   find_peer \"%s\"\n", name);
+               ast_verb(0, "+++   find_peer \"%s\"\n", name);
        }
 
        return peer;            
@@ -850,7 +854,7 @@ static int ooh323_digit_begin(struct ast_channel *chan, char digit)
        struct ooh323_pvt *p = (struct ooh323_pvt *) chan->tech_pvt;
        
        if (gH323Debug)
-               ast_verbose("---   ooh323_digit_begin\n");
+               ast_verb(0, "---   ooh323_digit_begin\n");
 
        if (!p) {
                ast_log(LOG_ERROR, "No private structure for call\n");
@@ -869,7 +873,7 @@ static int ooh323_digit_begin(struct ast_channel *chan, char digit)
        }
        ast_mutex_unlock(&p->lock);
        if (gH323Debug)
-               ast_verbose("+++   ooh323_digit_begin\n");
+               ast_verb(0, "+++   ooh323_digit_begin\n");
 
        return 0;
 }
@@ -879,7 +883,7 @@ static int ooh323_digit_end(struct ast_channel *chan, char digit, unsigned int d
        struct ooh323_pvt *p = (struct ooh323_pvt *) chan->tech_pvt;
 
        if (gH323Debug)
-               ast_verbose("---   ooh323_digit_end\n");
+               ast_verb(0, "---   ooh323_digit_end\n");
 
        if (!p) {
                ast_log(LOG_ERROR, "No private structure for call\n");
@@ -891,7 +895,7 @@ static int ooh323_digit_end(struct ast_channel *chan, char digit, unsigned int d
 
        ast_mutex_unlock(&p->lock);
        if (gH323Debug)
-               ast_verbose("+++   ooh323_digit_end\n");
+               ast_verb(0, "+++   ooh323_digit_end\n");
 
        return 0;
 }
@@ -912,7 +916,7 @@ static int ooh323_call(struct ast_channel *ast, char *dest, int timeout)
        };
 
        if (gH323Debug)
-               ast_verbose("---   ooh323_call- %s\n", dest);
+               ast_verb(0, "---   ooh323_call- %s\n", dest);
 
 
        if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) {
@@ -989,7 +993,7 @@ static int ooh323_call(struct ast_channel *ast, char *dest, int timeout)
                return -1; /* ToDO: cleanup */
        }
        if (gH323Debug)
-               ast_verbose("+++   ooh323_call\n");
+               ast_verb(0, "+++   ooh323_call\n");
 
   return 0;
 }
@@ -1000,7 +1004,7 @@ static int ooh323_hangup(struct ast_channel *ast)
        int q931cause = AST_CAUSE_NORMAL_CLEARING;
 
        if (gH323Debug)
-               ast_verbose("---   ooh323_hangup\n");
+               ast_verb(0, "---   ooh323_hangup\n");
 
        if (p) {
                ast_mutex_lock(&p->lock);
@@ -1027,7 +1031,7 @@ static int ooh323_hangup(struct ast_channel *ast)
 
 
                if (gH323Debug)
-                       ast_verbose("    hanging %s with cause: %d\n", p->username, q931cause);
+                       ast_verb(0, "    hanging %s with cause: %d\n", p->username, q931cause);
                ast->tech_pvt = NULL; 
                if (!ast_test_flag(p, H323_ALREADYGONE)) {
                        ooHangCall(p->callToken, 
@@ -1056,7 +1060,7 @@ static int ooh323_hangup(struct ast_channel *ast)
        }
        
        if (gH323Debug)
-               ast_verbose("+++   ooh323_hangup\n");
+               ast_verb(0, "+++   ooh323_hangup\n");
 
   return 0;
 }
@@ -1067,7 +1071,7 @@ static int ooh323_answer(struct ast_channel *ast)
        char *callToken = (char *)NULL;
 
        if (gH323Debug)
-               ast_verbose("--- ooh323_answer\n");
+               ast_verb(0, "--- ooh323_answer\n");
 
        if (p) {
 
@@ -1097,7 +1101,7 @@ static int ooh323_answer(struct ast_channel *ast)
        }
 
        if (gH323Debug)
-               ast_verbose("+++ ooh323_answer\n");
+               ast_verb(0, "+++ ooh323_answer\n");
 
   return 0;
 }
@@ -1201,12 +1205,12 @@ static int ooh323_indicate(struct ast_channel *ast, int condition, const void *d
 
        if (!callToken) {
                if (gH323Debug)
-                       ast_verbose("   ooh323_indicate - No callToken\n");
+                       ast_verb(0, "   ooh323_indicate - No callToken\n");
                return -1;
        }
 
        if (gH323Debug)
-               ast_verbose("----- ooh323_indicate %d on call %s\n", condition, callToken);
+               ast_verb(0, "----- ooh323_indicate %d on call %s\n", condition, callToken);
         
        ast_mutex_lock(&p->lock);
        switch (condition) {
@@ -1359,7 +1363,7 @@ static int ooh323_indicate(struct ast_channel *ast, int condition, const void *d
        ast_mutex_unlock(&p->lock);
 
        if (gH323Debug)
-               ast_verbose("++++  ooh323_indicate %d on %s\n", condition, callToken);
+               ast_verb(0, "++++  ooh323_indicate %d on %s\n", condition, callToken);
 
        free(callToken);
        return res;
@@ -1378,7 +1382,7 @@ static int ooh323_queryoption(struct ast_channel *ast, int option, void *data, i
        ast_mutex_lock(&p->lock);
 
        if (gH323Debug)
-               ast_verbose("----- ooh323_queryoption %d on channel %s\n", option, ast->name);
+               ast_verb(0, "----- ooh323_queryoption %d on channel %s\n", option, ast->name);
         
        switch (option) {
 
@@ -1418,7 +1422,7 @@ static int ooh323_queryoption(struct ast_channel *ast, int option, void *data, i
        }
 
        if (gH323Debug)
-               ast_verbose("+++++ ooh323_queryoption %d on channel %s\n", option, ast->name);
+               ast_verb(0, "+++++ ooh323_queryoption %d on channel %s\n", option, ast->name);
         
        ast_mutex_unlock(&p->lock);
 
@@ -1434,7 +1438,7 @@ static int ooh323_fixup(struct ast_channel *oldchan, struct ast_channel *newchan
        if (!p) return -1;
 
        if (gH323Debug)
-               ast_verbose("--- ooh323c ooh323_fixup\n");
+               ast_verb(0, "--- ooh323c ooh323_fixup\n");
 
        ast_mutex_lock(&p->lock);
        if (p->owner != oldchan) {
@@ -1452,7 +1456,7 @@ static int ooh323_fixup(struct ast_channel *oldchan, struct ast_channel *newchan
        ast_mutex_unlock(&p->lock);
 
        if (gH323Debug)
-               ast_verbose("+++ ooh323c ooh323_fixup \n");
+               ast_verb(0, "+++ ooh323c ooh323_fixup \n");
 
        return 0;
 }
@@ -1464,7 +1468,7 @@ void ooh323_set_write_format(ooCallData *call, struct ast_format *fmt, int txfra
        char formats[FORMAT_STRING_SIZE];
 
        if (gH323Debug)
-               ast_verbose("---   ooh323_update_writeformat %s/%d\n", 
+               ast_verb(0, "---   ooh323_update_writeformat %s/%d\n", 
                                ast_getformatname(fmt), txframes);
        
        p = find_call(call);
@@ -1488,7 +1492,7 @@ void ooh323_set_write_format(ooCallData *call, struct ast_format *fmt, int txfra
                        return;
                }
                if (gH323Debug)
-                       ast_verbose("Writeformat before update %s/%s\n", 
+                       ast_verb(0, "Writeformat before update %s/%s\n", 
                          ast_getformatname(&p->owner->writeformat),
                          ast_getformatname_multiple(formats, sizeof(formats), p->owner->nativeformats));
                if (txframes)
@@ -1514,7 +1518,7 @@ void ooh323_set_write_format(ooCallData *call, struct ast_format *fmt, int txfra
        ast_mutex_unlock(&p->lock);
 
        if (gH323Debug)
-               ast_verbose("+++   ooh323_update_writeformat\n");
+               ast_verb(0, "+++   ooh323_update_writeformat\n");
 }
 
 void ooh323_set_read_format(ooCallData *call, struct ast_format *fmt)
@@ -1522,7 +1526,7 @@ void ooh323_set_read_format(ooCallData *call, struct ast_format *fmt)
        struct ooh323_pvt *p = NULL;
 
        if (gH323Debug)
-               ast_verbose("---   ooh323_update_readformat %s\n", 
+               ast_verb(0, "---   ooh323_update_readformat %s\n", 
                                ast_getformatname(fmt));
        
        p = find_call(call);
@@ -1547,7 +1551,7 @@ void ooh323_set_read_format(ooCallData *call, struct ast_format *fmt)
                }
 
                if (gH323Debug)
-                       ast_verbose("Readformat before update %s\n", 
+                       ast_verb(0, "Readformat before update %s\n", 
                                  ast_getformatname(&p->owner->readformat));
                ast_format_cap_set(p->owner->nativeformats, fmt);
                ast_set_read_format(p->owner, &p->owner->readformat);
@@ -1558,7 +1562,7 @@ void ooh323_set_read_format(ooCallData *call, struct ast_format *fmt)
        ast_mutex_unlock(&p->lock);
 
        if (gH323Debug)
-               ast_verbose("+++   ooh323_update_readformat\n");
+               ast_verb(0, "+++   ooh323_update_readformat\n");
 }
 
 
@@ -1568,7 +1572,7 @@ int onAlerting(ooCallData *call)
        struct ast_channel *c = NULL;
 
        if (gH323Debug)
-               ast_verbose("--- onAlerting %s\n", call->callToken);
+               ast_verb(0, "--- onAlerting %s\n", call->callToken);
 
        p = find_call(call);
 
@@ -1613,7 +1617,7 @@ int onAlerting(ooCallData *call)
        ast_mutex_unlock(&p->lock);
 
        if (gH323Debug)
-               ast_verbose("+++ onAlerting %s\n", call->callToken);
+               ast_verb(0, "+++ onAlerting %s\n", call->callToken);
 
        return OO_OK;
 }
@@ -1624,7 +1628,7 @@ int onProgress(ooCallData *call)
        struct ast_channel *c = NULL;
 
        if (gH323Debug)
-               ast_verbose("--- onProgress %s\n", call->callToken);
+               ast_verb(0, "--- onProgress %s\n", call->callToken);
 
        p = find_call(call);
 
@@ -1669,7 +1673,7 @@ int onProgress(ooCallData *call)
        ast_mutex_unlock(&p->lock);
 
        if (gH323Debug)
-               ast_verbose("+++ onProgress %s\n", call->callToken);
+               ast_verb(0, "+++ onProgress %s\n", call->callToken);
 
        return OO_OK;
 }
@@ -1730,7 +1734,7 @@ int ooh323_onReceivedSetup(ooCallData *call, Q931Message *pmsg)
        char number [OO_MAX_NUMBER_LENGTH];
 
        if (gH323Debug)
-               ast_verbose("---   ooh323_onReceivedSetup %s\n", call->callToken);
+               ast_verb(0, "---   ooh323_onReceivedSetup %s\n", call->callToken);
 
 
        if (!(p = ooh323_alloc(call->callReference, call->callToken))) {
@@ -1877,7 +1881,7 @@ int ooh323_onReceivedSetup(ooCallData *call, Q931Message *pmsg)
        ast_mutex_unlock(&p->lock);
 
        if (gH323Debug)
-               ast_verbose("+++   ooh323_onReceivedSetup - Determined context %s, "
+               ast_verb(0, "+++   ooh323_onReceivedSetup - Determined context %s, "
                                                "extension %s\n", p->context, p->exten);
 
        return OO_OK;
@@ -1891,7 +1895,7 @@ int onOutgoingCall(ooCallData *call)
        int i = 0;
 
        if (gH323Debug)
-               ast_verbose("---   onOutgoingCall %lx: %s\n", (long unsigned int) call, call->callToken);
+               ast_verb(0, "---   onOutgoingCall %lx: %s\n", (long unsigned int) call, call->callToken);
 
        if (!strcmp(call->callType, "outgoing")) {
                p = find_call(call);
@@ -1923,13 +1927,13 @@ int onOutgoingCall(ooCallData *call)
 
                if (!ast_strlen_zero(p->caller_dialedDigits)) {
                        if (gH323Debug) {
-                               ast_verbose("Setting dialed digits %s\n", p->caller_dialedDigits);
+                               ast_verb(0, "Setting dialed digits %s\n", p->caller_dialedDigits);
                        }
                        ooCallAddAliasDialedDigits(call, p->caller_dialedDigits);
                } else if (!ast_strlen_zero(p->callerid_num)) {
                        if (ooIsDailedDigit(p->callerid_num)) {
                                if (gH323Debug) {
-                                       ast_verbose("setting callid number %s\n", p->callerid_num);
+                                       ast_verb(0, "setting callid number %s\n", p->callerid_num);
                                }
                                ooCallAddAliasDialedDigits(call, p->callerid_num);
                        } else if (ast_strlen_zero(p->caller_h323id)) {
@@ -1953,7 +1957,7 @@ int onOutgoingCall(ooCallData *call)
        }
 
        if (gH323Debug)
-               ast_verbose("+++   onOutgoingCall %s\n", call->callToken);
+               ast_verb(0, "+++   onOutgoingCall %s\n", call->callToken);
        return OO_OK;
 }
 
@@ -1964,7 +1968,7 @@ int onNewCallCreated(ooCallData *call)
        int i = 0;
 
        if (gH323Debug)
-               ast_verbose("---   onNewCallCreated %lx: %s\n", (long unsigned int) call, call->callToken);
+               ast_verb(0, "---   onNewCallCreated %lx: %s\n", (long unsigned int) call, call->callToken);
 
        ast_mutex_lock(&call->Lock);
        if (ooh323c_start_call_thread(call)) {
@@ -2004,13 +2008,13 @@ int onNewCallCreated(ooCallData *call)
 
                if (!ast_strlen_zero(p->caller_dialedDigits)) {
                        if (gH323Debug) {
-                               ast_verbose("Setting dialed digits %s\n", p->caller_dialedDigits);
+                               ast_verb(0, "Setting dialed digits %s\n", p->caller_dialedDigits);
                        }
                        ooCallAddAliasDialedDigits(call, p->caller_dialedDigits);
                } else if (!ast_strlen_zero(p->callerid_num)) {
                        if (ooIsDailedDigit(p->callerid_num)) {
                                if (gH323Debug) {
-                                       ast_verbose("setting callid number %s\n", p->callerid_num);
+                                       ast_verb(0, "setting callid number %s\n", p->callerid_num);
                                }
                                ooCallAddAliasDialedDigits(call, p->callerid_num);
                        } else if (ast_strlen_zero(p->caller_h323id)) {
@@ -2031,7 +2035,7 @@ int onNewCallCreated(ooCallData *call)
                if (gH323Debug) {
                        char prefsBuf[256];
                        ast_codec_pref_string(&p->prefs, prefsBuf, sizeof(prefsBuf));
-                       ast_verbose(" Outgoing call %s(%s) - Codec prefs - %s\n", 
+                       ast_verb(0, " Outgoing call %s(%s) - Codec prefs - %s\n", 
                                p->username?p->username:"NULL", call->callToken, prefsBuf);
                }
 
@@ -2044,7 +2048,7 @@ int onNewCallCreated(ooCallData *call)
 
        ast_mutex_unlock(&call->Lock);
        if (gH323Debug)
-               ast_verbose("+++   onNewCallCreated %s\n", call->callToken);
+               ast_verb(0, "+++   onNewCallCreated %s\n", call->callToken);
        return OO_OK;
 }
 
@@ -2053,7 +2057,7 @@ int onCallEstablished(ooCallData *call)
        struct ooh323_pvt *p = NULL;
 
        if (gH323Debug)
-               ast_verbose("---   onCallEstablished %s\n", call->callToken);
+               ast_verb(0, "---   onCallEstablished %s\n", call->callToken);
 
 
        if (!(p = find_call(call))) {
@@ -2099,7 +2103,7 @@ int onCallEstablished(ooCallData *call)
        }
 
        if (gH323Debug)
-               ast_verbose("+++   onCallEstablished %s\n", call->callToken);
+               ast_verb(0, "+++   onCallEstablished %s\n", call->callToken);
 
        return OO_OK;
 }
@@ -2110,7 +2114,7 @@ int onCallCleared(ooCallData *call)
        int ownerLock = 0;
 
        if (gH323Debug)
-               ast_verbose("---   onCallCleared %s \n", call->callToken);
+               ast_verb(0, "---   onCallCleared %s \n", call->callToken);
 
 
    if ((p = find_call(call))) {
@@ -2155,7 +2159,7 @@ int onCallCleared(ooCallData *call)
     }
 
        if (gH323Debug)
-               ast_verbose("+++   onCallCleared\n");
+               ast_verb(0, "+++   onCallCleared\n");
 
        return OO_OK;
 }
@@ -2165,7 +2169,7 @@ int onCallCleared(ooCallData *call)
        struct ooh323_user *prev = NULL, *cur = NULL;
 
        if (gH323Debug)
-               ast_verbose("---   ooh323_delete_user\n");
+               ast_verb(0, "---   ooh323_delete_user\n");
 
        if (user) {     
                cur = userl.users;
@@ -2188,7 +2192,7 @@ int onCallCleared(ooCallData *call)
        }  
 
        if (gH323Debug)
-               ast_verbose("+++   ooh323_delete_user\n");
+               ast_verb(0, "+++   ooh323_delete_user\n");
 
 } */
 
@@ -2197,7 +2201,7 @@ void ooh323_delete_peer(struct ooh323_peer *peer)
        struct ooh323_peer *prev = NULL, *cur = NULL;
 
        if (gH323Debug)
-               ast_verbose("---   ooh323_delete_peer\n");
+               ast_verb(0, "---   ooh323_delete_peer\n");
 
        if (peer) {     
       cur = peerl.peers;
@@ -2226,7 +2230,7 @@ void ooh323_delete_peer(struct ooh323_peer *peer)
        }  
 
        if (gH323Debug)
-               ast_verbose("+++   ooh323_delete_peer\n");
+               ast_verb(0, "+++   ooh323_delete_peer\n");
 
 }
 
@@ -2237,7 +2241,7 @@ static struct ooh323_user *build_user(const char *name, struct ast_variable *v)
        struct ooh323_user *user = NULL;
 
        if (gH323Debug)
-               ast_verbose("---   build_user\n");
+               ast_verb(0, "---   build_user\n");
 
        user = ast_calloc(1,sizeof(struct ooh323_user));
        if (user) {
@@ -2366,7 +2370,7 @@ static struct ooh323_user *build_user(const char *name, struct ast_variable *v)
        }
 
        if (gH323Debug)
-               ast_verbose("+++   build_user\n");
+               ast_verb(0, "+++   build_user\n");
 
        return user;
 }
@@ -2376,7 +2380,7 @@ static struct ooh323_peer *build_peer(const char *name, struct ast_variable *v,
        struct ooh323_peer *peer = NULL;
 
        if (gH323Debug)
-               ast_verbose("---   build_peer\n");
+               ast_verb(0, "---   build_peer\n");
 
        peer = ast_calloc(1, sizeof(*peer));
        if (peer) {
@@ -2534,7 +2538,7 @@ static struct ooh323_peer *build_peer(const char *name, struct ast_variable *v,
        }
 
        if (gH323Debug)
-               ast_verbose("+++   build_peer\n");
+               ast_verb(0, "+++   build_peer\n");
 
        return peer;
 }
@@ -2542,13 +2546,13 @@ static struct ooh323_peer *build_peer(const char *name, struct ast_variable *v,
 static int ooh323_do_reload(void)
 {
        if (gH323Debug) {
-               ast_verbose("---   ooh323_do_reload\n");
+               ast_verb(0, "---   ooh323_do_reload\n");
        }
 
        reload_config(1);
 
        if (gH323Debug) {
-               ast_verbose("+++   ooh323_do_reload\n");
+               ast_verb(0, "+++   ooh323_do_reload\n");
        }
 
        return 0;
@@ -2574,11 +2578,11 @@ char *handle_cli_ooh323_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_
                return CLI_SHOWUSAGE;
 
        if (gH323Debug)
-               ast_verbose("---   ooh323_reload\n");
+               ast_verb(0, "---   ooh323_reload\n");
 
        ast_mutex_lock(&h323_reload_lock);
        if (h323_reloading) {
-               ast_verbose("Previous OOH323 reload not yet done\n");
+               ast_verb(0, "Previous OOH323 reload not yet done\n");
    } else {
                h323_reloading = 1;
        }
@@ -2586,7 +2590,7 @@ char *handle_cli_ooh323_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_
        restart_monitor();
 
        if (gH323Debug)
-               ast_verbose("+++   ooh323_reload\n");
+               ast_verb(0, "+++   ooh323_reload\n");
 
        return 0;
 }
@@ -2605,7 +2609,7 @@ int reload_config(int reload)
        struct ast_format tmpfmt;
 
        if (gH323Debug)
-               ast_verbose("---   reload_config\n");
+               ast_verb(0, "---   reload_config\n");
 
        cfg = ast_config_load((char*)config, config_flags);
 
@@ -2620,7 +2624,7 @@ int reload_config(int reload)
                delete_users();
                delete_peers();
                if (gH323Debug) {
-                       ast_verbose("  reload_config - Freeing up alias list\n");
+                       ast_verb(0, "  reload_config - Freeing up alias list\n");
                }
                cur = gAliasList;
                while (cur) {
@@ -2788,8 +2792,7 @@ int reload_config(int reload)
          strncpy(gLogFile, v->value, sizeof(gLogFile)-1);
                } else if (!strcasecmp(v->name, "context")) {
          strncpy(gContext, v->value, sizeof(gContext)-1);
-         ast_verbose(VERBOSE_PREFIX_3 "  == Setting default context to %s\n", 
-                                                      gContext);
+         ast_verb(3, "  == Setting default context to %s\n", gContext);
                } else if (!strcasecmp(v->name, "rtptimeout")) {
                        gRTPTimeout = atoi(v->value);
                        if (gRTPTimeout <= 0)
@@ -2926,7 +2929,7 @@ int reload_config(int reload)
        }
 
        if (gH323Debug)
-               ast_verbose("+++   reload_config\n");
+               ast_verb(0, "+++   reload_config\n");
 
        return 0;
 
@@ -3760,10 +3763,10 @@ int ooh323_destroy(struct ooh323_pvt *p)
        struct ooh323_user *user = NULL;
 
        if (gH323Debug) {
-               ast_verbose("---   ooh323_destroy \n");
+               ast_verb(0, "---   ooh323_destroy \n");
 
                if (p)
-                       ast_verbose(" Destroying %s\n", p->username);
+                       ast_verb(0, " Destroying %s\n", p->username);
        }
 
        cur = iflist;
@@ -3782,7 +3785,7 @@ int ooh323_destroy(struct ooh323_pvt *p)
 
                if (cur->callToken) {
                        if (gH323Debug) 
-                               ast_verbose(" Destroying %s\n", cur->callToken);
+                               ast_verb(0, " Destroying %s\n", cur->callToken);
                        ast_free(cur->callToken);
                        cur->callToken = 0;
                }
@@ -3858,7 +3861,7 @@ int ooh323_destroy(struct ooh323_pvt *p)
        }
 
        if (gH323Debug)
-               ast_verbose("+++   ooh323_destroy\n");
+               ast_verb(0, "+++   ooh323_destroy\n");
 
        return 0;
 }
@@ -3935,7 +3938,7 @@ static int unload_module(void)
        struct ooAliases *cur = NULL, *prev = NULL;
 
        if (gH323Debug) {
-               ast_verbose("--- ooh323  unload_module \n");
+               ast_verb(0, "--- ooh323  unload_module \n");
        }
        /* First, take us out of the channel loop */
        ast_cli_unregister_multiple(cli_ooh323, sizeof(cli_ooh323) / sizeof(struct ast_cli_entry));
@@ -3947,7 +3950,7 @@ static int unload_module(void)
 #endif
 
        if (gH323Debug) {
-               ast_verbose("  unload_module - hanging up all interfaces\n");
+               ast_verb(0, "  unload_module - hanging up all interfaces\n");
        }
        if (!ast_mutex_lock(&iflock)) {
                /* Hangup all interfaces if they have an owner */
@@ -3967,7 +3970,7 @@ static int unload_module(void)
 
 
        if (gH323Debug) {
-               ast_verbose("  unload_module - stopping monitor thread\n");
+               ast_verb(0, "  unload_module - stopping monitor thread\n");
        }  
        if (monitor_thread != AST_PTHREADT_NULL) {
                if (!ast_mutex_lock(&monlock)) {
@@ -3986,13 +3989,13 @@ static int unload_module(void)
 
 
        if (gH323Debug) {
-               ast_verbose("   unload_module - stopping stack thread\n");
+               ast_verb(0, "   unload_module - stopping stack thread\n");
        }
        ooh323c_stop_stack_thread();
 
 
        if (gH323Debug) {
-               ast_verbose("   unload_module - freeing up memory used by interfaces\n");
+               ast_verb(0, "   unload_module - freeing up memory used by interfaces\n");
        }
        if (!ast_mutex_lock(&iflock)) {
                struct ooh323_pvt *pl;
@@ -4014,19 +4017,19 @@ static int unload_module(void)
  
 
        if (gH323Debug) {
-               ast_verbose("  unload_module - deleting users\n");
+               ast_verb(0, "  unload_module - deleting users\n");
        }
        delete_users();
 
 
        if (gH323Debug) {
-               ast_verbose("  unload_module - deleting peers\n");
+               ast_verb(0, "  unload_module - deleting peers\n");
        }
        delete_peers();
 
 
        if (gH323Debug) {
-               ast_verbose("  unload_module - Freeing up alias list\n");
+               ast_verb(0, "  unload_module - Freeing up alias list\n");
        }
        cur = gAliasList;
        while (cur) {
@@ -4039,12 +4042,12 @@ static int unload_module(void)
 
 
        if (gH323Debug) {
-               ast_verbose("   unload_module- destroying OOH323 endpoint \n");
+               ast_verb(0, "   unload_module- destroying OOH323 endpoint \n");
        }
        ooH323EpDestroy();
 
        if (gH323Debug) {
-               ast_verbose("+++ ooh323  unload_module \n");
+               ast_verb(0, "+++ ooh323  unload_module \n");
        }
 
        gCap = ast_format_cap_destroy(gCap);
@@ -4158,7 +4161,7 @@ static int ooh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance
        int mode;
 
        if (gH323Debug)
-               ast_verbose("---   ooh323_set_peer - %s\n", chan->name);
+               ast_verb(0, "---   ooh323_set_peer - %s\n", chan->name);
 
        if (!rtp) {
                return 0;
@@ -4194,7 +4197,7 @@ int configure_local_rtp(struct ooh323_pvt *p, ooCallData *call)
        ast_format_clear(&tmpfmt);
 
        if (gH323Debug)
-               ast_verbose("---   configure_local_rtp\n");
+               ast_verb(0, "---   configure_local_rtp\n");
 
 
        if (ast_parse_arg(call->localIP, PARSE_ADDR, &tmp)) {
@@ -4262,7 +4265,7 @@ int configure_local_rtp(struct ooh323_pvt *p, ooCallData *call)
 
        if (p->rtdrcount) {
                if (gH323Debug)
-                       ast_verbose("Setup RTDR info: %d, %d\n", p->rtdrinterval, p->rtdrcount);
+                       ast_verb(0, "Setup RTDR info: %d, %d\n", p->rtdrinterval, p->rtdrcount);
                call->rtdrInterval = p->rtdrinterval;
                call->rtdrCount = p->rtdrcount;
        }
@@ -4307,7 +4310,7 @@ int configure_local_rtp(struct ooh323_pvt *p, ooCallData *call)
        }
 
        if (gH323Debug)
-               ast_verbose("+++   configure_local_rtp\n");
+               ast_verb(0, "+++   configure_local_rtp\n");
 
        return 1;
 }
@@ -4319,7 +4322,7 @@ void setup_rtp_connection(ooCallData *call, const char *remoteIp,
        struct ast_sockaddr tmp;
 
        if (gH323Debug)
-               ast_verbose("---   setup_rtp_connection %s:%d\n", remoteIp, remotePort);
+               ast_verb(0, "---   setup_rtp_connection %s:%d\n", remoteIp, remotePort);
 
        /* Find the call or allocate a private structure if call not found */
        p = find_call(call); 
@@ -4338,7 +4341,7 @@ void setup_rtp_connection(ooCallData *call, const char *remoteIp,
                                                        "audio", "G726-32", AST_RTP_OPT_G726_NONSTANDARD);
 
        if(gH323Debug)
-               ast_verbose("+++   setup_rtp_connection\n");
+               ast_verb(0, "+++   setup_rtp_connection\n");
 
        return;
 }
@@ -4348,7 +4351,7 @@ void close_rtp_connection(ooCallData *call)
        struct ooh323_pvt *p = NULL;
 
    if(gH323Debug)
-               ast_verbose("---   close_rtp_connection\n");
+               ast_verb(0, "---   close_rtp_connection\n");
 
        p = find_call(call);
        if (!p) {
@@ -4363,7 +4366,7 @@ void close_rtp_connection(ooCallData *call)
        ast_mutex_unlock(&p->lock);
 
    if(gH323Debug)
-               ast_verbose("+++   close_rtp_connection\n");
+               ast_verb(0, "+++   close_rtp_connection\n");
 
        return;
 }
@@ -4414,7 +4417,7 @@ void setup_udptl_connection(ooCallData *call, const char *remoteIp,
        struct ast_sockaddr them;
 
        if (gH323Debug)
-               ast_verbose("---   setup_udptl_connection\n");
+               ast_verb(0, "---   setup_udptl_connection\n");
 
        /* Find the call or allocate a private structure if call not found */
        p = find_call(call); 
@@ -4463,7 +4466,7 @@ void setup_udptl_connection(ooCallData *call, const char *remoteIp,
        ast_mutex_unlock(&p->lock);
 
        if(gH323Debug)
-               ast_verbose("+++   setup_udptl_connection\n");
+               ast_verb(0, "+++   setup_udptl_connection\n");
 
        return;
 }
@@ -4473,7 +4476,7 @@ void close_udptl_connection(ooCallData *call)
        struct ooh323_pvt *p = NULL;
 
        if(gH323Debug)
-               ast_verbose("---   close_udptl_connection\n");
+               ast_verb(0, "---   close_udptl_connection\n");
 
        p = find_call(call);
        if (!p) {
@@ -4509,7 +4512,7 @@ void close_udptl_connection(ooCallData *call)
        ast_mutex_unlock(&p->lock);
 
        if(gH323Debug)
-               ast_verbose("+++   close_udptl_connection\n");
+               ast_verb(0, "+++   close_udptl_connection\n");
 
        return;
 }
@@ -4600,7 +4603,7 @@ struct ast_frame *ooh323_rtp_read(struct ast_channel *ast, struct ooh323_pvt *p)
                /* Switch to T.38 ON CED*/
                if (!p->faxmode && !p->chmodepend && (dfr->subclass.integer == 'e') && (p->t38support != T38_DISABLED)) {
                        if (gH323Debug)
-                               ast_verbose("request to change %s to t.38 because fax ced\n", p->callToken);
+                               ast_verb(0, "request to change %s to t.38 because fax ced\n", p->callToken);
                        p->chmodepend = 1;
                        p->faxdetected = 1;
                        ooRequestChangeMode(p->callToken, 1);
index d393de6..f011e0d 100644 (file)
@@ -1379,8 +1379,7 @@ static int load_module(void)
        parse_config(0);
 
        ast_config_engine_register(&mysql_engine);
-       if (option_verbose > 1)
-               ast_verbose(VERBOSE_PREFIX_2 "MySQL RealTime driver loaded.\n");
+       ast_verb(2, "MySQL RealTime driver loaded.\n");
        ast_cli_register_multiple(cli_realtime_mysql_status, sizeof(cli_realtime_mysql_status) / sizeof(struct ast_cli_entry));
        return 0;
 }
@@ -1392,8 +1391,7 @@ static int unload_module(void)
 
        ast_cli_unregister_multiple(cli_realtime_mysql_status, sizeof(cli_realtime_mysql_status) / sizeof(struct ast_cli_entry));
        ast_config_engine_deregister(&mysql_engine);
-       if (option_verbose > 1)
-               ast_verbose(VERBOSE_PREFIX_2 "MySQL RealTime unloaded.\n");
+       ast_verb(2, "MySQL RealTime unloaded.\n");
 
        ast_module_user_hangup_all();
 
index f370836..6722040 100644 (file)
@@ -2254,8 +2254,7 @@ char s1[256];
 static char *cs_keywords[] = {"rptena","rptdis","apena","apdis","lnkena","lnkdis","totena","totdis","skena","skdis",
                                "ufena","ufdis","atena","atdis",NULL};
 
-       if (option_verbose > 2)
-               ast_verbose(VERBOSE_PREFIX_3 "%s config for repeater %s\n",
+       ast_verb(3, "%s config for repeater %s\n",
                        (init) ? "Loading initial" : "Re-Loading",rpt_vars[n].name);
        ast_mutex_lock(&rpt_vars[n].lock);
        if (rpt_vars[n].cfg) ast_config_destroy(rpt_vars[n].cfg);
@@ -10411,9 +10410,8 @@ static int attempt_reconnect(struct rpt *myrpt, struct rpt_link *l)
 #endif
                l->chan->appl = "Apprpt";
                l->chan->data = "(Remote Rx)";
-               if (option_verbose > 2)
-                       ast_verbose(VERBOSE_PREFIX_3 "rpt (attempt_reconnect) initiating call to %s/%s on %s\n",
-                               deststr, tele, l->chan->name);
+               ast_verb(3, "rpt (attempt_reconnect) initiating call to %s/%s on %s\n",
+                       deststr, tele, l->chan->name);
                l->chan->caller.id.number.valid = 1;
                ast_free(l->chan->caller.id.number.str);
                l->chan->caller.id.number.str = ast_strdup(myrpt->name);
@@ -10422,9 +10420,8 @@ static int attempt_reconnect(struct rpt *myrpt, struct rpt_link *l)
        }
        else 
        {
-               if (option_verbose > 2)
-                       ast_verbose(VERBOSE_PREFIX_3 "Unable to place call to %s/%s on %s\n",
-                               deststr,tele,l->chan->name);
+               ast_verb(3, "Unable to place call to %s/%s on %s\n",
+                       deststr,tele,l->chan->name);
                return -1;
        }
        rpt_mutex_lock(&myrpt->lock);
@@ -10848,8 +10845,7 @@ struct ast_format_cap *cap = NULL;
 #endif
                myrpt->rxchannel->appl = "Apprpt";
                myrpt->rxchannel->data = "(Repeater Rx)";
-               if (option_verbose > 2)
-                       ast_verbose(VERBOSE_PREFIX_3 "rpt (Rx) initiating call to %s/%s on %s\n",
+               ast_verb(3, "rpt (Rx) initiating call to %s/%s on %s\n",
                                tmpstr,tele,myrpt->rxchannel->name);
                ast_call(myrpt->rxchannel,tele,999);
                if (myrpt->rxchannel->_state != AST_STATE_UP)
@@ -10907,8 +10903,7 @@ struct ast_format_cap *cap = NULL;
 #endif
                        myrpt->txchannel->appl = "Apprpt";
                        myrpt->txchannel->data = "(Repeater Tx)";
-                       if (option_verbose > 2)
-                               ast_verbose(VERBOSE_PREFIX_3 "rpt (Tx) initiating call to %s/%s on %s\n",
+                       ast_verb(3, "rpt (Tx) initiating call to %s/%s on %s\n",
                                        tmpstr,tele,myrpt->txchannel->name);
                        ast_call(myrpt->txchannel,tele,999);
                        if (myrpt->rxchannel->_state != AST_STATE_UP)
@@ -13447,14 +13442,12 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
                        chan->priority++;
                }
 
-               if(option_verbose > 2) {
-                       ast_verbose(VERBOSE_PREFIX_3 "Return Context: (%s,%s,%d) ID: %s\n",
-                               chan->context, chan->exten, chan->priority,
-                               S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""));
-                       if(!ast_exists_extension(chan, chan->context, chan->exten, chan->priority,
-                               S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
-                               ast_verbose( VERBOSE_PREFIX_3 "Warning: Return Context Invalid, call will return to default|s\n");
-                       }
+               ast_verb(3, "Return Context: (%s,%s,%d) ID: %s\n",
+                       chan->context, chan->exten, chan->priority,
+                       S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""));
+               if (!ast_exists_extension(chan, chan->context, chan->exten, chan->priority,
+                       S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
+                       ast_verb(3, "Warning: Return Context Invalid, call will return to default|s\n");
                }
   
                /* we are using masq_park here to protect * from touching the channel once we park it.  If the channel comes out of timeout
@@ -13462,7 +13455,7 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
 
                ast_masq_park_call(chan, NULL, timeout, &lot);
 
-               if (option_verbose > 2) ast_verbose( VERBOSE_PREFIX_3 "Call Parking Called, lot: %d, timeout: %d, context: %s\n", lot, timeout, return_context);
+               ast_verb(3, "Call Parking Called, lot: %d, timeout: %d, context: %s\n", lot, timeout, return_context);
 
                snprintf(buffer, sizeof(buffer) - 1, "%d,%s", lot, template + 1);
 
@@ -13833,9 +13826,8 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
 #endif
                myrpt->rxchannel->appl = "Apprpt";
                myrpt->rxchannel->data = "(Link Rx)";
-               if (option_verbose > 2)
-                       ast_verbose(VERBOSE_PREFIX_3 "rpt (Rx) initiating call to %s/%s on %s\n",
-                               myrpt->rxchanname,tele,myrpt->rxchannel->name);
+               ast_verb(3, "rpt (Rx) initiating call to %s/%s on %s\n",
+                       myrpt->rxchanname,tele,myrpt->rxchannel->name);
                rpt_mutex_unlock(&myrpt->lock);
                ast_call(myrpt->rxchannel,tele,999);
                rpt_mutex_lock(&myrpt->lock);
@@ -13876,9 +13868,8 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
 #endif
                        myrpt->txchannel->appl = "Apprpt";
                        myrpt->txchannel->data = "(Link Tx)";
-                       if (option_verbose > 2)
-                               ast_verbose(VERBOSE_PREFIX_3 "rpt (Tx) initiating call to %s/%s on %s\n",
-                                       myrpt->txchanname,tele,myrpt->txchannel->name);
+                       ast_verb(3, "rpt (Tx) initiating call to %s/%s on %s\n",
+                               myrpt->txchanname,tele,myrpt->txchannel->name);
                        rpt_mutex_unlock(&myrpt->lock);
                        ast_call(myrpt->txchannel,tele,999);
                        rpt_mutex_lock(&myrpt->lock);
index ca1a010..c8c6461 100644 (file)
@@ -103,19 +103,19 @@ static int verbose_exec(struct ast_channel *chan, const char *data)
        if (option_verbose >= vsize) {
                switch (vsize) {
                case 0:
-                       ast_verbose("%s\n", args.msg);
+                       ast_verb(0, "%s\n", args.msg);
                        break;
                case 1:
-                       ast_verbose(VERBOSE_PREFIX_1 "%s\n", args.msg);
+                       ast_verb(1, "%s\n", args.msg);
                        break;
                case 2:
-                       ast_verbose(VERBOSE_PREFIX_2 "%s\n", args.msg);
+                       ast_verb(2, "%s\n", args.msg);
                        break;
                case 3:
-                       ast_verbose(VERBOSE_PREFIX_3 "%s\n", args.msg);
+                       ast_verb(3, "%s\n", args.msg);
                        break;
                default:
-                       ast_verbose(VERBOSE_PREFIX_4 "%s\n", args.msg);
+                       ast_verb(4, "%s\n", args.msg);
                }
        }
 
index be604f0..c43a0ce 100644 (file)
@@ -13044,16 +13044,14 @@ static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num,
                }
                
        } else {
-               if (option_verbose > 2)
-                       ast_verbose( VERBOSE_PREFIX_3 "Destination number is CID number '%s'\n", num);
+               ast_verb(3, "Destination number is CID number '%s'\n", num);
                ast_copy_string(destination, num, sizeof(destination));
        }
 
        if (!ast_strlen_zero(destination)) {
                if (destination[strlen(destination) -1 ] == '*')
                        return 0; 
-               if (option_verbose > 2)
-                       ast_verbose( VERBOSE_PREFIX_3 "Placing outgoing call to extension '%s' in context '%s' from context '%s'\n", destination, outgoing_context, chan->context);
+               ast_verb(3, "Placing outgoing call to extension '%s' in context '%s' from context '%s'\n", destination, outgoing_context, chan->context);
                ast_copy_string(chan->exten, destination, sizeof(chan->exten));
                ast_copy_string(chan->context, outgoing_context, sizeof(chan->context));
                chan->priority = 0;
@@ -13388,11 +13386,11 @@ static int play_record_review(struct ast_channel *chan, char *playfile, char *re
                        if (outsidecaller) {  /* only mark vm messages */
                                /* Mark Urgent */
                                if ((flag && ast_strlen_zero(flag)) || (!ast_strlen_zero(flag) && strcmp(flag, "Urgent"))) {
-                                       ast_verbose(VERBOSE_PREFIX_3 "marking message as Urgent\n");
+                                       ast_verb(3, "marking message as Urgent\n");
                                        res = ast_play_and_wait(chan, "vm-marked-urgent");
                                        strcpy(flag, "Urgent");
                                } else if (flag) {
-                                       ast_verbose(VERBOSE_PREFIX_3 "UNmarking message as Urgent\n");
+                                       ast_verb(3, "UNmarking message as Urgent\n");
                                        res = ast_play_and_wait(chan, "vm-urgent-removed");
                                        strcpy(flag, "");
                                } else {
index a20d931..3b3a346 100644 (file)
@@ -7471,7 +7471,7 @@ static struct ast_frame *sip_read(struct ast_channel *ast)
                                S_COR(ast->caller.id.number.valid, ast->caller.id.number.str, NULL))) {
                                ast_channel_lock(ast);
                                sip_pvt_lock(p);
-                               ast_verbose(VERBOSE_PREFIX_2 "Redirecting '%s' to fax extension due to CNG detection\n", ast->name);
+                               ast_verb(2, "Redirecting '%s' to fax extension due to CNG detection\n", ast->name);
                                pbx_builtin_setvar_helper(ast, "FAXEXTEN", ast->exten);
                                if (ast_async_goto(ast, target_context, "fax", 1)) {
                                        ast_log(LOG_NOTICE, "Failed to async goto '%s' into fax of '%s'\n", ast->name, target_context);
@@ -9426,7 +9426,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
                                                ast_channel_unlock(p->owner);
                                                if (ast_exists_extension(p->owner, target_context, "fax", 1,
                                                        S_COR(p->owner->caller.id.number.valid, p->owner->caller.id.number.str, NULL))) {
-                                                       ast_verbose(VERBOSE_PREFIX_2 "Redirecting '%s' to fax extension due to peer T.38 re-INVITE\n", p->owner->name);
+                                                       ast_verb(2, "Redirecting '%s' to fax extension due to peer T.38 re-INVITE\n", p->owner->name);
                                                        pbx_builtin_setvar_helper(p->owner, "FAXEXTEN", p->owner->exten);
                                                        if (ast_async_goto(p->owner, target_context, "fax", 1)) {
                                                                ast_log(LOG_NOTICE, "Failed to async goto '%s' into fax of '%s'\n", p->owner->name, target_context);
@@ -14260,13 +14260,13 @@ static enum parse_register_result parse_register_contact(struct sip_pvt *pvt, st
        manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: SIP\r\nPeer: SIP/%s\r\nPeerStatus: Registered\r\nAddress: %s\r\n", peer->name,  ast_sockaddr_stringify(&peer->addr));
 
        /* Is this a new IP address for us? */
-       if (VERBOSITY_ATLEAST(2) && ast_sockaddr_cmp(&peer->addr, &oldsin)) {
-               ast_verbose(VERBOSE_PREFIX_3 "Registered SIP '%s' at %s\n", peer->name,
-                               ast_sockaddr_stringify(&peer->addr));
+       if (ast_sockaddr_cmp(&peer->addr, &oldsin)) {
+               ast_verb(3, "Registered SIP '%s' at %s\n", peer->name,
+                       ast_sockaddr_stringify(&peer->addr));
        }
        sip_poke_peer(peer, 0);
        register_peer_exten(peer, 1);
-       
+
        /* Save User agent */
        useragent = sip_get_header(req, "User-Agent");
        if (strcasecmp(useragent, peer->useragent)) {
index a61e21a..3799747 100644 (file)
@@ -5927,9 +5927,9 @@ static int handle_offhook_message(struct skinny_req *req, struct skinnysession *
        SKINNY_DEVONLY(if (skinnydebug > 1) {
                ast_verb(4, "Received OFFHOOK_MESSAGE from %s, instance=%d, callid=%d\n", d->name, instance, reference);
        })
-       
+
        if (d->hookstate == SKINNY_OFFHOOK) {
-               ast_verbose(VERBOSE_PREFIX_3 "Got offhook message when device (%s) already offhook\n", d->name);
+               ast_verb(3, "Got offhook message when device (%s) already offhook\n", d->name);
                return 0;
        }
 
index e89cf30..a6cc03a 100644 (file)
@@ -1546,8 +1546,7 @@ static int setformat(struct chan_usbradio_pvt *o, int mode)
                        /* Check to see if duplex set (FreeBSD Bug) */
                        res = ioctl(fd, SNDCTL_DSP_GETCAPS, &fmt);
                        if (res == 0 && (fmt & DSP_CAP_DUPLEX)) {
-                               if (option_verbose > 1)
-                                       ast_verbose(VERBOSE_PREFIX_2 "Console is full duplex\n");
+                               ast_verb(2, "Console is full duplex\n");
                                o->duplex = M_FULL;
                        };
                        break;
index 9e15d40..bca0256 100644 (file)
@@ -603,8 +603,7 @@ static int find_transcoders(void)
        }
 
        for (info.tcnum = 0; !(res = ioctl(fd, DAHDI_TC_GETINFO, &info)); info.tcnum++) {
-               if (option_verbose > 1)
-                       ast_verbose(VERBOSE_PREFIX_2 "Found transcoder '%s'.\n", info.name);
+               ast_verb(2, "Found transcoder '%s'.\n", info.name);
 
                /* Complex codecs need to support signed linear.  If the
                 * hardware transcoder does not natively support signed linear
@@ -628,8 +627,9 @@ static int find_transcoders(void)
 
        close(fd);
 
-       if (!info.tcnum && (option_verbose > 1))
-               ast_verbose(VERBOSE_PREFIX_2 "No hardware transcoders found.\n");
+       if (!info.tcnum) {
+               ast_verb(2, "No hardware transcoders found.\n");
+       }
 
        for (x = 0; x < 32; x++) {
                for (y = 0; y < 32; y++) {
index af1f90c..3f48507 100644 (file)
@@ -73,7 +73,7 @@
 ;    notice
 ;    warning
 ;    error
-;    verbose
+;    verbose(<level>)
 ;    dtmf
 ;    fax
 ;    security
 ; 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,
 ; most of which you are unlikely to understand without an understanding of
index 9363caa..a3e436d 100644 (file)
@@ -68,19 +68,20 @@ int logger_reload(void);
 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 abscence of a comma after the VERBOSE_PREFIX_3.  This is important.
-       VERBOSE_PREFIX_1 through VERBOSE_PREFIX_3 are defined.
+ *     \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, 4, 5))) __ast_verbose(const char *file, int line, const char *func, const char *fmt, ...);
+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__,  __VA_ARGS__)
+#define ast_verbose(...) __ast_verbose(__FILE__, __LINE__, __PRETTY_FUNCTION__, -1, __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);
+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__, fmt, ap)
+#define ast_verbose_ap(fmt, ap)        __ast_verbose_ap(__FILE__, __LINE__, __PRETTY_FUNCTION__, -1, fmt, ap)
 
 void __attribute__((format(printf, 2, 3))) ast_child_verbose(int level, const char *fmt, ...);
 
@@ -240,20 +241,7 @@ void ast_logger_unregister_level(const char *name);
 
 #define VERBOSITY_ATLEAST(level) (option_verbose >= (level) || (ast_opt_verb_module && ast_verbose_get_by_module(AST_MODULE) >= (level)))
 
-#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)
+#define ast_verb(level, ...) __ast_verbose(__FILE__, __LINE__, __PRETTY_FUNCTION__, level, __VA_ARGS__)
 
 #ifndef _LOGGER_BACKTRACE_H
 #define _LOGGER_BACKTRACE_H
index 16f3efa..acddc96 100644 (file)
@@ -1749,11 +1749,6 @@ static const char *fix_header(char *outbuf, int maxout, const char *s, char *cmp
 {
        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);
@@ -1762,10 +1757,25 @@ static const char *fix_header(char *outbuf, int maxout, const char *s, char *cmp
        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)) ||
@@ -1774,17 +1784,15 @@ static void console_verboser(const char *s)
                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)
+       if (ast_opt_console && consolethread != AST_PTHREADT_NULL) {
                pthread_kill(consolethread, SIGURG);
+       }
 }
 
 static int ast_all_zeros(char *s)
@@ -1829,8 +1837,26 @@ static int remoteconsolehandler(char *s)
                else
                        ast_safe_system(getenv("SHELL") ? getenv("SHELL") : "/bin/sh");
                ret = 1;
-       }
-       if ((strncasecmp(s, "quit", 4) == 0 || strncasecmp(s, "exit", 4) == 0) &&
+       } 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) &&
            (s[4] == '\0' || isspace(s[4]))) {
                quit_handler(0, 0, 0, 0);
                ret = 1;
@@ -2133,6 +2159,23 @@ static struct ast_cli_entry cli_asterisk[] = {
 #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;
@@ -2142,6 +2185,7 @@ static int ast_el_read_char(EditLine *editline, char *cp)
        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;
@@ -2166,11 +2210,13 @@ static int ast_el_read_char(EditLine *editline, char *cp)
                        num_read = read(STDIN_FILENO, cp, 1);
                        if (num_read < 1) {
                                break;
-                       } else 
+                       } else {
                                return (num_read);
+                       }
                }
                if (fds[0].revents) {
-                       char *tmp;
+                       char level = 0;
+                       char *curline = buf, *nextline;
                        res = read(ast_consock, buf, sizeof(buf) - 1);
                        /* if the remote side disappears exit */
                        if (res < 1) {
@@ -2203,22 +2249,35 @@ static int ast_el_read_char(EditLine *editline, char *cp)
 
                        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\e[0K", 5) < 0) {
                                }
                        }
-                       if (write(STDOUT_FILENO, buf, res) < 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++;
+                               }
+                               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 ((res < EL_BUF_SIZE - 1) && ((buf[res-1] == '\n') || (buf[res-2] == '\n'))) {
                                *cp = CC_REFRESH;
                                return(1);
@@ -2729,22 +2788,20 @@ static void ast_remotecontrol(char *data)
        else
                pid = -1;
        if (!data) {
-               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)
+               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;
@@ -2758,18 +2815,34 @@ static void ast_remotecontrol(char *data)
                        }
 
                        do {
+                               prev_linefull = linefull;
                                if ((nextline = strchr(curline, '\n'))) {
+                                       linefull = 1;
                                        nextline++;
                                } else {
+                                       linefull = 0;
                                        nextline = strchr(curline, '\0');
                                }
 
                                /* Skip verbose lines */
-                               if (*curline != 127) {
+                               /* 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;
                                        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));
@@ -2808,14 +2881,6 @@ static void ast_remotecontrol(char *data)
                        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));
index 503e865..5ae8617 100644 (file)
@@ -87,9 +87,7 @@ int __ast_bridge_technology_register(struct ast_bridge_technology *technology, s
 
        AST_RWLIST_UNLOCK(&bridge_technologies);
 
-       if (option_verbose > 1) {
-               ast_verbose(VERBOSE_PREFIX_2 "Registered bridge technology %s\n", technology->name);
-       }
+       ast_verb(2, "Registered bridge technology %s\n", technology->name);
 
        return 0;
 }
@@ -104,9 +102,7 @@ int ast_bridge_technology_unregister(struct ast_bridge_technology *technology)
        AST_RWLIST_TRAVERSE_SAFE_BEGIN(&bridge_technologies, current, entry) {
                if (current == technology) {
                        AST_RWLIST_REMOVE_CURRENT(entry);
-                       if (option_verbose > 1) {
-                               ast_verbose(VERBOSE_PREFIX_2 "Unregistered bridge technology %s\n", technology->name);
-                       }
+                       ast_verb(2, "Unregistered bridge technology %s\n", technology->name);
                        break;
                }
        }
index c35b941..9c66b67 100644 (file)
@@ -382,6 +382,20 @@ static char *complete_number(const char *partial, unsigned int min, unsigned int
        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)
 {
        int oldval;
@@ -1668,6 +1682,8 @@ static struct ast_cli_entry cli_cli[] = {
 
        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"),
index 6faf8f5..420ce19 100644 (file)
@@ -432,8 +432,7 @@ static void handle_frame(struct ast_dial *dial, struct ast_dial_channel *channel
                        ast_indicate(chan, AST_CONTROL_VIDUPDATE);
                        break;
                case AST_CONTROL_SRCUPDATE:
-                       if (option_verbose > 2)
-                               ast_verbose (VERBOSE_PREFIX_3 "%s requested a source update, passing it to %s\n", channel->owner->name, chan->name);
+                       ast_verb(3, "%s requested a source update, passing it to %s\n", channel->owner->name, chan->name);
                        ast_indicate(chan, AST_CONTROL_SRCUPDATE);
                        break;
                case AST_CONTROL_CONNECTED_LINE:
index 6fc36df..74b7dd1 100644 (file)
@@ -101,6 +101,8 @@ struct logchannel {
        int disabled;
        /*! syslog facility */
        int facility;
+       /*! Verbosity level */
+       int verbosity;
        /*! Type of log channel */
        enum logtypes type;
        /*! logfile logging file pointer */
@@ -209,19 +211,24 @@ AST_THREADSTORAGE(log_buf);
 
 static void logger_queue_init(void);
 
-static unsigned int make_components(const char *s, int lineno)
+static unsigned int make_components(const char *s, int lineno, int *verbosity)
 {
        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])) {
                                res |= (1 << x);
@@ -300,7 +307,7 @@ static struct logchannel *make_logchannel(const char *channel, const char *compo
                }
                chan->type = LOGTYPE_FILE;
        }
-       chan->logmask = make_components(chan->components, lineno);
+       chan->logmask = make_components(chan->components, lineno, &chan->verbosity);
 
        return chan;
 }
@@ -434,11 +441,6 @@ void ast_child_verbose(int level, const char *fmt, ...)
        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);
        if ((size = vsnprintf(msg, 0, fmt, ap)) < 0) {
@@ -968,15 +970,23 @@ static void ast_log_vsyslog(struct logmsg *msg)
        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)
@@ -990,8 +1000,13 @@ static void logger_print_normal(struct logmsg *logmsg)
        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);
@@ -1219,20 +1234,11 @@ void ast_log(int level, const char *file, int line, const char *function, const
                }
                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);
@@ -1492,13 +1498,31 @@ void ast_backtrace(void)
 #endif /* defined(HAVE_BKTR) */
 }
 
-void __ast_verbose_ap(const char *file, int line, const char *func, const char *fmt, va_list ap)
+void __ast_verbose_ap(const char *file, int line, const char *func, int level, 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;
@@ -1509,12 +1533,12 @@ void __ast_verbose_ap(const char *file, int line, const char *func, const char *
                now = ast_tvnow();
                ast_localtime(&now, &tm, NULL);
                ast_strftime(date, sizeof(date), dateformat, &tm);
-               datefmt = alloca(strlen(date) + 3 + strlen(fmt) + 1);
-               sprintf(datefmt, "%c[%s] %s", 127, date, fmt);
+               datefmt = alloca(strlen(date) + 3 + strlen(prefix) + strlen(fmt) + 1);
+               sprintf(datefmt, "%c[%s] %s%s", (char) magic, date, prefix, fmt);
                fmt = datefmt;
        } else {
-               char *tmp = alloca(strlen(fmt) + 2);
-               sprintf(tmp, "%c%s", 127, fmt);
+               char *tmp = alloca(strlen(prefix) + strlen(fmt) + 2);
+               sprintf(tmp, "%c%s%s", (char) magic, prefix, fmt);
                fmt = tmp;
        }
 
@@ -1522,18 +1546,19 @@ void __ast_verbose_ap(const char *file, int line, const char *func, const char *
        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, const char *fmt, ...)
+void __ast_verbose(const char *file, int line, const char *func, int level, const char *fmt, ...)
 {
        va_list ap;
 
        va_start(ap, fmt);
-       __ast_verbose_ap(file, line, func, fmt, ap);
+       __ast_verbose_ap(file, line, func, level, fmt, ap);
        va_end(ap);
 }
 
@@ -1545,7 +1570,7 @@ void ast_verbose(const char *fmt, ...)
        va_list ap;
 
        va_start(ap, fmt);
-       __ast_verbose_ap("", 0, "", fmt, ap);
+       __ast_verbose_ap("", 0, "", 0, fmt, ap);
        va_end(ap);
 }
 
@@ -1592,7 +1617,7 @@ static void update_logchannels(void)
        global_logmask = 0;
 
        AST_RWLIST_TRAVERSE(&logchannels, cur, list) {
-               cur->logmask = make_components(cur->components, cur->lineno);
+               cur->logmask = make_components(cur->components, cur->lineno, &cur->verbosity);
                global_logmask |= cur->logmask;
        }
 
index e242b65..4c04b79 100644 (file)
@@ -1233,7 +1233,7 @@ static int ast_say_number_full_he(struct ast_channel *chan, int num, const char
 
        char fn[SAY_NUM_BUF_SIZE] = "";
 
-       ast_verbose(VERBOSE_PREFIX_3 "ast_say_digits_full: started. num: %d, options=\"%s\"\n", num, options);
+       ast_verb(3, "ast_say_digits_full: started. num: %d, options=\"%s\"\n", num, options);
 
        if (!num) {
                return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
@@ -1241,7 +1241,7 @@ static int ast_say_number_full_he(struct ast_channel *chan, int num, const char
        if (options && !strncasecmp(options, "m", 1)) {
                mf = 1;
        }
-       ast_verbose(VERBOSE_PREFIX_3 "ast_say_digits_full: num: %d, state=%d, options=\"%s\", mf=%d\n", num, state, options, mf);
+       ast_verb(3, "ast_say_digits_full: num: %d, state=%d, options=\"%s\", mf=%d\n", num, state, options, mf);
 
        /* Do we have work to do? */
        while (!res && (num || (state > 0))) {
@@ -1252,7 +1252,7 @@ static int ast_say_number_full_he(struct ast_channel *chan, int num, const char
                 * state==0 is the normal mode and it means that we continue
                 * to check if the number num has yet anything left.
                 */
-               ast_verbose(VERBOSE_PREFIX_3 "ast_say_digits_full: num: %d, state=%d, options=\"%s\", mf=%d, tmpnum=%d\n", num, state, options, mf, tmpnum);
+               ast_verb(3, "ast_say_digits_full: num: %d, state=%d, options=\"%s\", mf=%d, tmpnum=%d\n", num, state, options, mf, tmpnum);
 
                if (state == 1) {
                        state = 0;
@@ -3200,13 +3200,13 @@ static int ast_say_enumeration_full_he(struct ast_channel *chan, int num, const
        int res = 0;
        char fn[256] = "";
        int mf = -1;                            /* +1 = Masculin; -1 = Feminin */
-       ast_verbose(VERBOSE_PREFIX_3 "ast_say_digits_full: started. num: %d, options=\"%s\"\n", num, options);
+       ast_verb(3, "ast_say_digits_full: started. num: %d, options=\"%s\"\n", num, options);
 
        if (options && !strncasecmp(options, "m", 1)) {
                mf = -1;
        }
 
-       ast_verbose(VERBOSE_PREFIX_3 "ast_say_digits_full: num: %d, options=\"%s\", mf=%d\n", num, options, mf);
+       ast_verb(3, "ast_say_digits_full: num: %d, options=\"%s\", mf=%d\n", num, options, mf);
 
        while (!res && num) {
                if (num < 0) {
index d67f3ba..123fe5a 100644 (file)
@@ -211,7 +211,7 @@ static void load_config(int reload)
 
                        ast_cli_register(&alias->cli_entry);
                        ao2_link(cli_aliases, alias);
-                       ast_verbose(VERBOSE_PREFIX_2 "Aliased CLI command '%s' to '%s'\n", v1->name, v1->value);
+                       ast_verb(2, "Aliased CLI command '%s' to '%s'\n", v1->name, v1->value);
                        ao2_ref(alias, -1);
                }
        }
index 3b1abd2..bb26328 100644 (file)
@@ -3322,7 +3322,7 @@ static struct ast_frame *fax_detect_framehook(struct ast_channel *chan, struct a
                        if (ast_exists_extension(chan, target_context, "fax", 1,
                            S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
                                ast_channel_lock(chan);
-                               ast_verbose(VERBOSE_PREFIX_2 "Redirecting '%s' to fax extension due to %s detection\n",
+                               ast_verb(2, "Redirecting '%s' to fax extension due to %s detection\n",
                                        chan->name, (result == 'f') ? "CNG" : "T38");
                                pbx_builtin_setvar_helper(chan, "FAXEXTEN", chan->exten);
                                if (ast_async_goto(chan, target_context, "fax", 1)) {
index 870508d..f1e9c74 100644 (file)
@@ -2615,9 +2615,7 @@ static void aji_handle_subscribe(struct aji_client *client, ikspak *pak)
                        ASTOBJ_UNREF(buddy, ast_aji_buddy_destroy);
                }
        default:
-               if (option_verbose > 4) {
-                       ast_verbose(VERBOSE_PREFIX_3 "JABBER: This is a subcription of type %i\n", pak->subtype);
-               }
+               ast_verb(5, "JABBER: This is a subcription of type %i\n", pak->subtype);
        }
 }
 
index d5f9e2c..ffe051e 100644 (file)
@@ -268,9 +268,7 @@ static void moh_files_release(struct ast_channel *chan, void *data)
                chan->stream = NULL;
        }
        
-       if (option_verbose > 2) {
-               ast_verbose(VERBOSE_PREFIX_3 "Stopped music on hold on %s\n", chan->name);
-       }
+       ast_verb(3, "Stopped music on hold on %s\n", chan->name);
 
        ast_format_clear(&state->mohwfmt); /* make sure to clear this format before restoring the original format. */
        if (state->origwfmt.id && ast_set_write_format(chan, &state->origwfmt)) {
@@ -1154,10 +1152,8 @@ static int init_files_class(struct mohclass *class)
        }
 
        if (!res) {
-               if (option_verbose > 2) {
-                       ast_verbose(VERBOSE_PREFIX_3 "Files not found in %s for moh class:%s\n",
-                                       class->dir, class->name);
-               }
+               ast_verb(3, "Files not found in %s for moh class:%s\n",
+                       class->dir, class->name);
                return -1;
        }