diff options
Diffstat (limited to 'res')
-rw-r--r-- | res/res_adsi.c | 60 | ||||
-rw-r--r-- | res/res_agi.c | 7 | ||||
-rw-r--r-- | res/res_config_pgsql.c | 138 | ||||
-rw-r--r-- | res/res_crypto.c | 6 | ||||
-rw-r--r-- | res/res_jabber.c | 6 | ||||
-rw-r--r-- | res/res_monitor.c | 9 | ||||
-rw-r--r-- | res/res_musiconhold.c | 15 | ||||
-rw-r--r-- | res/res_smdi.c | 12 |
8 files changed, 163 insertions, 90 deletions
diff --git a/res/res_adsi.c b/res/res_adsi.c index cea172767..9cc085dbb 100644 --- a/res/res_adsi.c +++ b/res/res_adsi.c @@ -52,6 +52,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/module.h" #include "asterisk/config.h" #include "asterisk/file.h" +#include "asterisk/options.h" #define DEFAULT_ADSI_MAX_RETRIES 3 @@ -230,7 +231,8 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms for(;;) { if (((res = ast_waitfor(chan, waittime)) < 1)) { /* Didn't get back DTMF A in time */ - ast_log(LOG_DEBUG, "No ADSI CPE detected (%d)\n", res); + if (option_debug) + ast_log(LOG_DEBUG, "No ADSI CPE detected (%d)\n", res); if (!chan->adsicpe) chan->adsicpe = AST_ADSI_UNAVAILABLE; errno = ENOSYS; @@ -239,7 +241,8 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms waittime = res; f = ast_read(chan); if (!f) { - ast_log(LOG_DEBUG, "Hangup in ADSI\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Hangup in ADSI\n"); return -1; } if (f->frametype == AST_FRAME_DTMF) { @@ -250,7 +253,8 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms break; } else { if (f->subclass == 'D') { - ast_log(LOG_DEBUG, "Off-hook capable CPE only, not ADSI\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Off-hook capable CPE only, not ADSI\n"); } else ast_log(LOG_WARNING, "Unknown ADSI response '%c'\n", f->subclass); if (!chan->adsicpe) @@ -262,9 +266,12 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms ast_frfree(f); } - ast_log(LOG_DEBUG, "ADSI Compatible CPE Detected\n"); - } else - ast_log(LOG_DEBUG, "Already in data mode\n"); + if (option_debug) + ast_log(LOG_DEBUG, "ADSI Compatible CPE Detected\n"); + } else { + if (option_debug) + ast_log(LOG_DEBUG, "Already in data mode\n"); + } x = 0; pos = 0; @@ -277,8 +284,9 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms ast_log(LOG_WARNING, "Failed to generate ADSI message %d on channel %s\n", x + 1, chan->name); return -1; } - ast_log(LOG_DEBUG, "Message %d, of %d input bytes, %d output bytes\n", - x + 1, msglen[x], res); + if (option_debug) + ast_log(LOG_DEBUG, "Message %d, of %d input bytes, %d output bytes\n", + x + 1, msglen[x], res); pos += res; x++; } @@ -291,7 +299,8 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms if (res) return -1; - ast_log(LOG_DEBUG, "Sent total spill of %d bytes\n", pos); + if (option_debug) + ast_log(LOG_DEBUG, "Sent total spill of %d bytes\n", pos); memset(ack, 0, sizeof(ack)); /* Get real result */ @@ -300,13 +309,15 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms if (res < 0) return -1; if (ack[0] == 'D') { - ast_log(LOG_DEBUG, "Acked up to message %d\n", atoi(ack + 1)); + if (option_debug) + ast_log(LOG_DEBUG, "Acked up to message %d\n", atoi(ack + 1)); start += atoi(ack + 1); if (start >= x) break; else { retries++; - ast_log(LOG_DEBUG, "Retransmitting (%d), from %d\n", retries, start + 1); + if (option_debug) + ast_log(LOG_DEBUG, "Retransmitting (%d), from %d\n", retries, start + 1); } } else { retries++; @@ -337,7 +348,8 @@ int ast_adsi_begin_download(struct ast_channel *chan, char *service, unsigned ch return -1; if (ack[0] == 'B') return 0; - ast_log(LOG_DEBUG, "Download was denied by CPE\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Download was denied by CPE\n"); return -1; } @@ -372,13 +384,15 @@ int ast_adsi_transmit_message_full(struct ast_channel *chan, unsigned char *msg, for (x=0;x<msglen;x+=(msg[x+1]+2)) { if (msg[x] == ADSI_SWITCH_TO_DATA) { - ast_log(LOG_DEBUG, "Switch to data is sent!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Switch to data is sent!\n"); waitforswitch++; newdatamode = ADSI_FLAG_DATAMODE; } if (msg[x] == ADSI_SWITCH_TO_VOICE) { - ast_log(LOG_DEBUG, "Switch to voice is sent!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Switch to voice is sent!\n"); waitforswitch++; newdatamode = 0; } @@ -411,8 +425,13 @@ int ast_adsi_transmit_message_full(struct ast_channel *chan, unsigned char *msg, res = __adsi_transmit_messages(chan, msgs, msglens, msgtypes); if (dowait) { - ast_log(LOG_DEBUG, "Wait for switch is '%d'\n", waitforswitch); - while(waitforswitch-- && ((res = ast_waitfordigit(chan, 1000)) > 0)) { res = 0; ast_log(LOG_DEBUG, "Waiting for 'B'...\n"); } + if (option_debug) + ast_log(LOG_DEBUG, "Wait for switch is '%d'\n", waitforswitch); + while (waitforswitch-- && ((res = ast_waitfordigit(chan, 1000)) > 0)) { + res = 0; + if (option_debug) + ast_log(LOG_DEBUG, "Waiting for 'B'...\n"); + } } if (!res) @@ -994,14 +1013,17 @@ int ast_adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, if (res < 0) return -1; if (res) { - ast_log(LOG_DEBUG, "No response from CPE about version. Assuming not there.\n"); + if (option_debug) + ast_log(LOG_DEBUG, "No response from CPE about version. Assuming not there.\n"); return 0; } if (!strcmp(resp, "B")) { - ast_log(LOG_DEBUG, "CPE has script '%s' version %d already loaded\n", app, ver); + if (option_debug) + ast_log(LOG_DEBUG, "CPE has script '%s' version %d already loaded\n", app, ver); return 1; } else if (!strcmp(resp, "A")) { - ast_log(LOG_DEBUG, "CPE hasn't script '%s' version %d already loaded\n", app, ver); + if (option_debug) + ast_log(LOG_DEBUG, "CPE hasn't script '%s' version %d already loaded\n", app, ver); } else { ast_log(LOG_WARNING, "Unexpected CPE response to script query: %s\n", resp); } diff --git a/res/res_agi.c b/res/res_agi.c index e38cef2c2..f6adf290e 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -563,7 +563,7 @@ static int handle_streamfile(struct ast_channel *chan, AGI *agi, int argc, char return RESULT_SUCCESS; } vfs = ast_openvstream(chan, argv[2], chan->language); - if (vfs) + if (vfs && option_debug) ast_log(LOG_DEBUG, "Ooh, found a video stream, too\n"); if (option_verbose > 2) @@ -628,7 +628,7 @@ static int handle_getoption(struct ast_channel *chan, AGI *agi, int argc, char * return RESULT_SUCCESS; } vfs = ast_openvstream(chan, argv[2], chan->language); - if (vfs) + if (vfs && option_debug) ast_log(LOG_DEBUG, "Ooh, found a video stream, too\n"); if (option_verbose > 2) @@ -1840,7 +1840,8 @@ static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi /* Idle the channel until we get a command */ f = ast_read(c); if (!f) { - ast_log(LOG_DEBUG, "%s hungup\n", chan->name); + if (option_debug) + ast_log(LOG_DEBUG, "%s hungup\n", chan->name); returnstatus = AGI_RESULT_HANGUP; break; } else { diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c index 11dec3f40..cebad75a8 100644 --- a/res/res_config_pgsql.c +++ b/res/res_config_pgsql.c @@ -132,9 +132,11 @@ static struct ast_variable *realtime_pgsql(const char *database, const char *tab if (!(result = PQexec(pgsqlConn, sql))) { ast_log(LOG_WARNING, "Postgresql RealTime: Failed to query database. Check debug for more info.\n"); - ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql); - ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n", - PQerrorMessage(pgsqlConn)); + if (option_debug) { + ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql); + ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n", + PQerrorMessage(pgsqlConn)); + } ast_mutex_unlock(&pgsql_lock); return NULL; } else { @@ -144,15 +146,18 @@ static struct ast_variable *realtime_pgsql(const char *database, const char *tab && result_status != PGRES_NONFATAL_ERROR) { ast_log(LOG_WARNING, "Postgresql RealTime: Failed to query database. Check debug for more info.\n"); - ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql); - ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n", - PQresultErrorMessage(result), PQresStatus(result_status)); + if (option_debug) { + ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql); + ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n", + PQresultErrorMessage(result), PQresStatus(result_status)); + } ast_mutex_unlock(&pgsql_lock); return NULL; } } - ast_log(LOG_DEBUG, "1Postgresql RealTime: Result=%p Query: %s\n", result, sql); + if (option_debug) + ast_log(LOG_DEBUG, "1Postgresql RealTime: Result=%p Query: %s\n", result, sql); if ((num_rows = PQntuples(result)) > 0) { int i = 0; @@ -160,7 +165,8 @@ static struct ast_variable *realtime_pgsql(const char *database, const char *tab int numFields = PQnfields(result); char **fieldnames = NULL; - ast_log(LOG_DEBUG, "Postgresql RealTime: Found %d rows.\n", num_rows); + if (option_debug) + ast_log(LOG_DEBUG, "Postgresql RealTime: Found %d rows.\n", num_rows); if (!(fieldnames = ast_calloc(1, numFields * sizeof(char *)))) { ast_mutex_unlock(&pgsql_lock); @@ -278,9 +284,11 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char if (!(result = PQexec(pgsqlConn, sql))) { ast_log(LOG_WARNING, "Postgresql RealTime: Failed to query database. Check debug for more info.\n"); - ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql); - ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n", - PQerrorMessage(pgsqlConn)); + if (option_debug) { + ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql); + ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n", + PQerrorMessage(pgsqlConn)); + } ast_mutex_unlock(&pgsql_lock); return NULL; } else { @@ -290,15 +298,18 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char && result_status != PGRES_NONFATAL_ERROR) { ast_log(LOG_WARNING, "Postgresql RealTime: Failed to query database. Check debug for more info.\n"); - ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql); - ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n", - PQresultErrorMessage(result), PQresStatus(result_status)); + if (option_debug) { + ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql); + ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n", + PQresultErrorMessage(result), PQresStatus(result_status)); + } ast_mutex_unlock(&pgsql_lock); return NULL; } } - ast_log(LOG_DEBUG, "2Postgresql RealTime: Result=%p Query: %s\n", result, sql); + if (option_debug) + ast_log(LOG_DEBUG, "2Postgresql RealTime: Result=%p Query: %s\n", result, sql); if ((num_rows = PQntuples(result)) > 0) { int numFields = PQnfields(result); @@ -306,7 +317,8 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char int rowIndex = 0; char **fieldnames = NULL; - ast_log(LOG_DEBUG, "Postgresql RealTime: Found %d rows.\n", num_rows); + if (option_debug) + ast_log(LOG_DEBUG, "Postgresql RealTime: Found %d rows.\n", num_rows); if (!(fieldnames = ast_calloc(1, numFields * sizeof(char *)))) { ast_mutex_unlock(&pgsql_lock); @@ -386,7 +398,8 @@ static int update_pgsql(const char *database, const char *table, const char *key snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " WHERE %s = '%s'", keyfield, lookup); - ast_log(LOG_DEBUG, "Postgresql RealTime: Update SQL: %s\n", sql); + if (option_debug) + ast_log(LOG_DEBUG, "Postgresql RealTime: Update SQL: %s\n", sql); /* We now have our complete statement; Lets connect to the server and execute it. */ ast_mutex_lock(&pgsql_lock); @@ -398,9 +411,11 @@ static int update_pgsql(const char *database, const char *table, const char *key if (!(result = PQexec(pgsqlConn, sql))) { ast_log(LOG_WARNING, "Postgresql RealTime: Failed to query database. Check debug for more info.\n"); - ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql); - ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n", - PQerrorMessage(pgsqlConn)); + if (option_debug) { + ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql); + ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n", + PQerrorMessage(pgsqlConn)); + } ast_mutex_unlock(&pgsql_lock); return -1; } else { @@ -410,9 +425,11 @@ static int update_pgsql(const char *database, const char *table, const char *key && result_status != PGRES_NONFATAL_ERROR) { ast_log(LOG_WARNING, "Postgresql RealTime: Failed to query database. Check debug for more info.\n"); - ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql); - ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n", - PQresultErrorMessage(result), PQresStatus(result_status)); + if (option_debug) { + ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql); + ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n", + PQresultErrorMessage(result), PQresStatus(result_status)); + } ast_mutex_unlock(&pgsql_lock); return -1; } @@ -421,8 +438,9 @@ static int update_pgsql(const char *database, const char *table, const char *key numrows = atoi(PQcmdTuples(result)); ast_mutex_unlock(&pgsql_lock); - ast_log(LOG_DEBUG, "Postgresql RealTime: Updated %d rows on table: %s\n", numrows, - table); + if (option_debug) + ast_log(LOG_DEBUG, "Postgresql RealTime: Updated %d rows on table: %s\n", numrows, + table); /* From http://dev.pgsql.com/doc/pgsql/en/pgsql-affected-rows.html * An integer greater than zero indicates the number of rows affected @@ -459,7 +477,8 @@ static struct ast_config *config_pgsql(const char *database, const char *table, "SELECT category, var_name, var_val, cat_metric FROM %s WHERE filename='%s' and commented=0 ORDER BY filename, cat_metric desc, var_metric asc, category, var_name, var_val, id", table, file); - ast_log(LOG_DEBUG, "Postgresql RealTime: Static SQL: %s\n", sql); + if (option_debug) + ast_log(LOG_DEBUG, "Postgresql RealTime: Static SQL: %s\n", sql); /* We now have our complete statement; Lets connect to the server and execute it. */ ast_mutex_lock(&pgsql_lock); @@ -471,9 +490,11 @@ static struct ast_config *config_pgsql(const char *database, const char *table, if (!(result = PQexec(pgsqlConn, sql))) { ast_log(LOG_WARNING, "Postgresql RealTime: Failed to query database. Check debug for more info.\n"); - ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql); - ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n", - PQerrorMessage(pgsqlConn)); + if (option_debug) { + ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql); + ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n", + PQerrorMessage(pgsqlConn)); + } ast_mutex_unlock(&pgsql_lock); return NULL; } else { @@ -483,9 +504,11 @@ static struct ast_config *config_pgsql(const char *database, const char *table, && result_status != PGRES_NONFATAL_ERROR) { ast_log(LOG_WARNING, "Postgresql RealTime: Failed to query database. Check debug for more info.\n"); - ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql); - ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n", - PQresultErrorMessage(result), PQresStatus(result_status)); + if (option_debug) { + ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql); + ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n", + PQresultErrorMessage(result), PQresStatus(result_status)); + } ast_mutex_unlock(&pgsql_lock); return NULL; } @@ -497,7 +520,8 @@ static struct ast_config *config_pgsql(const char *database, const char *table, int rowIndex = 0; char **fieldnames = NULL; - ast_log(LOG_DEBUG, "Postgresql RealTime: Found %ld rows.\n", num_rows); + if (option_debug) + ast_log(LOG_DEBUG, "Postgresql RealTime: Found %ld rows.\n", num_rows); if (!(fieldnames = ast_calloc(1, numFields * sizeof(char *)))) { ast_mutex_unlock(&pgsql_lock); @@ -561,8 +585,9 @@ static int load_module(void) if (!pgsql_reconnect(NULL)) { ast_log(LOG_WARNING, "Postgresql RealTime: Couldn't establish connection. Check debug.\n"); - ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n", - PQerrorMessage(pgsqlConn)); + if (option_debug) + ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n", + PQerrorMessage(pgsqlConn)); } ast_config_engine_register(&pgsql_engine); @@ -613,8 +638,9 @@ static int reload(void) if (!pgsql_reconnect(NULL)) { ast_log(LOG_WARNING, "Postgresql RealTime: Couldn't establish connection. Check debug.\n"); - ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n", - PQerrorMessage(pgsqlConn)); + if (option_debug) + ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n", + PQerrorMessage(pgsqlConn)); } ast_verbose(VERBOSE_PREFIX_2 "Postgresql RealTime reloaded.\n"); @@ -685,15 +711,17 @@ static int parse_config(void) } ast_config_destroy(config); - if (dbhost) { - ast_log(LOG_DEBUG, "Postgresql RealTime Host: %s\n", dbhost); - ast_log(LOG_DEBUG, "Postgresql RealTime Port: %i\n", dbport); - } else { - ast_log(LOG_DEBUG, "Postgresql RealTime Socket: %s\n", dbsock); + if (option_debug) { + if (dbhost) { + ast_log(LOG_DEBUG, "Postgresql RealTime Host: %s\n", dbhost); + ast_log(LOG_DEBUG, "Postgresql RealTime Port: %i\n", dbport); + } else { + ast_log(LOG_DEBUG, "Postgresql RealTime Socket: %s\n", dbsock); + } + ast_log(LOG_DEBUG, "Postgresql RealTime User: %s\n", dbuser); + ast_log(LOG_DEBUG, "Postgresql RealTime Password: %s\n", dbpass); + ast_log(LOG_DEBUG, "Postgresql RealTime DBName: %s\n", dbname); } - ast_log(LOG_DEBUG, "Postgresql RealTime User: %s\n", dbuser); - ast_log(LOG_DEBUG, "Postgresql RealTime Password: %s\n", dbpass); - ast_log(LOG_DEBUG, "Postgresql RealTime DBName: %s\n", dbname); return 1; } @@ -723,26 +751,32 @@ static int pgsql_reconnect(const char *database) sprintf(connInfo, "host=%s port=%d dbname=%s user=%s password=%s", dbhost, dbport, my_database, dbuser, dbpass); - ast_log(LOG_DEBUG, "%u connInfo=%s\n", size, connInfo); + if (option_debug) + ast_log(LOG_DEBUG, "%u connInfo=%s\n", size, connInfo); pgsqlConn = PQconnectdb(connInfo); - ast_log(LOG_DEBUG, "%u connInfo=%s\n", size, connInfo); + if (option_debug) + ast_log(LOG_DEBUG, "%u connInfo=%s\n", size, connInfo); free(connInfo); connInfo = NULL; - ast_log(LOG_DEBUG, "pgsqlConn=%p\n", pgsqlConn); + if (option_debug) + ast_log(LOG_DEBUG, "pgsqlConn=%p\n", pgsqlConn); if (pgsqlConn && PQstatus(pgsqlConn) == CONNECTION_OK) { - ast_log(LOG_DEBUG, "Postgresql RealTime: Successfully connected to database.\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Postgresql RealTime: Successfully connected to database.\n"); connect_time = time(NULL); return 1; } else { ast_log(LOG_ERROR, "Postgresql RealTime: Failed to connect database server %s on %s. Check debug for more info.\n", dbname, dbhost); - ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n", - PQresultErrorMessage(NULL)); + if (option_debug) + ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n", + PQresultErrorMessage(NULL)); return 0; } } else { - ast_log(LOG_DEBUG, "Postgresql RealTime: Everything is fine.\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Postgresql RealTime: Everything is fine.\n"); return 1; } } diff --git a/res/res_crypto.c b/res/res_crypto.c index c12c11a51..055716789 100644 --- a/res/res_crypto.c +++ b/res/res_crypto.c @@ -433,7 +433,8 @@ static int __ast_check_signature_bin(struct ast_key *key, const char *msg, int m res = RSA_verify(NID_sha1, digest, sizeof(digest), (unsigned char *)dsig, 128, key->rsa); if (!res) { - ast_log(LOG_DEBUG, "Key failed verification: %s\n", key->name); + if (option_debug) + ast_log(LOG_DEBUG, "Key failed verification: %s\n", key->name); return -1; } /* Pass */ @@ -487,7 +488,8 @@ static void crypto_load(int ifd, int ofd) while(key) { nkey = key->next; if (key->delme) { - ast_log(LOG_DEBUG, "Deleting key %s type %d\n", key->name, key->ktype); + if (option_debug) + ast_log(LOG_DEBUG, "Deleting key %s type %d\n", key->name, key->ktype); /* Do the delete */ if (last) last->next = nkey; diff --git a/res/res_jabber.c b/res/res_jabber.c index 9a4b52db6..3340423c5 100644 --- a/res/res_jabber.c +++ b/res/res_jabber.c @@ -1239,8 +1239,10 @@ static void aji_handle_presence(struct aji_client *client, ikspak *pak) found->cap = aji_find_version(node, ver, pak); if(gtalk_yuck(pak->x)) /* gtalk should do discover */ found->cap->jingle = 1; - if(found->cap->jingle && option_debug > 4) - ast_log(LOG_DEBUG,"Special case for google till they support discover.\n"); + if(found->cap->jingle && option_debug > 4) { + if (option_debug) + ast_log(LOG_DEBUG,"Special case for google till they support discover.\n"); + } else { iks *iq, *query; iq = iks_new("iq"); diff --git a/res/res_monitor.c b/res/res_monitor.c index b1739f977..793921b42 100644 --- a/res/res_monitor.c +++ b/res/res_monitor.c @@ -47,6 +47,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/app.h" #include "asterisk/utils.h" #include "asterisk/config.h" +#include "asterisk/options.h" AST_MUTEX_DEFINE_STATIC(monitorlock); @@ -221,8 +222,9 @@ int ast_monitor_start( struct ast_channel *chan, const char *format_spec, /* so we know this call has been monitored in case we need to bill for it or something */ pbx_builtin_setvar_helper(chan, "__MONITORED","true"); } else { - ast_log(LOG_DEBUG,"Cannot start monitoring %s, already monitored\n", - chan->name); + if (option_debug) + ast_log(LOG_DEBUG,"Cannot start monitoring %s, already monitored\n", + chan->name); res = -1; } @@ -295,7 +297,8 @@ int ast_monitor_stop(struct ast_channel *chan, int need_lock) snprintf(tmp2,sizeof(tmp2), "( %s& rm -f \"%s/%s-\"* ) &",tmp, dir ,name); /* remove legs when done mixing */ ast_copy_string(tmp, tmp2, sizeof(tmp)); } - ast_log(LOG_DEBUG,"monitor executing %s\n",tmp); + if (option_debug) + ast_log(LOG_DEBUG,"monitor executing %s\n",tmp); if (ast_safe_system(tmp) == -1) ast_log(LOG_WARNING, "Execute of %s failed.\n",tmp); } diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index ce630b0b4..41f588c0e 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -533,8 +533,10 @@ static void *monmp3thread(void *data) kill(class->pid, SIGKILL); class->pid = 0; } - } else - ast_log(LOG_DEBUG, "Read %d bytes of audio while expecting %d\n", res2, len); + } else { + if (option_debug) + ast_log(LOG_DEBUG, "Read %d bytes of audio while expecting %d\n", res2, len); + } continue; } pthread_testcancel(); @@ -819,7 +821,8 @@ static int moh_register(struct mohclass *moh, int reload) AST_LIST_LOCK(&mohclasses); if (get_mohbyname(moh->name)) { if (reload) { - ast_log(LOG_DEBUG, "Music on Hold class '%s' left alone from initial load.\n", moh->name); + if (option_debug) + ast_log(LOG_DEBUG, "Music on Hold class '%s' left alone from initial load.\n", moh->name); } else { ast_log(LOG_WARNING, "Music on Hold class '%s' already exists\n", moh->name); } @@ -1041,7 +1044,8 @@ static void ast_moh_destroy(void) AST_LIST_LOCK(&mohclasses); while ((moh = AST_LIST_REMOVE_HEAD(&mohclasses, list))) { if (moh->pid > 1) { - ast_log(LOG_DEBUG, "killing %d!\n", moh->pid); + if (option_debug) + ast_log(LOG_DEBUG, "killing %d!\n", moh->pid); stime = time(NULL) + 2; pid = moh->pid; moh->pid = 0; @@ -1055,7 +1059,8 @@ static void ast_moh_destroy(void) kill(pid, SIGKILL); while ((ast_wait_for_input(moh->srcfd, 100) > 0) && (bytes = read(moh->srcfd, buff, 8192)) && time(NULL) < stime) tbytes = tbytes + bytes; - ast_log(LOG_DEBUG, "mpg123 pid %d and child died after %d bytes read\n", pid, tbytes); + if (option_debug) + ast_log(LOG_DEBUG, "mpg123 pid %d and child died after %d bytes read\n", pid, tbytes); close(moh->srcfd); } ast_moh_free_class(&moh); diff --git a/res/res_smdi.c b/res/res_smdi.c index c0c7f8927..87540e48f 100644 --- a/res/res_smdi.c +++ b/res/res_smdi.c @@ -112,7 +112,8 @@ int ast_smdi_mwi_set(struct ast_smdi_interface *iface, const char *mailbox) fclose(file); ASTOBJ_UNLOCK(iface); - ast_log(LOG_DEBUG, "Sent MWI set message for %s on %s\n", mailbox, iface->name); + if (option_debug) + ast_log(LOG_DEBUG, "Sent MWI set message for %s on %s\n", mailbox, iface->name); return 0; } @@ -143,7 +144,8 @@ int ast_smdi_mwi_unset(struct ast_smdi_interface *iface, const char *mailbox) fclose(file); ASTOBJ_UNLOCK(iface); - ast_log(LOG_DEBUG, "Sent MWI unset message for %s on %s\n", mailbox, iface->name); + if (option_debug) + ast_log(LOG_DEBUG, "Sent MWI unset message for %s on %s\n", mailbox, iface->name); return 0; } @@ -412,7 +414,8 @@ static void *smdi_read(void *iface_p) /* add the message to the message queue */ md_msg->timestamp = ast_tvnow(); ast_smdi_md_message_push(iface, md_msg); - ast_log(LOG_DEBUG, "Recieved SMDI MD message on %s\n", iface->name); + if (option_debug) + ast_log(LOG_DEBUG, "Recieved SMDI MD message on %s\n", iface->name); ASTOBJ_UNREF(md_msg, ast_smdi_md_message_destroy); @@ -455,7 +458,8 @@ static void *smdi_read(void *iface_p) /* add the message to the message queue */ mwi_msg->timestamp = ast_tvnow(); ast_smdi_mwi_message_push(iface, mwi_msg); - ast_log(LOG_DEBUG, "Recieved SMDI MWI message on %s\n", iface->name); + if (option_debug) + ast_log(LOG_DEBUG, "Recieved SMDI MWI message on %s\n", iface->name); ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy); } else { |