* 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 -------------------
------------------------------------------------------------------------------
===
===========================================================
-From 10 to 12:
+From 10 to 11:
func_enum:
- ENUM query functions now return a count of -1 on lookup error to
- 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.
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 */
if(ch) ast_channel_unlock(ch);
- if (gH323Debug)
- ast_verbose("+++ h323_new\n");
+ if (gH323Debug) {
+ ast_verb(0, "+++ h323_new\n");
+ }
return ch;
}
{
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");
iflist = pvt;
ast_mutex_unlock(&iflock);
- if (gH323Debug)
- ast_verbose("+++ ooh323_alloc\n");
+ if (gH323Debug) {
+ ast_verb(0, "+++ ooh323_alloc\n");
+ }
return pvt;
}
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))) {
restart_monitor();
if (gH323Debug)
- ast_verbose("+++ ooh323_request\n");
+ ast_verb(0, "+++ ooh323_request\n");
return chan;
struct ooh323_pvt *p;
if (gH323Debug)
- ast_verbose("--- find_call\n");
+ ast_verb(0, "--- find_call\n");
ast_mutex_lock(&iflock);
ast_mutex_unlock(&iflock);
if (gH323Debug)
- ast_verbose("+++ find_call\n");
+ ast_verb(0, "+++ find_call\n");
return p;
}
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);
ast_mutex_unlock(&userl.lock);
if (gH323Debug)
- ast_verbose("+++ find_user\n");
+ ast_verb(0, "+++ find_user\n");
return user;
}
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)) {
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;
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;
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;
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");
}
ast_mutex_unlock(&p->lock);
if (gH323Debug)
- ast_verbose("+++ ooh323_digit_begin\n");
+ ast_verb(0, "+++ ooh323_digit_begin\n");
return 0;
}
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");
ast_mutex_unlock(&p->lock);
if (gH323Debug)
- ast_verbose("+++ ooh323_digit_end\n");
+ ast_verb(0, "+++ ooh323_digit_end\n");
return 0;
}
};
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)) {
return -1; /* ToDO: cleanup */
}
if (gH323Debug)
- ast_verbose("+++ ooh323_call\n");
+ ast_verb(0, "+++ ooh323_call\n");
return 0;
}
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);
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,
}
if (gH323Debug)
- ast_verbose("+++ ooh323_hangup\n");
+ ast_verb(0, "+++ ooh323_hangup\n");
return 0;
}
char *callToken = (char *)NULL;
if (gH323Debug)
- ast_verbose("--- ooh323_answer\n");
+ ast_verb(0, "--- ooh323_answer\n");
if (p) {
}
if (gH323Debug)
- ast_verbose("+++ ooh323_answer\n");
+ ast_verb(0, "+++ ooh323_answer\n");
return 0;
}
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) {
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;
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) {
}
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);
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) {
ast_mutex_unlock(&p->lock);
if (gH323Debug)
- ast_verbose("+++ ooh323c ooh323_fixup \n");
+ ast_verb(0, "+++ ooh323c ooh323_fixup \n");
return 0;
}
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);
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)
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)
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);
}
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);
ast_mutex_unlock(&p->lock);
if (gH323Debug)
- ast_verbose("+++ ooh323_update_readformat\n");
+ ast_verb(0, "+++ ooh323_update_readformat\n");
}
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);
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;
}
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);
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;
}
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))) {
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;
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);
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)) {
}
if (gH323Debug)
- ast_verbose("+++ onOutgoingCall %s\n", call->callToken);
+ ast_verb(0, "+++ onOutgoingCall %s\n", call->callToken);
return OO_OK;
}
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)) {
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)) {
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);
}
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;
}
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))) {
}
if (gH323Debug)
- ast_verbose("+++ onCallEstablished %s\n", call->callToken);
+ ast_verb(0, "+++ onCallEstablished %s\n", call->callToken);
return OO_OK;
}
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))) {
}
if (gH323Debug)
- ast_verbose("+++ onCallCleared\n");
+ ast_verb(0, "+++ onCallCleared\n");
return OO_OK;
}
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;
}
if (gH323Debug)
- ast_verbose("+++ ooh323_delete_user\n");
+ ast_verb(0, "+++ ooh323_delete_user\n");
} */
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;
}
if (gH323Debug)
- ast_verbose("+++ ooh323_delete_peer\n");
+ ast_verb(0, "+++ ooh323_delete_peer\n");
}
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) {
}
if (gH323Debug)
- ast_verbose("+++ build_user\n");
+ ast_verb(0, "+++ build_user\n");
return user;
}
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) {
}
if (gH323Debug)
- ast_verbose("+++ build_peer\n");
+ ast_verb(0, "+++ build_peer\n");
return peer;
}
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;
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;
}
restart_monitor();
if (gH323Debug)
- ast_verbose("+++ ooh323_reload\n");
+ ast_verb(0, "+++ ooh323_reload\n");
return 0;
}
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);
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) {
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)
}
if (gH323Debug)
- ast_verbose("+++ reload_config\n");
+ ast_verb(0, "+++ reload_config\n");
return 0;
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;
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;
}
}
if (gH323Debug)
- ast_verbose("+++ ooh323_destroy\n");
+ ast_verb(0, "+++ ooh323_destroy\n");
return 0;
}
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));
#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 */
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)) {
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;
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) {
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);
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;
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)) {
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;
}
}
if (gH323Debug)
- ast_verbose("+++ configure_local_rtp\n");
+ ast_verb(0, "+++ configure_local_rtp\n");
return 1;
}
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);
"audio", "G726-32", AST_RTP_OPT_G726_NONSTANDARD);
if(gH323Debug)
- ast_verbose("+++ setup_rtp_connection\n");
+ ast_verb(0, "+++ setup_rtp_connection\n");
return;
}
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) {
ast_mutex_unlock(&p->lock);
if(gH323Debug)
- ast_verbose("+++ close_rtp_connection\n");
+ ast_verb(0, "+++ close_rtp_connection\n");
return;
}
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);
ast_mutex_unlock(&p->lock);
if(gH323Debug)
- ast_verbose("+++ setup_udptl_connection\n");
+ ast_verb(0, "+++ setup_udptl_connection\n");
return;
}
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) {
ast_mutex_unlock(&p->lock);
if(gH323Debug)
- ast_verbose("+++ close_udptl_connection\n");
+ ast_verb(0, "+++ close_udptl_connection\n");
return;
}
/* 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);
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;
}
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();
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);
#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);
}
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);
#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)
#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)
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
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);
#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);
#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);
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);
}
}
}
} 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;
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 {
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);
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);
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)) {
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;
}
/* 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;
}
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
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++) {
; 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
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, ...);
#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
{
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);
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)) ||
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)
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;
#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;
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;
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) {
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);
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;
}
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));
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));
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;
}
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;
}
}
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;
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"),
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:
int disabled;
/*! syslog facility */
int facility;
+ /*! Verbosity level */
+ int verbosity;
/*! Type of log channel */
enum logtypes type;
/*! logfile logging file pointer */
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);
}
chan->type = LOGTYPE_FILE;
}
- chan->logmask = make_components(chan->components, lineno);
+ chan->logmask = make_components(chan->components, lineno, &chan->verbosity);
return chan;
}
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) {
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)
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);
}
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);
#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;
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;
}
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);
}
va_list ap;
va_start(ap, fmt);
- __ast_verbose_ap("", 0, "", fmt, ap);
+ __ast_verbose_ap("", 0, "", 0, fmt, ap);
va_end(ap);
}
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;
}
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);
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))) {
* 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;
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) {
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);
}
}
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)) {
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);
}
}
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)) {
}
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;
}