Index: main/loader.c =================================================================== --- main/loader.c (revision 69516) +++ main/loader.c (working copy) @@ -248,8 +248,7 @@ for (pos = 0, x = 0; x < 16; x++) pos += sprintf(buf + pos, " %02x", *d++); - if (option_debug) - ast_log(LOG_DEBUG, "Unexpected signature:%s\n", buf); + ast_debug(1, "Unexpected signature:%s\n", buf); return 0; } Index: main/manager.c =================================================================== --- main/manager.c (revision 69516) +++ main/manager.c (working copy) @@ -1062,7 +1062,7 @@ if (!strcmp(md5key, key)) error = 0; } else { - ast_log(LOG_DEBUG, "MD5 authentication is not possible. challenge: '%s'\n", + ast_debug(1, "MD5 authentication is not possible. challenge: '%s'\n", S_OR(s->challenge, "")); return -1; } @@ -1369,8 +1369,7 @@ /* XXX should this go inside the lock ? */ s->waiting_thread = pthread_self(); /* let new events wake up this thread */ - if (option_debug) - ast_log(LOG_DEBUG, "Starting waiting for an event!\n"); + ast_debug(1, "Starting waiting for an event!\n"); for (x=0; x < timeout || timeout < 0; x++) { ast_mutex_lock(&s->__lock); @@ -1394,8 +1393,7 @@ sleep(1); } } - if (option_debug) - ast_log(LOG_DEBUG, "Finished waiting for an event!\n"); + ast_debug(1, "Finished waiting for an event!\n"); ast_mutex_lock(&s->__lock); if (s->waiting_thread == pthread_self()) { struct eventqent *eqe; @@ -1414,8 +1412,7 @@ "\r\n", idText); s->waiting_thread = AST_PTHREADT_NULL; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Abandoning event request!\n"); + ast_debug(1, "Abandoning event request!\n"); } ast_mutex_unlock(&s->__lock); return 0; @@ -2331,8 +2328,7 @@ const char *user = astman_get_header(m, "Username"); ast_copy_string(action, astman_get_header(m, "Action"), sizeof(action)); - if (option_debug) - ast_log(LOG_DEBUG, "Manager received command '%s'\n", action); + ast_debug(1, "Manager received command '%s'\n", action); if (ast_strlen_zero(action)) { astman_send_error(s, m, "Missing action in request"); @@ -3161,12 +3157,10 @@ if (s->needdestroy) { if (s->inuse == 1) { - if (option_debug) - ast_log(LOG_DEBUG, "Need destroy, doing it now!\n"); + ast_debug(1, "Need destroy, doing it now!\n"); blastaway = 1; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Need destroy, but can't do it yet!\n"); + ast_debug(1, "Need destroy, but can't do it yet!\n"); if (s->waiting_thread != AST_PTHREADT_NULL) pthread_kill(s->waiting_thread, SIGURG); s->inuse--; @@ -3423,8 +3417,7 @@ } else if (!strcasecmp(var->name, "displayconnects") ) user->displayconnects = ast_true(var->value); else { - if (option_debug) - ast_log(LOG_DEBUG, "%s is an unknown option.\n", var->name); + ast_debug(1, "%s is an unknown option.\n", var->name); } var = var->next; } Index: main/http.c =================================================================== --- main/http.c (revision 69516) +++ main/http.c (working copy) @@ -350,7 +350,7 @@ struct ast_http_post_mapping *post_map; if (!ast_strlen_zero(prefix) && strncmp(prefix, uri, strlen(prefix))) { - ast_log(LOG_DEBUG, "URI %s does not have prefix %s\n", uri, prefix); + ast_debug(1, "URI %s does not have prefix %s\n", uri, prefix); return NULL; } @@ -389,8 +389,7 @@ snprintf(filename, sizeof(filename), "%s/%s", post_dir, fn); - if (option_debug) - ast_log(LOG_DEBUG, "Posting raw data to %s\n", filename); + ast_debug(1, "Posting raw data to %s\n", filename); if (!(f = fopen(filename, "w"))) { ast_log(LOG_WARNING, "Unable to open %s for writing file from a POST!\n", filename); @@ -398,15 +397,13 @@ } if (!(body = mm_mimepart_getbody(part, 0))) { - if (option_debug) - ast_log(LOG_DEBUG, "Couldn't get the mimepart body\n"); + ast_debug(1, "Couldn't get the mimepart body\n"); fclose(f); return; } body_len = mm_mimepart_getlength(part); - if (option_debug) - ast_log(LOG_DEBUG, "Body length is %ld\n", (long int)body_len); + ast_debug(1, "Body length is %ld\n", (long int)body_len); fwrite(body, 1, body_len, f); @@ -462,8 +459,7 @@ fclose(f); return NULL; } - if (option_debug) - ast_log(LOG_DEBUG, "Got a Content-Length of %d\n", content_len); + ast_debug(1, "Got a Content-Length of %d\n", content_len); } else if (!strcasecmp(var->name, "Content-Type")) fprintf(f, "Content-Type: %s\r\n\r\n", var->value); } @@ -476,16 +472,14 @@ } if (fseek(f, SEEK_SET, 0)) { - if (option_debug) - ast_log(LOG_DEBUG, "Failed to seek temp file back to beginning.\n"); + ast_debug(1, "Failed to seek temp file back to beginning.\n"); fclose(f); return NULL; } AST_RWLIST_RDLOCK(&post_mappings); if (!(post_map = find_post_mapping(uri))) { - if (option_debug) - ast_log(LOG_DEBUG, "%s is not a valid URI for POST\n", uri); + ast_debug(1, "%s is not a valid URI for POST\n", uri); AST_RWLIST_UNLOCK(&post_mappings); fclose(f); *status = 404; @@ -496,8 +490,7 @@ post_map = NULL; AST_RWLIST_UNLOCK(&post_mappings); - if (option_debug) - ast_log(LOG_DEBUG, "Going to post files to dir %s\n", post_dir); + ast_debug(1, "Going to post files to dir %s\n", post_dir); if (!(ctx = mm_context_new())) { fclose(f); @@ -525,9 +518,9 @@ if (option_debug) { if (mm_context_iscomposite(ctx)) - ast_log(LOG_DEBUG, "Found %d MIME parts\n", mm_res - 1); + ast_debug(1, "Found %d MIME parts\n", mm_res - 1); else - ast_log(LOG_DEBUG, "We have a flat (not multi-part) message\n"); + ast_debug(1, "We have a flat (not multi-part) message\n"); } for (i = 1; i < mm_res; i++) { @@ -535,20 +528,17 @@ char fn[PATH_MAX]; if (!(part = mm_context_getpart(ctx, i))) { - if (option_debug) - ast_log(LOG_DEBUG, "Failed to get mime part num %d\n", i); + ast_debug(1, "Failed to get mime part num %d\n", i); continue; } if (get_filename(part, fn, sizeof(fn))) { - if (option_debug) - ast_log(LOG_DEBUG, "Failed to retrieve a filename for part num %d\n", i); + ast_debug(1, "Failed to retrieve a filename for part num %d\n", i); continue; } if (!part->type) { - if (option_debug) - ast_log(LOG_DEBUG, "This part has no content struct?\n"); + ast_debug(1, "This part has no content struct?\n"); continue; } @@ -991,8 +981,7 @@ /* Do nothing if nothing has changed */ if (!memcmp(&desc->oldsin, &desc->sin, sizeof(desc->oldsin))) { - if (option_debug) - ast_log(LOG_DEBUG, "Nothing changed in %s\n", desc->name); + ast_debug(1, "Nothing changed in %s\n", desc->name); return; } Index: main/translate.c =================================================================== --- main/translate.c (revision 69516) +++ main/translate.c (working copy) @@ -423,8 +423,7 @@ int y; /* intermediate format index */ int z; /* destination format index */ - if (option_debug) - ast_log(LOG_DEBUG, "Resetting translation matrix\n"); + ast_debug(1, "Resetting translation matrix\n"); bzero(tr_matrix, sizeof(tr_matrix)); @@ -478,8 +477,7 @@ tr_matrix[x][z].step = tr_matrix[x][y].step; tr_matrix[x][z].cost = newcost; tr_matrix[x][z].multistep = 1; - if (option_debug) - ast_log(LOG_DEBUG, "Discovered %d cost path from %s to %s, via %d\n", tr_matrix[x][z].cost, ast_getformatname(x), ast_getformatname(z), y); + ast_debug(1, "Discovered %d cost path from %s to %s, via %d\n", tr_matrix[x][z].cost, ast_getformatname(x), ast_getformatname(z), y); changed++; } } Index: main/jitterbuf.c =================================================================== --- main/jitterbuf.c (revision 69516) +++ main/jitterbuf.c (working copy) @@ -38,6 +38,7 @@ #include "jitterbuf.h" #include "asterisk/utils.h" +#include "asterisk/options.h" /*! define these here, just for ancient compiler systems */ #define JB_LONGMAX 2147483647L @@ -532,7 +533,7 @@ if (jb->frames) numts = jb->frames->prev->ts - jb->frames->ts; if (numts >= jb->info.conf.max_jitterbuf) { - ast_log(LOG_DEBUG, "Attempting to exceed Jitterbuf max %ld timeslots\n", + ast_debug(1, "Attempting to exceed Jitterbuf max %ld timeslots\n", jb->info.conf.max_jitterbuf); jb->dropem = 1; return JB_DROP; Index: main/rtp.c =================================================================== --- main/rtp.c (revision 69516) +++ main/rtp.c (working copy) @@ -435,34 +435,29 @@ int resplen, respleft; if (len < sizeof(struct stun_header)) { - if (option_debug) - ast_log(LOG_DEBUG, "Runt STUN packet (only %d, wanting at least %d)\n", (int) len, (int) sizeof(struct stun_header)); + ast_debug(1, "Runt STUN packet (only %d, wanting at least %d)\n", (int) len, (int) sizeof(struct stun_header)); return -1; } if (stundebug) ast_verbose("STUN Packet, msg %s (%04x), length: %d\n", stun_msg2str(ntohs(hdr->msgtype)), ntohs(hdr->msgtype), ntohs(hdr->msglen)); if (ntohs(hdr->msglen) > len - sizeof(struct stun_header)) { - if (option_debug) - ast_log(LOG_DEBUG, "Scrambled STUN packet length (got %d, expecting %d)\n", ntohs(hdr->msglen), (int)(len - sizeof(struct stun_header))); + ast_debug(1, "Scrambled STUN packet length (got %d, expecting %d)\n", ntohs(hdr->msglen), (int)(len - sizeof(struct stun_header))); } else len = ntohs(hdr->msglen); data += sizeof(struct stun_header); memset(&st, 0, sizeof(st)); while (len) { if (len < sizeof(struct stun_attr)) { - if (option_debug) - ast_log(LOG_DEBUG, "Runt Attribute (got %d, expecting %d)\n", (int)len, (int) sizeof(struct stun_attr)); + ast_debug(1, "Runt Attribute (got %d, expecting %d)\n", (int)len, (int) sizeof(struct stun_attr)); break; } attr = (struct stun_attr *)data; if (ntohs(attr->len) > len) { - if (option_debug) - ast_log(LOG_DEBUG, "Inconsistent Attribute (length %d exceeds remaining msg len %d)\n", ntohs(attr->len), (int)len); + ast_debug(1, "Inconsistent Attribute (length %d exceeds remaining msg len %d)\n", ntohs(attr->len), (int)len); break; } if (stun_process_attr(&st, attr)) { - if (option_debug) - ast_log(LOG_DEBUG, "Failed to handle attribute %s (%04x)\n", stun_attr2str(ntohs(attr->attr)), ntohs(attr->attr)); + ast_debug(1, "Failed to handle attribute %s (%04x)\n", stun_attr2str(ntohs(attr->attr)), ntohs(attr->attr)); break; } /* Clear attribute in case previous entry was a string */ @@ -637,14 +632,12 @@ { if (((ast_test_flag(rtp, FLAG_DTMF_COMPENSATE) && type == AST_FRAME_DTMF_END) || (type == AST_FRAME_DTMF_BEGIN)) && ast_tvcmp(ast_tvnow(), rtp->dtmfmute) < 0) { - if (option_debug) - ast_log(LOG_DEBUG, "Ignore potential DTMF echo from '%s'\n", ast_inet_ntoa(rtp->them.sin_addr)); + ast_debug(1, "Ignore potential DTMF echo from '%s'\n", ast_inet_ntoa(rtp->them.sin_addr)); rtp->resp = 0; rtp->dtmfsamples = 0; return &ast_null_frame; } - if (option_debug) - ast_log(LOG_DEBUG, "Sending dtmf: %d (%c), at %s\n", rtp->resp, rtp->resp, ast_inet_ntoa(rtp->them.sin_addr)); + ast_debug(1, "Sending dtmf: %d (%c), at %s\n", rtp->resp, rtp->resp, ast_inet_ntoa(rtp->them.sin_addr)); if (rtp->resp == 'X') { rtp->f.frametype = AST_FRAME_CONTROL; rtp->f.subclass = AST_CONTROL_FLASH; @@ -736,7 +729,7 @@ event = data[3] & 0x1f; if (option_debug > 2 || rtpdebug) - ast_log(LOG_DEBUG, "Cisco DTMF Digit: %02x (len=%d, seq=%d, flags=%02x, power=%d, history count=%d)\n", event, len, seq, flags, power, (len - 4) / 2); + ast_debug(0, "Cisco DTMF Digit: %02x (len=%d, seq=%d, flags=%02x, power=%d, history count=%d)\n", event, len, seq, flags, power, (len - 4) / 2); if (event < 10) { resp = '0' + event; } else if (event < 11) { @@ -796,7 +789,7 @@ /* Print out debug if turned on */ if (rtpdebug || option_debug > 2) - ast_log(LOG_DEBUG, "- RTP 2833 Event: %08x (len = %d)\n", event, len); + ast_debug(0, "- RTP 2833 Event: %08x (len = %d)\n", event, len); /* Figure out what digit was pressed */ if (event < 10) { @@ -849,7 +842,7 @@ totally help us out becuase we don't have an engine to keep it going and we are not guaranteed to have it every 20ms or anything */ if (rtpdebug) - ast_log(LOG_DEBUG, "- RTP 3389 Comfort noise event: Level %d (len = %d)\n", rtp->lastrxformat, len); + ast_debug(0, "- RTP 3389 Comfort noise event: Level %d (len = %d)\n", rtp->lastrxformat, len); if (!(ast_test_flag(rtp, FLAG_3389_WARNING))) { ast_log(LOG_NOTICE, "Comfort noise support incomplete in Asterisk (RFC 3389). Please turn off on client if possible. Client IP: %s\n", @@ -939,12 +932,11 @@ (rtp->rtcp->them.sin_port != sin.sin_port)) { memcpy(&rtp->rtcp->them, &sin, sizeof(rtp->rtcp->them)); if (option_debug || rtpdebug) - ast_log(LOG_DEBUG, "RTCP NAT: Got RTCP from other end. Now sending to address %s:%d\n", ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port)); + ast_debug(0, "RTCP NAT: Got RTCP from other end. Now sending to address %s:%d\n", ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port)); } } - if (option_debug) - ast_log(LOG_DEBUG, "Got RTCP report of %d bytes\n", res); + ast_debug(1, "Got RTCP report of %d bytes\n", res); /* Process a compound packet */ position = 0; @@ -1058,8 +1050,7 @@ ast_verbose("Received a BYE from %s:%d\n", ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port)); break; default: - if (option_debug) - ast_log(LOG_DEBUG, "Unknown RTCP packet (pt=%d) received from %s:%d\n", pt, ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port)); + ast_debug(1, "Unknown RTCP packet (pt=%d) received from %s:%d\n", pt, ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port)); break; } position += (length + 1); @@ -1155,11 +1146,10 @@ res = sendto(bridged->s, (void *)rtpheader, len, 0, (struct sockaddr *)&bridged->them, sizeof(bridged->them)); if (res < 0) { if (!bridged->nat || (bridged->nat && (ast_test_flag(bridged, FLAG_NAT_ACTIVE) == FLAG_NAT_ACTIVE))) { - if (option_debug) - ast_log(LOG_DEBUG, "RTP Transmission error of packet to %s:%d: %s\n", ast_inet_ntoa(bridged->them.sin_addr), ntohs(bridged->them.sin_port), strerror(errno)); + ast_debug(1, "RTP Transmission error of packet to %s:%d: %s\n", ast_inet_ntoa(bridged->them.sin_addr), ntohs(bridged->them.sin_port), strerror(errno)); } else if (((ast_test_flag(bridged, FLAG_NAT_ACTIVE) == FLAG_NAT_INACTIVE) || rtpdebug) && !ast_test_flag(bridged, FLAG_NAT_INACTIVE_NOWARN)) { if (option_debug || rtpdebug) - ast_log(LOG_DEBUG, "RTP NAT: Can't write RTP to private address %s:%d, waiting for other end to send audio...\n", ast_inet_ntoa(bridged->them.sin_addr), ntohs(bridged->them.sin_port)); + ast_debug(0, "RTP NAT: Can't write RTP to private address %s:%d, waiting for other end to send audio...\n", ast_inet_ntoa(bridged->them.sin_addr), ntohs(bridged->them.sin_port)); ast_set_flag(bridged, FLAG_NAT_INACTIVE_NOWARN); } return 0; @@ -1244,7 +1234,7 @@ rtp->rxseqno = 0; ast_set_flag(rtp, FLAG_NAT_ACTIVE); if (option_debug || rtpdebug) - ast_log(LOG_DEBUG, "RTP NAT: Got audio from other end. Now sending to address %s:%d\n", ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port)); + ast_debug(0, "RTP NAT: Got audio from other end. Now sending to address %s:%d\n", ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port)); } } @@ -1265,7 +1255,7 @@ if (!mark && rtp->rxssrc && rtp->rxssrc != ssrc) { if (option_debug || rtpdebug) - ast_log(LOG_DEBUG, "Forcing Marker bit, because SSRC has changed\n"); + ast_debug(0, "Forcing Marker bit, because SSRC has changed\n"); mark = 1; } @@ -1284,9 +1274,9 @@ int profile; profile = (ntohl(rtpheader[3]) & 0xffff0000) >> 16; if (profile == 0x505a) - ast_log(LOG_DEBUG, "Found Zfone extension in RTP stream - zrtp - not supported.\n"); + ast_debug(1, "Found Zfone extension in RTP stream - zrtp - not supported.\n"); else - ast_log(LOG_DEBUG, "Found unknown RTP Extensions %x\n", profile); + ast_debug(1, "Found unknown RTP Extensions %x\n", profile); } } @@ -1576,16 +1566,14 @@ if (c1) srcpr = get_proto(c1); if (!destpr) { - if (option_debug) - ast_log(LOG_DEBUG, "Channel '%s' has no RTP, not doing anything\n", c0->name); + ast_debug(1, "Channel '%s' has no RTP, not doing anything\n", c0->name); ast_channel_unlock(c0); if (c1) ast_channel_unlock(c1); return -1; } if (!srcpr) { - if (option_debug) - ast_log(LOG_DEBUG, "Channel '%s' has no RTP, not doing anything\n", c1 ? c1->name : ""); + ast_debug(1, "Channel '%s' has no RTP, not doing anything\n", c1 ? c1->name : ""); ast_channel_unlock(c0); if (c1) ast_channel_unlock(c1); @@ -1636,8 +1624,7 @@ ast_channel_unlock(c0); if (c1) ast_channel_unlock(c1); - if (option_debug) - ast_log(LOG_DEBUG, "Setting early bridge SDP of '%s' with that of '%s'\n", c0->name, c1 ? c1->name : ""); + ast_debug(1, "Setting early bridge SDP of '%s' with that of '%s'\n", c0->name, c1 ? c1->name : ""); return 0; } @@ -1661,15 +1648,13 @@ /* Find channel driver interfaces */ if (!(destpr = get_proto(dest))) { - if (option_debug) - ast_log(LOG_DEBUG, "Channel '%s' has no RTP, not doing anything\n", dest->name); + ast_debug(1, "Channel '%s' has no RTP, not doing anything\n", dest->name); ast_channel_unlock(dest); ast_channel_unlock(src); return 0; } if (!(srcpr = get_proto(src))) { - if (option_debug) - ast_log(LOG_DEBUG, "Channel '%s' has no RTP, not doing anything\n", src->name); + ast_debug(1, "Channel '%s' has no RTP, not doing anything\n", src->name); ast_channel_unlock(dest); ast_channel_unlock(src); return 0; @@ -1712,8 +1697,7 @@ } ast_channel_unlock(dest); ast_channel_unlock(src); - if (option_debug) - ast_log(LOG_DEBUG, "Seeded SDP of '%s' with that of '%s'\n", dest->name, src->name); + ast_debug(1, "Seeded SDP of '%s' with that of '%s'\n", dest->name, src->name); return 1; } @@ -2688,8 +2672,7 @@ if (abs(rtp->lastts - pred) < MAX_TIMESTAMP_SKEW) rtp->lastts = pred; else { - if (option_debug > 2) - ast_log(LOG_DEBUG, "Difference is %d, ms is %d\n", abs(rtp->lastts - pred), ms); + ast_debug(3, "Difference is %d, ms is %d\n", abs(rtp->lastts - pred), ms); mark = 1; } } @@ -2704,8 +2687,7 @@ rtp->lastts = pred; rtp->lastovidtimestamp += f->samples; } else { - if (option_debug > 2) - ast_log(LOG_DEBUG, "Difference is %d, ms is %d (%d), pred/ts/samples %d/%d/%d\n", abs(rtp->lastts - pred), ms, ms * 90, rtp->lastts, pred, f->samples); + ast_debug(3, "Difference is %d, ms is %d (%d), pred/ts/samples %d/%d/%d\n", abs(rtp->lastts - pred), ms, ms * 90, rtp->lastts, pred, f->samples); rtp->lastovidtimestamp = rtp->lastts; } } @@ -2719,8 +2701,7 @@ rtp->lastts = pred; rtp->lastotexttimestamp += f->samples; } else { - if (option_debug > 2) - ast_log(LOG_DEBUG, "Difference is %d, ms is %d (%d), pred/ts/samples %d/%d/%d\n", abs(rtp->lastts - pred), ms, ms * 90, rtp->lastts, pred, f->samples); + ast_debug(3, "Difference is %d, ms is %d (%d), pred/ts/samples %d/%d/%d\n", abs(rtp->lastts - pred), ms, ms * 90, rtp->lastts, pred, f->samples); rtp->lastotexttimestamp = rtp->lastts; } } @@ -2745,12 +2726,11 @@ res = sendto(rtp->s, (void *)rtpheader, f->datalen + hdrlen, 0, (struct sockaddr *)&rtp->them, sizeof(rtp->them)); if (res <0) { if (!rtp->nat || (rtp->nat && (ast_test_flag(rtp, FLAG_NAT_ACTIVE) == FLAG_NAT_ACTIVE))) { - if (option_debug) - ast_log(LOG_DEBUG, "RTP Transmission error of packet %d to %s:%d: %s\n", rtp->seqno, ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno)); + ast_debug(1, "RTP Transmission error of packet %d to %s:%d: %s\n", rtp->seqno, ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno)); } else if (((ast_test_flag(rtp, FLAG_NAT_ACTIVE) == FLAG_NAT_INACTIVE) || rtpdebug) && !ast_test_flag(rtp, FLAG_NAT_INACTIVE_NOWARN)) { /* Only give this error message once if we are not RTP debugging */ if (option_debug || rtpdebug) - ast_log(LOG_DEBUG, "RTP NAT: Can't write RTP to private address %s:%d, waiting for other end to send audio...\n", ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port)); + ast_debug(0, "RTP NAT: Can't write RTP to private address %s:%d, waiting for other end to send audio...\n", ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port)); ast_set_flag(rtp, FLAG_NAT_INACTIVE_NOWARN); } } else { @@ -2835,8 +2815,7 @@ if (rtp->lasttxformat != subclass) { /* New format, reset the smoother */ - if (option_debug) - ast_log(LOG_DEBUG, "Ooh, format changed from %s to %s\n", ast_getformatname(rtp->lasttxformat), ast_getformatname(subclass)); + ast_debug(1, "Ooh, format changed from %s to %s\n", ast_getformatname(rtp->lasttxformat), ast_getformatname(subclass)); rtp->lasttxformat = subclass; if (rtp->smoother) ast_smoother_free(rtp->smoother); @@ -2852,8 +2831,7 @@ } if (fmt.flags) ast_smoother_set_flags(rtp->smoother, fmt.flags); - if (option_debug) - ast_log(LOG_DEBUG, "Created smoother: format: %d ms: %d len: %d\n", subclass, fmt.cur_ms, ((fmt.cur_ms * fmt.fr_len) / fmt.inc_ms)); + ast_debug(1, "Created smoother: format: %d ms: %d len: %d\n", subclass, fmt.cur_ms, ((fmt.cur_ms * fmt.fr_len) / fmt.inc_ms)); } } if (rtp->smoother) { @@ -2951,8 +2929,7 @@ if ((c0->tech_pvt != pvt0) || (c1->tech_pvt != pvt1) || (c0->masq || c0->masqr || c1->masq || c1->masqr)) { - if (option_debug) - ast_log(LOG_DEBUG, "Oooh, something is weird, backing out\n"); + ast_debug(1, "Oooh, something is weird, backing out\n"); if (c0->tech_pvt == pvt0) if (pr0->set_rtp_peer(c0, NULL, NULL, NULL, 0, 0)) ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", c0->name); @@ -2982,17 +2959,17 @@ (tp1 && inaddrcmp(&tt1, &tac1)) || (codec1 != oldcodec1)) { if (option_debug > 1) { - ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d (format %d)\n", + ast_debug(2, "Oooh, '%s' changed end address to %s:%d (format %d)\n", c1->name, ast_inet_ntoa(t1.sin_addr), ntohs(t1.sin_port), codec1); - ast_log(LOG_DEBUG, "Oooh, '%s' changed end vaddress to %s:%d (format %d)\n", + ast_debug(2, "Oooh, '%s' changed end vaddress to %s:%d (format %d)\n", c1->name, ast_inet_ntoa(vt1.sin_addr), ntohs(vt1.sin_port), codec1); - ast_log(LOG_DEBUG, "Oooh, '%s' changed end taddress to %s:%d (format %d)\n", + ast_debug(2, "Oooh, '%s' changed end taddress to %s:%d (format %d)\n", c1->name, ast_inet_ntoa(tt1.sin_addr), ntohs(tt1.sin_port), codec1); - ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d/(format %d)\n", + ast_debug(2, "Oooh, '%s' was %s:%d/(format %d)\n", c1->name, ast_inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port), oldcodec1); - ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d/(format %d)\n", + ast_debug(2, "Oooh, '%s' was %s:%d/(format %d)\n", c1->name, ast_inet_ntoa(vac1.sin_addr), ntohs(vac1.sin_port), oldcodec1); - ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d/(format %d)\n", + ast_debug(2, "Oooh, '%s' was %s:%d/(format %d)\n", c1->name, ast_inet_ntoa(tac1.sin_addr), ntohs(tac1.sin_port), oldcodec1); } if (pr0->set_rtp_peer(c0, t1.sin_addr.s_addr ? p1 : NULL, vt1.sin_addr.s_addr ? vp1 : NULL, tt1.sin_addr.s_addr ? tp1 : NULL, codec1, ast_test_flag(p1, FLAG_NAT_ACTIVE))) @@ -3006,9 +2983,9 @@ (vp0 && inaddrcmp(&vt0, &vac0)) || (tp0 && inaddrcmp(&tt0, &tac0))) { if (option_debug > 1) { - ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d (format %d)\n", + ast_debug(2, "Oooh, '%s' changed end address to %s:%d (format %d)\n", c0->name, ast_inet_ntoa(t0.sin_addr), ntohs(t0.sin_port), codec0); - ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d/(format %d)\n", + ast_debug(2, "Oooh, '%s' was %s:%d/(format %d)\n", c0->name, ast_inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port), oldcodec0); } if (pr1->set_rtp_peer(c1, t0.sin_addr.s_addr ? p0 : NULL, vt0.sin_addr.s_addr ? vp0 : NULL, tt0.sin_addr.s_addr ? tp0 : NULL, codec0, ast_test_flag(p0, FLAG_NAT_ACTIVE))) @@ -3028,8 +3005,7 @@ ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", c1->name); return AST_BRIDGE_RETRY; } - if (option_debug) - ast_log(LOG_DEBUG, "Ooh, empty read...\n"); + ast_debug(1, "Ooh, empty read...\n"); if (ast_check_hangup(c0) || ast_check_hangup(c1)) break; continue; @@ -3042,8 +3018,7 @@ /* Break out of bridge */ *fo = fr; *rc = who; - if (option_debug) - ast_log(LOG_DEBUG, "Oooh, got a %s\n", fr ? "digit" : "hangup"); + ast_debug(1, "Oooh, got a %s\n", fr ? "digit" : "hangup"); if (c0->tech_pvt == pvt0) if (pr0->set_rtp_peer(c0, NULL, NULL, NULL, 0, 0)) ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", c0->name); @@ -3073,8 +3048,7 @@ } else { *fo = fr; *rc = who; - if (option_debug) - ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass, who->name); + ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass, who->name); return AST_BRIDGE_COMPLETE; } } else { @@ -3131,7 +3105,7 @@ rtp->rxseqno = 0; ast_set_flag(rtp, FLAG_NAT_ACTIVE); if (option_debug || rtpdebug) - ast_log(LOG_DEBUG, "P2P RTP NAT: Got audio from other end. Now sending to address %s:%d\n", ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port)); + ast_debug(0, "P2P RTP NAT: Got audio from other end. Now sending to address %s:%d\n", ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port)); } /* Write directly out to other RTP stream if bridged */ @@ -3235,8 +3209,7 @@ if ((c0->tech_pvt != pvt0) || (c1->tech_pvt != pvt1) || (c0->masq || c0->masqr || c1->masq || c1->masqr)) { - if (option_debug > 2) - ast_log(LOG_DEBUG, "p2p-rtp-bridge: Oooh, something is weird, backing out\n"); + ast_debug(3, "p2p-rtp-bridge: Oooh, something is weird, backing out\n"); /* If a masquerade needs to happen we have to try to read in a frame so that it actually happens. Without this we risk being called again and going into a loop */ if ((c0->masq || c0->masqr) && (fr = ast_read(c0))) ast_frfree(fr); @@ -3267,8 +3240,7 @@ /* Record received frame and who */ *fo = fr; *rc = who; - if (option_debug > 2) - ast_log(LOG_DEBUG, "p2p-rtp-bridge: Ooh, got a %s\n", fr ? "digit" : "hangup"); + ast_debug(3, "p2p-rtp-bridge: Ooh, got a %s\n", fr ? "digit" : "hangup"); res = AST_BRIDGE_COMPLETE; break; } else if ((fr->frametype == AST_FRAME_CONTROL) && !(flags & AST_BRIDGE_IGNORE_SIGS)) { @@ -3297,8 +3269,7 @@ } else { *fo = fr; *rc = who; - if (option_debug > 2) - ast_log(LOG_DEBUG, "p2p-rtp-bridge: Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass, who->name); + ast_debug(3, "p2p-rtp-bridge: Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass, who->name); res = AST_BRIDGE_COMPLETE; break; } @@ -3475,8 +3446,7 @@ codec1 = pr1->get_codec ? pr1->get_codec(c1) : 0; if (codec0 && codec1 && !(codec0 & codec1)) { /* Hey, we can't do native bridging if both parties speak different codecs */ - if (option_debug > 2) - ast_log(LOG_DEBUG, "Channel codec0 = %d is not codec1 = %d, cannot native bridge in RTP.\n", codec0, codec1); + ast_debug(3, "Channel codec0 = %d is not codec1 = %d, cannot native bridge in RTP.\n", codec0, codec1); ast_channel_unlock(c0); ast_channel_unlock(c1); return AST_BRIDGE_FAILED_NOWARN; @@ -3486,8 +3456,7 @@ if (audio_p0_res == AST_RTP_TRY_PARTIAL || audio_p1_res == AST_RTP_TRY_PARTIAL) { /* In order to do Packet2Packet bridging both sides must be in the same rawread/rawwrite */ if (c0->rawreadformat != c1->rawwriteformat || c1->rawreadformat != c0->rawwriteformat) { - if (option_debug) - ast_log(LOG_DEBUG, "Cannot packet2packet bridge - raw formats are incompatible\n"); + ast_debug(1, "Cannot packet2packet bridge - raw formats are incompatible\n"); ast_channel_unlock(c0); ast_channel_unlock(c1); return AST_BRIDGE_FAILED_NOWARN; Index: main/udptl.c =================================================================== --- main/udptl.c (revision 69516) +++ main/udptl.c (working copy) @@ -697,8 +697,7 @@ if ((udptl->them.sin_addr.s_addr != sin.sin_addr.s_addr) || (udptl->them.sin_port != sin.sin_port)) { memcpy(&udptl->them, &sin, sizeof(udptl->them)); - if (option_debug) - ast_log(LOG_DEBUG, "UDPTL NAT: Using address %s:%d\n", ast_inet_ntoa(udptl->them.sin_addr), ntohs(udptl->them.sin_port)); + ast_debug(1, "UDPTL NAT: Using address %s:%d\n", ast_inet_ntoa(udptl->them.sin_addr), ntohs(udptl->them.sin_port)); } } @@ -1066,8 +1065,7 @@ if ((c0->tech_pvt != pvt0) || (c1->tech_pvt != pvt1) || (c0->masq || c0->masqr || c1->masq || c1->masqr)) { - if (option_debug) - ast_log(LOG_DEBUG, "Oooh, something is weird, backing out\n"); + ast_debug(1, "Oooh, something is weird, backing out\n"); /* Tell it to try again later */ return -3; } @@ -1076,26 +1074,25 @@ ast_udptl_get_peer(p0, &t0); if (inaddrcmp(&t1, &ac1)) { if (option_debug) { - ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d\n", + ast_debug(1, "Oooh, '%s' changed end address to %s:%d\n", c1->name, ast_inet_ntoa(t1.sin_addr), ntohs(t1.sin_port)); - ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d\n", + ast_debug(1, "Oooh, '%s' was %s:%d\n", c1->name, ast_inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port)); } memcpy(&ac1, &t1, sizeof(ac1)); } if (inaddrcmp(&t0, &ac0)) { if (option_debug) { - ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d\n", + ast_debug(1, "Oooh, '%s' changed end address to %s:%d\n", c0->name, ast_inet_ntoa(t0.sin_addr), ntohs(t0.sin_port)); - ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d\n", + ast_debug(1, "Oooh, '%s' was %s:%d\n", c0->name, ast_inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port)); } memcpy(&ac0, &t0, sizeof(ac0)); } who = ast_waitfor_n(cs, 2, &to); if (!who) { - if (option_debug) - ast_log(LOG_DEBUG, "Ooh, empty read...\n"); + ast_debug(1, "Ooh, empty read...\n"); /* check for hangup / whentohangup */ if (ast_check_hangup(c0) || ast_check_hangup(c1)) break; @@ -1105,8 +1102,7 @@ if (!f) { *fo = f; *rc = who; - if (option_debug) - ast_log(LOG_DEBUG, "Oooh, got a %s\n", f ? "digit" : "hangup"); + ast_debug(1, "Oooh, got a %s\n", f ? "digit" : "hangup"); /* That's all we needed */ return 0; } else { Index: main/say.c =================================================================== --- main/say.c (revision 69516) +++ main/say.c (working copy) @@ -508,8 +508,7 @@ num = num % 1000000; snprintf(fn, sizeof(fn), "digits/million"); } else { - if (option_debug) - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_debug(1, "Number '%d' is too big for me\n", num); res = -1; } } @@ -738,8 +737,7 @@ snprintf(fn, sizeof(fn), "digits/millions"); num = num % 1000000; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_debug(1, "Number '%d' is too big for me\n", num); res = -1; } } @@ -874,8 +872,7 @@ snprintf(fn, sizeof(fn), "digits/milliards"); } } else { - if (option_debug) - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_debug(1, "Number '%d' is too big for me\n", num); res = -1; } if (!res) { @@ -960,8 +957,7 @@ if (num && num < 100) playa++; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_debug(1, "Number '%d' is too big for me\n", num); res = -1; } @@ -1062,8 +1058,7 @@ } num = num % 1000000; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_debug(1, "Number '%d' is too big for me\n", num); res = -1; } } @@ -1159,8 +1154,7 @@ snprintf(fn, sizeof(fn), "digits/million"); num = num % 1000000; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_debug(1, "Number '%d' is too big for me\n", num); res = -1; } if (!res) { @@ -1309,8 +1303,7 @@ snprintf(fn, sizeof(fn), "digits/million"); num = num % 1000000; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_debug(1, "Number '%d' is too big for me\n", num); res = -1; } if (!res) { @@ -1388,7 +1381,7 @@ num = num % 1000000; snprintf(fn, sizeof(fn), "digits/million"); } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_debug(1, "Number '%d' is too big for me\n", num); res = -1; } } @@ -1541,8 +1534,7 @@ else snprintf(fn, sizeof(fn), "digits/millions"); } else { - if (option_debug) - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_debug(1, "Number '%d' is too big for me\n", num); res = -1; } } @@ -1618,8 +1610,7 @@ num = num % 1000000; snprintf(fn, sizeof(fn), "digits/million"); } else { - if (option_debug) - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_debug(1, "Number '%d' is too big for me\n", num); res = -1; } } @@ -1714,8 +1705,7 @@ if (num && num < 100) playa++; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_debug(1, "Number '%d' is too big for me\n", num); res = -1; } @@ -1766,8 +1756,7 @@ { char file_name[255] = "digits/"; strcat(file_name, fn); - if (option_debug) - ast_log(LOG_DEBUG, "Trying to play: %s\n", file_name); + ast_debug(1, "Trying to play: %s\n", file_name); if (!ast_streamfile(chan, file_name, language)) { if ((audiofd > -1) && (ctrlfd > -1)) ast_waitstream_full(chan, ints, audiofd, ctrlfd); @@ -2180,8 +2169,7 @@ num = num % 1000000; snprintf(fn, sizeof(fn), "digits/million"); } else { - if (option_debug) - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_debug(1, "Number '%d' is too big for me\n", num); res = -1; } } @@ -2246,8 +2234,7 @@ num = num % 1000000; snprintf(fn, sizeof(fn), "digits/million"); } else { - if (option_debug) - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_debug(1, "Number '%d' is too big for me\n", num); res = -1; } } @@ -2356,8 +2343,7 @@ } num %= 1000000; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_debug(1, "Number '%d' is too big for me\n", num); res = -1; } if (!res) { @@ -2471,8 +2457,7 @@ snprintf(fn, sizeof(fn), "digits/h-last"); num = 0; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_debug(1, "Number '%d' is too big for me\n", num); res = -1; } @@ -2625,8 +2610,7 @@ snprintf(fn, sizeof(fn), "digits/h-last%s", gender); num = 0; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_debug(1, "Number '%d' is too big for me\n", num); res = -1; } @@ -2789,8 +2773,7 @@ snprintf(fn, sizeof(fn), "digits/h-last%s", gender); num = 0; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_debug(1, "Number '%d' is too big for me\n", num); res = -1; } @@ -3127,8 +3110,7 @@ ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - if (option_debug) - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -3370,8 +3352,7 @@ ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - if (option_debug) - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -3576,8 +3557,7 @@ ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - if (option_debug) - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -3807,8 +3787,7 @@ ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - if (option_debug) - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -3990,8 +3969,7 @@ ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - if (option_debug) - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -4183,8 +4161,7 @@ ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - if (option_debug) - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -4382,8 +4359,7 @@ ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - if (option_debug) - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -4616,8 +4592,7 @@ ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - if (option_debug) - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -4823,8 +4798,7 @@ for (offset = 0 ; format[offset] != '\0' ; offset++) { int remainder; - if (option_debug) - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -5042,8 +5016,7 @@ ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - if (option_debug) - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -5341,8 +5314,7 @@ ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - if (option_debug) - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -6333,7 +6305,7 @@ int res; char fn[256] = ""; - /* ast_log(LOG_DEBUG, "\n\n Saying number female %s %d \n\n",lang, num); */ + /* ast_debug(1, "\n\n Saying number female %s %d \n\n",lang, num); */ if (num < 5) { snprintf(fn, sizeof(fn), "digits/female-%d", num); res = wait_file(chan, ints, fn, lang); @@ -6424,8 +6396,7 @@ num = num % 1000000; snprintf(fn, sizeof(fn), "digits/millions"); } else { - if (option_debug) - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_debug(1, "Number '%d' is too big for me\n", num); res = -1; } } @@ -6590,8 +6561,7 @@ ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - if (option_debug) - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + ast_debug(1, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': Index: main/io.c =================================================================== --- main/io.c (revision 69516) +++ main/io.c (working copy) @@ -37,6 +37,7 @@ #include "asterisk/io.h" #include "asterisk/logger.h" #include "asterisk/utils.h" +#include "asterisk/options.h" #ifdef DEBUG_IO #define DEBUG DEBUG_M @@ -119,7 +120,7 @@ { void *tmp; - DEBUG(ast_log(LOG_DEBUG, "io_grow()\n")); + DEBUG(ast_debug(1, "io_grow()\n")); ioc->maxfdcnt += GROW_SHRINK_SIZE; @@ -159,7 +160,7 @@ { int *ret; - DEBUG(ast_log(LOG_DEBUG, "ast_io_add()\n")); + DEBUG(ast_debug(1, "ast_io_add()\n")); if (ioc->fdcnt >= ioc->maxfdcnt) { /* @@ -275,7 +276,7 @@ { int res, x, origcnt; - DEBUG(ast_log(LOG_DEBUG, "ast_io_wait()\n")); + DEBUG(ast_debug(1, "ast_io_wait()\n")); if ((res = poll(ioc->fds, ioc->fdcnt, howlong)) <= 0) return res; @@ -312,19 +313,19 @@ */ int x; - ast_log(LOG_DEBUG, "Asterisk IO Dump: %d entries, %d max entries\n", ioc->fdcnt, ioc->maxfdcnt); - ast_log(LOG_DEBUG, "================================================\n"); - ast_log(LOG_DEBUG, "| ID FD Callback Data Events |\n"); - ast_log(LOG_DEBUG, "+------+------+-----------+-----------+--------+\n"); + ast_debug(1, "Asterisk IO Dump: %d entries, %d max entries\n", ioc->fdcnt, ioc->maxfdcnt); + ast_debug(1, "================================================\n"); + ast_debug(1, "| ID FD Callback Data Events |\n"); + ast_debug(1, "+------+------+-----------+-----------+--------+\n"); for (x = 0; x < ioc->fdcnt; x++) { - ast_log(LOG_DEBUG, "| %.4d | %.4d | %p | %p | %.6x |\n", + ast_debug(1, "| %.4d | %.4d | %p | %p | %.6x |\n", *ioc->ior[x].id, ioc->fds[x].fd, ioc->ior[x].callback, ioc->ior[x].data, ioc->fds[x].events); } - ast_log(LOG_DEBUG, "================================================\n"); + ast_debug(1, "================================================\n"); } /* Unrelated I/O functions */ Index: main/logger.c =================================================================== --- main/logger.c (revision 69516) +++ main/logger.c (working copy) @@ -965,16 +965,13 @@ if ((addresses = ast_calloc(MAX_BACKTRACE_FRAMES, sizeof(*addresses)))) { count = backtrace(addresses, MAX_BACKTRACE_FRAMES); if ((strings = backtrace_symbols(addresses, count))) { - if (option_debug) - ast_log(LOG_DEBUG, "Got %d backtrace record%c\n", count, count != 1 ? 's' : ' '); + ast_debug(1, "Got %d backtrace record%c\n", count, count != 1 ? 's' : ' '); for (i=0; i < count ; i++) { - if (option_debug) - ast_log(LOG_DEBUG, "#%d: [%08X] %s\n", i, (unsigned int)addresses[i], strings[i]); + ast_debug(1, "#%d: [%08X] %s\n", i, (unsigned int)addresses[i], strings[i]); } free(strings); } else { - if (option_debug) - ast_log(LOG_DEBUG, "Could not allocate memory for backtrace\n"); + ast_debug(1, "Could not allocate memory for backtrace\n"); } free(addresses); } Index: main/sched.c =================================================================== --- main/sched.c (revision 69516) +++ main/sched.c (working copy) @@ -149,7 +149,7 @@ { int ms; - DEBUG(ast_log(LOG_DEBUG, "ast_sched_wait()\n")); + DEBUG(ast_debug(1, "ast_sched_wait()\n")); ast_mutex_lock(&con->lock); if (AST_LIST_EMPTY(&con->schedq)) { @@ -196,13 +196,12 @@ { struct timeval now = ast_tvnow(); - /*ast_log(LOG_DEBUG, "TV -> %lu,%lu\n", tv->tv_sec, tv->tv_usec);*/ + /*ast_debug(1, "TV -> %lu,%lu\n", tv->tv_sec, tv->tv_usec);*/ if (ast_tvzero(*tv)) /* not supplied, default to now */ *tv = now; *tv = ast_tvadd(*tv, ast_samp2tv(when, 1000)); if (ast_tvcmp(*tv, now) < 0) { - if (option_debug) - ast_log(LOG_DEBUG, "Request to schedule in the past?!?!\n"); + ast_debug(1, "Request to schedule in the past?!?!\n"); *tv = now; } return 0; @@ -216,7 +215,7 @@ { struct sched *tmp; int res = -1; - DEBUG(ast_log(LOG_DEBUG, "ast_sched_add()\n")); + DEBUG(ast_debug(1, "ast_sched_add()\n")); if (!when) { ast_log(LOG_NOTICE, "Scheduled event in 0 ms?\n"); return -1; @@ -260,7 +259,7 @@ { struct sched *s; - DEBUG(ast_log(LOG_DEBUG, "ast_sched_del()\n")); + DEBUG(ast_debug(1, "ast_sched_del()\n")); ast_mutex_lock(&con->lock); AST_LIST_TRAVERSE_SAFE_BEGIN(&con->schedq, s, list) { @@ -281,8 +280,7 @@ ast_mutex_unlock(&con->lock); if (!s) { - if (option_debug) - ast_log(LOG_DEBUG, "Attempted to delete nonexistent schedule entry %d!\n", id); + ast_debug(1, "Attempted to delete nonexistent schedule entry %d!\n", id); #ifdef DO_CRASH CRASH; #endif @@ -298,28 +296,26 @@ struct sched *q; struct timeval tv = ast_tvnow(); #ifdef SCHED_MAX_CACHE - if (option_debug) - ast_log(LOG_DEBUG, "Asterisk Schedule Dump (%d in Q, %d Total, %d Cache)\n", con->schedcnt, con->eventcnt - 1, con->schedccnt); + ast_debug(1, "Asterisk Schedule Dump (%d in Q, %d Total, %d Cache)\n", con->schedcnt, con->eventcnt - 1, con->schedccnt); #else - if (option_debug) - ast_log(LOG_DEBUG, "Asterisk Schedule Dump (%d in Q, %d Total)\n", con->schedcnt, con->eventcnt - 1); + ast_debug(1, "Asterisk Schedule Dump (%d in Q, %d Total)\n", con->schedcnt, con->eventcnt - 1); #endif if (option_debug) { - ast_log(LOG_DEBUG, "=============================================================\n"); - ast_log(LOG_DEBUG, "|ID Callback Data Time (sec:ms) |\n"); - ast_log(LOG_DEBUG, "+-----+-----------------+-----------------+-----------------+\n"); + ast_debug(1, "=============================================================\n"); + ast_debug(1, "|ID Callback Data Time (sec:ms) |\n"); + ast_debug(1, "+-----+-----------------+-----------------+-----------------+\n"); AST_LIST_TRAVERSE(&con->schedq, q, list) { struct timeval delta = ast_tvsub(q->when, tv); - ast_log(LOG_DEBUG, "|%.4d | %-15p | %-15p | %.6ld : %.6ld |\n", + ast_debug(1, "|%.4d | %-15p | %-15p | %.6ld : %.6ld |\n", q->id, q->callback, q->data, delta.tv_sec, (long int)delta.tv_usec); } - ast_log(LOG_DEBUG, "=============================================================\n"); + ast_debug(1, "=============================================================\n"); } } @@ -333,7 +329,7 @@ int numevents; int res; - DEBUG(ast_log(LOG_DEBUG, "ast_sched_runq()\n")); + DEBUG(ast_debug(1, "ast_sched_runq()\n")); ast_mutex_lock(&con->lock); @@ -387,7 +383,7 @@ { struct sched *s; long secs = -1; - DEBUG(ast_log(LOG_DEBUG, "ast_sched_when()\n")); + DEBUG(ast_debug(1, "ast_sched_when()\n")); ast_mutex_lock(&con->lock); AST_LIST_TRAVERSE(&con->schedq, s, list) {