From 055d82cbce5ad588f4d612c49f56cd76f4c8bab6 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Thu, 14 Jun 2007 19:39:12 +0000 Subject: Add a massive set of changes for converting to use the ast_debug() macro. (issue #9957, patches from mvanbaak, caio1982, critch, and dimas) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@69327 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- res/res_adsi.c | 53 +++++++--------------- res/res_agi.c | 12 ++--- res/res_config_pgsql.c | 116 ++++++++++++++++-------------------------------- res/res_config_sqlite.c | 6 +-- res/res_crypto.c | 9 ++-- res/res_features.c | 50 +++++++-------------- res/res_jabber.c | 27 ++++------- res/res_monitor.c | 7 +-- res/res_musiconhold.c | 18 +++----- res/res_smdi.c | 12 ++--- 10 files changed, 103 insertions(+), 207 deletions(-) (limited to 'res') diff --git a/res/res_adsi.c b/res/res_adsi.c index 6b3fccf14..28ff200e4 100644 --- a/res/res_adsi.c +++ b/res/res_adsi.c @@ -232,8 +232,7 @@ 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 */ - if (option_debug) - ast_log(LOG_DEBUG, "No ADSI CPE detected (%d)\n", res); + ast_debug(1, "No ADSI CPE detected (%d)\n", res); if (!chan->adsicpe) chan->adsicpe = AST_ADSI_UNAVAILABLE; errno = ENOSYS; @@ -242,8 +241,7 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms waittime = res; f = ast_read(chan); if (!f) { - if (option_debug) - ast_log(LOG_DEBUG, "Hangup in ADSI\n"); + ast_debug(1, "Hangup in ADSI\n"); return -1; } if (f->frametype == AST_FRAME_DTMF) { @@ -254,8 +252,7 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms break; } else { if (f->subclass == 'D') { - if (option_debug) - ast_log(LOG_DEBUG, "Off-hook capable CPE only, not ADSI\n"); + ast_debug(1, "Off-hook capable CPE only, not ADSI\n"); } else ast_log(LOG_WARNING, "Unknown ADSI response '%c'\n", f->subclass); if (!chan->adsicpe) @@ -267,11 +264,9 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms ast_frfree(f); } - if (option_debug) - ast_log(LOG_DEBUG, "ADSI Compatible CPE Detected\n"); + ast_debug(1, "ADSI Compatible CPE Detected\n"); } else { - if (option_debug) - ast_log(LOG_DEBUG, "Already in data mode\n"); + ast_debug(1, "Already in data mode\n"); } x = 0; @@ -285,9 +280,7 @@ 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; } - if (option_debug) - ast_log(LOG_DEBUG, "Message %d, of %d input bytes, %d output bytes\n", - x + 1, msglen[x], res); + ast_debug(1, "Message %d, of %d input bytes, %d output bytes\n", x + 1, msglen[x], res); pos += res; x++; } @@ -300,8 +293,7 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms if (res) return -1; - if (option_debug) - ast_log(LOG_DEBUG, "Sent total spill of %d bytes\n", pos); + ast_debug(1, "Sent total spill of %d bytes\n", pos); memset(ack, 0, sizeof(ack)); /* Get real result */ @@ -310,15 +302,12 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms if (res < 0) return -1; if (ack[0] == 'D') { - if (option_debug) - ast_log(LOG_DEBUG, "Acked up to message %d\n", atoi(ack + 1)); - start += atoi(ack + 1); + ast_debug(1, "Acked up to message %d\n", atoi(ack + 1)); start += atoi(ack + 1); if (start >= x) break; else { retries++; - if (option_debug) - ast_log(LOG_DEBUG, "Retransmitting (%d), from %d\n", retries, start + 1); + ast_debug(1, "Retransmitting (%d), from %d\n", retries, start + 1); } } else { retries++; @@ -349,8 +338,7 @@ static int _ast_adsi_begin_download(struct ast_channel *chan, char *service, uns return -1; if (ack[0] == 'B') return 0; - if (option_debug) - ast_log(LOG_DEBUG, "Download was denied by CPE\n"); + ast_debug(1, "Download was denied by CPE\n"); return -1; } @@ -385,15 +373,13 @@ static int _ast_adsi_transmit_message_full(struct ast_channel *chan, unsigned ch for (x=0;x 0)) { res = 0; - if (option_debug) - ast_log(LOG_DEBUG, "Waiting for 'B'...\n"); + ast_debug(1, "Waiting for 'B'...\n"); } } @@ -1014,17 +998,14 @@ static int _ast_adsi_load_session(struct ast_channel *chan, unsigned char *app, if (res < 0) return -1; if (res) { - if (option_debug) - ast_log(LOG_DEBUG, "No response from CPE about version. Assuming not there.\n"); + ast_debug(1, "No response from CPE about version. Assuming not there.\n"); return 0; } if (!strcmp(resp, "B")) { - if (option_debug) - ast_log(LOG_DEBUG, "CPE has script '%s' version %d already loaded\n", app, ver); + ast_debug(1, "CPE has script '%s' version %d already loaded\n", app, ver); return 1; } else if (!strcmp(resp, "A")) { - if (option_debug) - ast_log(LOG_DEBUG, "CPE hasn't script '%s' version %d already loaded\n", app, ver); + ast_debug(1, "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 5d58de4b0..1fef67a59 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -224,8 +224,7 @@ static enum agi_result launch_netscript(char *agiurl, char *argv[], int *fds, in if (!ast_strlen_zero(script)) fdprintf(s, "agi_network_script: %s\n", script); - if (option_debug > 3) - ast_log(LOG_DEBUG, "Wow, connected!\n"); + ast_debug(4, "Wow, connected!\n"); fds[0] = s; fds[1] = s; *opid = -1; @@ -584,8 +583,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 && option_debug) - ast_log(LOG_DEBUG, "Ooh, found a video stream, too\n"); + ast_debug(vfs && 1, "Ooh, found a video stream, too\n"); if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Playing '%s' (escape_digits=%s) (sample_offset %ld)\n", argv[2], edigits, sample_offset); @@ -649,8 +647,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 && option_debug) - ast_log(LOG_DEBUG, "Ooh, found a video stream, too\n"); + ast_debug(vfs && 1, "Ooh, found a video stream, too\n"); if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Playing '%s' (escape_digits=%s) (timeout %d)\n", argv[2], edigits, timeout); @@ -1860,8 +1857,7 @@ 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) { - if (option_debug) - ast_log(LOG_DEBUG, "%s hungup\n", chan->name); + ast_debug(1, "%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 20b2312c0..821f32cc0 100644 --- a/res/res_config_pgsql.c +++ b/res/res_config_pgsql.c @@ -132,11 +132,8 @@ 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"); - 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_debug(1, "Postgresql RealTime: Query: %s\n", sql); + ast_debug(1, "Postgresql RealTime: Query Failed because: %s\n", PQerrorMessage(pgsqlConn)); ast_mutex_unlock(&pgsql_lock); return NULL; } else { @@ -146,18 +143,15 @@ 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"); - 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", + ast_debug(1, "Postgresql RealTime: Query: %s\n", sql); + ast_debug(1, "Postgresql RealTime: Query Failed because: %s (%s)\n", PQresultErrorMessage(result), PQresStatus(result_status)); - } ast_mutex_unlock(&pgsql_lock); return NULL; } } - if (option_debug) - ast_log(LOG_DEBUG, "1Postgresql RealTime: Result=%p Query: %s\n", result, sql); + ast_debug(1, "1Postgresql RealTime: Result=%p Query: %s\n", result, sql); if ((num_rows = PQntuples(result)) > 0) { int i = 0; @@ -165,8 +159,7 @@ static struct ast_variable *realtime_pgsql(const char *database, const char *tab int numFields = PQnfields(result); char **fieldnames = NULL; - if (option_debug) - ast_log(LOG_DEBUG, "Postgresql RealTime: Found %d rows.\n", num_rows); + ast_debug(1, "Postgresql RealTime: Found %d rows.\n", num_rows); if (!(fieldnames = ast_calloc(1, numFields * sizeof(char *)))) { ast_mutex_unlock(&pgsql_lock); @@ -284,11 +277,8 @@ 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"); - 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_debug(1, "Postgresql RealTime: Query: %s\n", sql); + ast_debug(1, "Postgresql RealTime: Query Failed because: %s\n", PQerrorMessage(pgsqlConn)); ast_mutex_unlock(&pgsql_lock); return NULL; } else { @@ -298,18 +288,15 @@ 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"); - 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", + ast_debug(1, "Postgresql RealTime: Query: %s\n", sql); + ast_debug(1, "Postgresql RealTime: Query Failed because: %s (%s)\n", PQresultErrorMessage(result), PQresStatus(result_status)); - } ast_mutex_unlock(&pgsql_lock); return NULL; } } - if (option_debug) - ast_log(LOG_DEBUG, "2Postgresql RealTime: Result=%p Query: %s\n", result, sql); + ast_debug(1, "2Postgresql RealTime: Result=%p Query: %s\n", result, sql); if ((num_rows = PQntuples(result)) > 0) { int numFields = PQnfields(result); @@ -317,8 +304,7 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char int rowIndex = 0; char **fieldnames = NULL; - if (option_debug) - ast_log(LOG_DEBUG, "Postgresql RealTime: Found %d rows.\n", num_rows); + ast_debug(1, "Postgresql RealTime: Found %d rows.\n", num_rows); if (!(fieldnames = ast_calloc(1, numFields * sizeof(char *)))) { ast_mutex_unlock(&pgsql_lock); @@ -398,8 +384,7 @@ 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); - if (option_debug) - ast_log(LOG_DEBUG, "Postgresql RealTime: Update SQL: %s\n", sql); + ast_debug(1, "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); @@ -411,11 +396,8 @@ 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"); - 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_debug(1, "Postgresql RealTime: Query: %s\n", sql); + ast_debug(1, "Postgresql RealTime: Query Failed because: %s\n", PQerrorMessage(pgsqlConn)); ast_mutex_unlock(&pgsql_lock); return -1; } else { @@ -425,11 +407,9 @@ 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"); - 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", + ast_debug(1, "Postgresql RealTime: Query: %s\n", sql); + ast_debug(1, "Postgresql RealTime: Query Failed because: %s (%s)\n", PQresultErrorMessage(result), PQresStatus(result_status)); - } ast_mutex_unlock(&pgsql_lock); return -1; } @@ -438,9 +418,7 @@ static int update_pgsql(const char *database, const char *table, const char *key numrows = atoi(PQcmdTuples(result)); ast_mutex_unlock(&pgsql_lock); - if (option_debug) - ast_log(LOG_DEBUG, "Postgresql RealTime: Updated %d rows on table: %s\n", numrows, - table); + ast_debug(1, "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 @@ -479,8 +457,7 @@ static struct ast_config *config_pgsql(const char *database, const char *table, ast_build_string(&sql, &sqlleft, "WHERE filename='%s' and commented=0", file); ast_build_string(&sql, &sqlleft, "ORDER BY cat_metric DESC, var_metric ASC, category, var_name "); - if (option_debug) - ast_log(LOG_DEBUG, "Postgresql RealTime: Static SQL: %s\n", sqlbuf); + ast_debug(1, "Postgresql RealTime: Static SQL: %s\n", sqlbuf); /* We now have our complete statement; Lets connect to the server and execute it. */ ast_mutex_lock(&pgsql_lock); @@ -492,11 +469,8 @@ static struct ast_config *config_pgsql(const char *database, const char *table, if (!(result = PQexec(pgsqlConn, sqlbuf))) { ast_log(LOG_WARNING, "Postgresql RealTime: Failed to query database. Check debug for more info.\n"); - 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_debug(1, "Postgresql RealTime: Query: %s\n", sql); + ast_debug(1, "Postgresql RealTime: Query Failed because: %s\n", PQerrorMessage(pgsqlConn)); ast_mutex_unlock(&pgsql_lock); return NULL; } else { @@ -506,11 +480,9 @@ 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"); - 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", + ast_debug(1, "Postgresql RealTime: Query: %s\n", sql); + ast_debug(1, "Postgresql RealTime: Query Failed because: %s (%s)\n", PQresultErrorMessage(result), PQresStatus(result_status)); - } ast_mutex_unlock(&pgsql_lock); return NULL; } @@ -519,8 +491,7 @@ static struct ast_config *config_pgsql(const char *database, const char *table, if ((num_rows = PQntuples(result)) > 0) { int rowIndex = 0; - if (option_debug) - ast_log(LOG_DEBUG, "Postgresql RealTime: Found %ld rows.\n", num_rows); + ast_debug(1, "Postgresql RealTime: Found %ld rows.\n", num_rows); for (rowIndex = 0; rowIndex < num_rows; rowIndex++) { char *field_category = PQgetvalue(result, rowIndex, 0); @@ -576,9 +547,7 @@ static int load_module(void) if (!pgsql_reconnect(NULL)) { ast_log(LOG_WARNING, "Postgresql RealTime: Couldn't establish connection. Check debug.\n"); - if (option_debug) - ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n", - PQerrorMessage(pgsqlConn)); + ast_debug(1, "Postgresql RealTime: Cannot Connect: %s\n", PQerrorMessage(pgsqlConn)); } ast_config_engine_register(&pgsql_engine); @@ -629,9 +598,7 @@ static int reload(void) if (!pgsql_reconnect(NULL)) { ast_log(LOG_WARNING, "Postgresql RealTime: Couldn't establish connection. Check debug.\n"); - if (option_debug) - ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n", - PQerrorMessage(pgsqlConn)); + ast_debug(1, "Postgresql RealTime: Cannot Connect: %s\n", PQerrorMessage(pgsqlConn)); } ast_verbose(VERBOSE_PREFIX_2 "Postgresql RealTime reloaded.\n"); @@ -704,14 +671,14 @@ static int parse_config(void) 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); + ast_debug(1, "Postgresql RealTime Host: %s\n", dbhost); + ast_debug(1, "Postgresql RealTime Port: %i\n", dbport); } else { - ast_log(LOG_DEBUG, "Postgresql RealTime Socket: %s\n", dbsock); + ast_debug(1, "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_debug(1, "Postgresql RealTime User: %s\n", dbuser); + ast_debug(1, "Postgresql RealTime Password: %s\n", dbpass); + ast_debug(1, "Postgresql RealTime DBName: %s\n", dbname); } return 1; @@ -742,32 +709,25 @@ 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); - if (option_debug) - ast_log(LOG_DEBUG, "%u connInfo=%s\n", size, connInfo); + ast_debug(1, "%u connInfo=%s\n", size, connInfo); pgsqlConn = PQconnectdb(connInfo); - if (option_debug) - ast_log(LOG_DEBUG, "%u connInfo=%s\n", size, connInfo); + ast_debug(1, "%u connInfo=%s\n", size, connInfo); ast_free(connInfo); connInfo = NULL; - if (option_debug) - ast_log(LOG_DEBUG, "pgsqlConn=%p\n", pgsqlConn); + ast_debug(1, "pgsqlConn=%p\n", pgsqlConn); if (pgsqlConn && PQstatus(pgsqlConn) == CONNECTION_OK) { - if (option_debug) - ast_log(LOG_DEBUG, "Postgresql RealTime: Successfully connected to database.\n"); + ast_debug(1, "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); - if (option_debug) - ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n", - PQresultErrorMessage(NULL)); + ast_debug(1, "Postgresql RealTime: Cannot Connect: %s\n", PQresultErrorMessage(NULL)); return 0; } } else { - if (option_debug) - ast_log(LOG_DEBUG, "Postgresql RealTime: Everything is fine.\n"); + ast_debug(1, "Postgresql RealTime: Everything is fine.\n"); return 1; } } diff --git a/res/res_config_sqlite.c b/res/res_config_sqlite.c index f8f9d81d1..9aa37d5f0 100644 --- a/res/res_config_sqlite.c +++ b/res/res_config_sqlite.c @@ -909,7 +909,7 @@ realtime_handler(const char *database, const char *table, va_list ap) } query = tmp_str; - ast_log(LOG_DEBUG, "SQL query: %s\n", query); + ast_debug(1, "SQL query: %s\n", query); args.var = NULL; args.last = NULL; @@ -1074,7 +1074,7 @@ static struct ast_config *realtime_multi_handler(const char *database, sqlite_freemem(query); query = tmp_str; - ast_log(LOG_DEBUG, "SQL query: %s\n", query); + ast_debug(1, "SQL query: %s\n", query); args.cfg = cfg; args.initfield = initfield; @@ -1157,7 +1157,7 @@ static int realtime_update_handler(const char *database, const char *table, sqlite_freemem(query); query = tmp_str; - ast_log(LOG_DEBUG, "SQL query: %s\n", query); + ast_debug(1, "SQL query: %s\n", query); ast_mutex_lock(&mutex); diff --git a/res/res_crypto.c b/res/res_crypto.c index 341723d70..73a54ba6d 100644 --- a/res/res_crypto.c +++ b/res/res_crypto.c @@ -258,8 +258,7 @@ static struct ast_key *try_load_key (char *dir, char *fname, int ifd, int ofd, i key->ktype &= ~KEY_NEEDS_PASSCODE; if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Loaded %s key '%s'\n", key->ktype == AST_KEY_PUBLIC ? "PUBLIC" : "PRIVATE", key->name); - if (option_debug) - ast_log(LOG_DEBUG, "Key '%s' loaded OK\n", key->name); + ast_debug(1, "Key '%s' loaded OK\n", key->name); key->delme = 0; } else ast_log(LOG_NOTICE, "Key '%s' is not expected size.\n", key->name); @@ -436,8 +435,7 @@ 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) { - if (option_debug) - ast_log(LOG_DEBUG, "Key failed verification: %s\n", key->name); + ast_debug(1, "Key failed verification: %s\n", key->name); return -1; } /* Pass */ @@ -491,8 +489,7 @@ static void crypto_load(int ifd, int ofd) while(key) { nkey = key->next; if (key->delme) { - if (option_debug) - ast_log(LOG_DEBUG, "Deleting key %s type %d\n", key->name, key->ktype); + ast_debug(1, "Deleting key %s type %d\n", key->name, key->ktype); /* Do the delete */ if (last) last->next = nkey; diff --git a/res/res_features.c b/res/res_features.c index b4feda26c..bd8504f05 100644 --- a/res/res_features.c +++ b/res/res_features.c @@ -324,8 +324,7 @@ static int adsi_announce_park(struct ast_channel *chan, char *parkingexten) /*! \brief Notify metermaids that we've changed an extension */ static void notify_metermaids(const char *exten, char *context) { - if (option_debug > 3) - ast_log(LOG_DEBUG, "Notification of state change to metermaids %s@%s\n", exten, context); + ast_debug(4, "Notification of state change to metermaids %s@%s\n", exten, context); /* Send notification to devicestate subsystem */ ast_device_state_changed("park:%s@%s", exten, context); @@ -343,8 +342,7 @@ static enum ast_device_state metermaidstate(const char *data) if (!context) return res; - if (option_debug > 3) - ast_log(LOG_DEBUG, "Checking state of exten %s in context %s\n", exten, context); + ast_debug(4, "Checking state of exten %s in context %s\n", exten, context); res = ast_exists_extension(NULL, context, exten, 1, NULL); @@ -807,8 +805,7 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st struct ast_frame *f; int l; - if (option_debug) - ast_log(LOG_DEBUG, "Executing Attended Transfer %s, %s (sense=%d) \n", chan->name, peer->name, sense); + ast_debug(1, "Executing Attended Transfer %s, %s (sense=%d) \n", chan->name, peer->name, sense); set_peers(&transferer, &transferee, peer, chan, sense); transferer_real_context = real_ctx(transferer, transferee); /* Start autoservice on chan while we talk to the originator */ @@ -957,11 +954,9 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st } if (!newchan) { /* Transfer failed, sleeping */ - if (option_debug) - ast_log(LOG_DEBUG, "Sleeping for %d ms before callback.\n", atxferloopdelay); + ast_debug(1, "Sleeping for %d ms before callback.\n", atxferloopdelay); ast_safe_sleep(transferee, atxferloopdelay); - if (option_debug) - ast_log(LOG_DEBUG, "Trying to callback...\n"); + ast_debug(1, "Trying to callback...\n"); newchan = ast_feature_request_and_dial(transferee, NULL, "Local", ast_best_codec(transferee->nativeformats), callbackto, atxfernoanswertimeout, &outstate, transferee->cid.cid_num, transferee->cid.cid_name, 0); } @@ -1329,8 +1324,7 @@ static int ast_feature_interpret(struct ast_channel *chan, struct ast_channel *p ast_copy_flags(&features, &(config->features_caller), AST_FLAGS_ALL); else ast_copy_flags(&features, &(config->features_callee), AST_FLAGS_ALL); - if (option_debug > 2) - ast_log(LOG_DEBUG, "Feature interpret: chan=%s, peer=%s, sense=%d, features=%d\n", chan->name, peer->name, sense, features.flags); + ast_debug(3, "Feature interpret: chan=%s, peer=%s, sense=%d, features=%d\n", chan->name, peer->name, sense, features.flags); ast_rwlock_rdlock(&features_lock); for (x = 0; x < FEATURES_COUNT; x++) { @@ -1693,8 +1687,7 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast activated, but that's no excuse to keep things going indefinitely! */ if (backup_config.feature_timer && ((backup_config.feature_timer -= diff) <= 0)) { - if (option_debug) - ast_log(LOG_DEBUG, "Timed out, realtime this time!\n"); + ast_debug(1, "Timed out, realtime this time!\n"); config->feature_timer = 0; who = chan; if (f) @@ -1704,8 +1697,7 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast } else if (config->feature_timer <= 0) { /* Not *really* out of time, just out of time for digits to come in for features. */ - if (option_debug) - ast_log(LOG_DEBUG, "Timed out for feature!\n"); + ast_debug(1, "Timed out for feature!\n"); if (!ast_strlen_zero(peer_featurecode)) { ast_dtmf_stream(chan, peer, peer_featurecode, 0); memset(peer_featurecode, 0, sizeof(peer_featurecode)); @@ -1827,8 +1819,7 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast } config->start_time = ast_tvnow(); config->feature_timer = featuredigittimeout; - if (option_debug) - ast_log(LOG_DEBUG, "Set time limit to %ld\n", config->feature_timer); + ast_debug(1, "Set time limit to %ld\n", config->feature_timer); } } if (f) @@ -2032,8 +2023,7 @@ static void *do_parking_thread(void *ignore) /*! \todo XXX Maybe we could do something with packets, like dial "0" for operator or something XXX */ ast_frfree(f); if (pu->moh_trys < 3 && !chan->generatordata) { - if (option_debug) - ast_log(LOG_DEBUG, "MOH on parked call stopped by outside source. Restarting.\n"); + ast_debug(1, "MOH on parked call stopped by outside source. Restarting.\n"); ast_indicate_data(chan, AST_CONTROL_HOLD, S_OR(parkmohclass, NULL), !ast_strlen_zero(parkmohclass) ? strlen(parkmohclass) + 1 : 0); @@ -2573,8 +2563,7 @@ int ast_pickup_call(struct ast_channel *chan) ast_channel_unlock(cur); } if (cur) { - if (option_debug) - ast_log(LOG_DEBUG, "Call pickup on chan '%s' by '%s'\n",cur->name, chan->name); + ast_debug(1, "Call pickup on chan '%s' by '%s'\n",cur->name, chan->name); res = ast_answer(chan); if (res) ast_log(LOG_WARNING, "Unable to answer '%s'\n", chan->name); @@ -2586,8 +2575,7 @@ int ast_pickup_call(struct ast_channel *chan) ast_log(LOG_WARNING, "Unable to masquerade '%s' into '%s'\n", chan->name, cur->name); /* Done */ ast_channel_unlock(cur); } else { - if (option_debug) - ast_log(LOG_DEBUG, "No call pickup possible...\n"); + ast_debug(1, "No call pickup possible...\n"); } return res; } @@ -2880,8 +2868,7 @@ static int load_config(void) if (!ast_strlen_zero(old_parking_con) && (con = ast_context_find(old_parking_con))) { if(ast_context_remove_extension2(con, old_parking_ext, 1, registrar)) notify_metermaids(old_parking_ext, old_parking_con); - if (option_debug) - ast_log(LOG_DEBUG, "Removed old parking extension %s@%s\n", old_parking_ext, old_parking_con); + ast_debug(1, "Removed old parking extension %s@%s\n", old_parking_ext, old_parking_con); } if (!(con = ast_context_find(parking_con)) && !(con = ast_context_create(NULL, parking_con, registrar))) { @@ -3023,20 +3010,17 @@ static int bridge_exec(struct ast_channel *chan, void *data) /* the bridge has ended, set BRIDGERESULT to SUCCESS. If the other channel has not been hung up, return it to the PBX */ pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "SUCCESS"); if (!ast_check_hangup(final_dest_chan)) { - if (option_debug) { - ast_log(LOG_DEBUG, "starting new PBX in %s,%s,%d for chan %s\n", + ast_debug(1, "starting new PBX in %s,%s,%d for chan %s\n", final_dest_chan->context, final_dest_chan->exten, final_dest_chan->priority, final_dest_chan->name); - } if (ast_pbx_start(final_dest_chan) != AST_PBX_SUCCESS) { ast_log(LOG_WARNING, "FAILED continuing PBX on dest chan %s\n", final_dest_chan->name); ast_hangup(final_dest_chan); - } else if (option_debug) - ast_log(LOG_DEBUG, "SUCCESS continuing PBX on chan %s\n", final_dest_chan->name); + } else + ast_debug(1, "SUCCESS continuing PBX on chan %s\n", final_dest_chan->name); } else { - if (option_debug) - ast_log(LOG_DEBUG, "hangup chan %s since the other endpoint has hung up\n", final_dest_chan->name); + ast_debug(1, "hangup chan %s since the other endpoint has hung up\n", final_dest_chan->name); ast_hangup(final_dest_chan); } diff --git a/res/res_jabber.c b/res/res_jabber.c index d7af93d53..2562f43ef 100644 --- a/res/res_jabber.c +++ b/res/res_jabber.c @@ -683,32 +683,26 @@ static int aji_act_hook(void *data, int type, iks *node) switch (pak->type) { case IKS_PAK_NONE: - if (option_debug) - ast_log(LOG_DEBUG, "JABBER: I Don't know what to do with you NONE\n"); + ast_debug(1, "JABBER: I Don't know what to do with you NONE\n"); break; case IKS_PAK_MESSAGE: aji_handle_message(client, pak); - if (option_debug) - ast_log(LOG_DEBUG, "JABBER: I Don't know what to do with you MESSAGE\n"); + ast_debug(1, "JABBER: I Don't know what to do with you MESSAGE\n"); break; case IKS_PAK_PRESENCE: aji_handle_presence(client, pak); - if (option_debug) - ast_log(LOG_DEBUG, "JABBER: I Do know how to handle presence!!\n"); + ast_debug(1, "JABBER: I Do know how to handle presence!!\n"); break; case IKS_PAK_S10N: aji_handle_subscribe(client, pak); - if (option_debug) - ast_log(LOG_DEBUG, "JABBER: I Dont know S10N subscribe!!\n"); + ast_debug(1, "JABBER: I Dont know S10N subscribe!!\n"); break; case IKS_PAK_IQ: - if (option_debug) - ast_log(LOG_DEBUG, "JABBER: I Dont have an IQ!!!\n"); + ast_debug(1, "JABBER: I Dont have an IQ!!!\n"); aji_handle_iq(client, node); break; default: - if (option_debug) - ast_log(LOG_DEBUG, "JABBER: I Dont know %i\n", pak->type); + ast_debug(1, "JABBER: I Dont know %i\n", pak->type); break; } @@ -1346,8 +1340,7 @@ static void aji_handle_presence(struct aji_client *client, ikspak *pak) if(gtalk_yuck(pak->x)) /* gtalk should do discover */ found->cap->jingle = 1; if(found->cap->jingle && option_debug > 4) { - if (option_debug) - ast_log(LOG_DEBUG,"Special case for google till they support discover.\n"); + ast_debug(1,"Special case for google till they support discover.\n"); } else { iks *iq, *query; @@ -1597,8 +1590,7 @@ static void *aji_recv_loop(void *data) res = iks_recv(client->p, 1); if (client->state == AJI_DISCONNECTING) { - if (option_debug > 1) - ast_log(LOG_DEBUG, "Ending our Jabber client's thread due to a disconnect\n"); + ast_debug(2, "Ending our Jabber client's thread due to a disconnect\n"); pthread_exit(NULL); } client->timeout--; @@ -2512,8 +2504,7 @@ static int unload_module(void) ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { ASTOBJ_RDLOCK(iterator); - if (option_debug > 2) - ast_log(LOG_DEBUG, "JABBER: Releasing and disconneing client: %s\n", iterator->name); + ast_debug(3, "JABBER: Releasing and disconneing client: %s\n", iterator->name); iterator->state = AJI_DISCONNECTING; ast_aji_disconnect(iterator); pthread_join(iterator->thread, NULL); diff --git a/res/res_monitor.c b/res/res_monitor.c index 5bff1b1ff..d23c6f727 100644 --- a/res/res_monitor.c +++ b/res/res_monitor.c @@ -222,9 +222,7 @@ 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 { - if (option_debug) - ast_log(LOG_DEBUG,"Cannot start monitoring %s, already monitored\n", - chan->name); + ast_debug(1,"Cannot start monitoring %s, already monitored\n", chan->name); res = -1; } @@ -315,8 +313,7 @@ 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)); } - if (option_debug) - ast_log(LOG_DEBUG,"monitor executing %s\n",tmp); + ast_debug(1,"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 22e44302f..765786369 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -250,8 +250,7 @@ static int ast_moh_files_next(struct ast_channel *chan) return -1; } - if (option_debug) - ast_log(LOG_DEBUG, "%s Opened file %d '%s'\n", chan->name, state->pos, state->class->filearray[state->pos]); + ast_debug(1, "%s Opened file %d '%s'\n", chan->name, state->pos, state->class->filearray[state->pos]); if (state->samples) ast_seekstream(chan->stream, state->samples, SEEK_SET); @@ -583,8 +582,7 @@ static void *monmp3thread(void *data) class->pid = 0; } } else { - if (option_debug) - ast_log(LOG_DEBUG, "Read %d bytes of audio while expecting %d\n", res2, len); + ast_debug(1, "Read %d bytes of audio while expecting %d\n", res2, len); } continue; } @@ -593,8 +591,7 @@ static void *monmp3thread(void *data) AST_RWLIST_TRAVERSE(&class->members, moh, list) { /* Write data */ if ((res = write(moh->pipe[1], sbuf, res2)) != res2) { - if (option_debug) - ast_log(LOG_DEBUG, "Only wrote %d of %d bytes to pipe\n", res, res2); + ast_debug(1, "Only wrote %d of %d bytes to pipe\n", res, res2); } } AST_RWLIST_UNLOCK(&mohclasses); @@ -875,8 +872,7 @@ static int moh_register(struct mohclass *moh, int reload) AST_RWLIST_WRLOCK(&mohclasses); if (get_mohbyname(moh->name)) { if (reload) { - if (option_debug) - ast_log(LOG_DEBUG, "Music on Hold class '%s' left alone from initial load.\n", moh->name); + ast_debug(1, "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); } @@ -1100,8 +1096,7 @@ static void ast_moh_destroy(void) AST_RWLIST_WRLOCK(&mohclasses); while ((moh = AST_RWLIST_REMOVE_HEAD(&mohclasses, list))) { if (moh->pid > 1) { - if (option_debug) - ast_log(LOG_DEBUG, "killing %d!\n", moh->pid); + ast_debug(1, "killing %d!\n", moh->pid); stime = time(NULL) + 2; pid = moh->pid; moh->pid = 0; @@ -1115,8 +1110,7 @@ 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; - if (option_debug) - ast_log(LOG_DEBUG, "mpg123 pid %d and child died after %d bytes read\n", pid, tbytes); + ast_debug(1, "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 f3d695408..fc9d6d1e4 100644 --- a/res/res_smdi.c +++ b/res/res_smdi.c @@ -111,8 +111,7 @@ int ast_smdi_mwi_set(struct ast_smdi_interface *iface, const char *mailbox) fclose(file); ASTOBJ_UNLOCK(iface); - if (option_debug) - ast_log(LOG_DEBUG, "Sent MWI set message for %s on %s\n", mailbox, iface->name); + ast_debug(1, "Sent MWI set message for %s on %s\n", mailbox, iface->name); return 0; } @@ -143,8 +142,7 @@ int ast_smdi_mwi_unset(struct ast_smdi_interface *iface, const char *mailbox) fclose(file); ASTOBJ_UNLOCK(iface); - if (option_debug) - ast_log(LOG_DEBUG, "Sent MWI unset message for %s on %s\n", mailbox, iface->name); + ast_debug(1, "Sent MWI unset message for %s on %s\n", mailbox, iface->name); return 0; } @@ -413,8 +411,7 @@ 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); - if (option_debug) - ast_log(LOG_DEBUG, "Recieved SMDI MD message on %s\n", iface->name); + ast_debug(1, "Recieved SMDI MD message on %s\n", iface->name); ASTOBJ_UNREF(md_msg, ast_smdi_md_message_destroy); @@ -457,8 +454,7 @@ 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); - if (option_debug) - ast_log(LOG_DEBUG, "Recieved SMDI MWI message on %s\n", iface->name); + ast_debug(1, "Recieved SMDI MWI message on %s\n", iface->name); ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy); } else { -- cgit v1.2.3