[Asterisk-cvs] asterisk asterisk.c, 1.141, 1.142 cli.c, 1.74,
1.75 logger.c, 1.55, 1.56
markster at lists.digium.com
markster at lists.digium.com
Fri Mar 4 22:07:51 CST 2005
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv23366
Modified Files:
asterisk.c cli.c logger.c
Log Message:
Allow debug to be enabled on a per-file basis...
Index: asterisk.c
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.c,v
retrieving revision 1.141
retrieving revision 1.142
diff -u -d -r1.141 -r1.142
--- asterisk.c 11 Feb 2005 21:16:34 -0000 1.141
+++ asterisk.c 5 Mar 2005 04:04:55 -0000 1.142
@@ -85,6 +85,7 @@
int option_reconnect = 0;
int fully_booted = 0;
char record_cache_dir[AST_CACHE_DIR_LEN] = AST_TMP_DIR;
+char debug_filename[AST_FILENAME_MAX] = "";
static int ast_socket = -1; /* UNIX Socket for allowing remote control */
static int ast_consock = -1; /* UNIX Socket for controlling another asterisk */
Index: cli.c
===================================================================
RCS file: /usr/cvsroot/asterisk/cli.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- cli.c 4 Mar 2005 06:47:23 -0000 1.74
+++ cli.c 5 Mar 2005 04:04:55 -0000 1.75
@@ -441,6 +441,11 @@
"Usage: debug channel <channel>\n"
" Enables debugging on a specific channel.\n";
+static char debuglevel_help[] =
+"Usage: debug level <level> [filename]\n"
+" Set debug to specified level (0 to disable). If filename\n"
+"is specified, debugging will be limited to just that file.\n";
+
static char nodebugchan_help[] =
"Usage: no debug channel <channel>\n"
" Disables debugging on a specific channel.\n";
@@ -571,6 +576,25 @@
return RESULT_SUCCESS;
}
+static int handle_debuglevel(int fd, int argc, char *argv[])
+{
+ int newlevel;
+ char *filename = "<any>";
+ if ((argc < 3) || (argc > 4))
+ return RESULT_SHOWUSAGE;
+ if (sscanf(argv[2], "%i", &newlevel) != 1)
+ return RESULT_SHOWUSAGE;
+ option_debug = newlevel;
+ if (argc == 4) {
+ filename = argv[3];
+ strncpy(debug_filename, filename, sizeof(debug_filename) - 1);
+ } else {
+ debug_filename[0] = '\0';
+ }
+ ast_cli(fd, "Debugging level set to %d, file '%s'\n", newlevel, filename);
+ return RESULT_SUCCESS;
+}
+
static int handle_debugchan(int fd, int argc, char *argv[])
{
struct ast_channel *c=NULL;
@@ -792,6 +816,7 @@
{ { "_command", "nummatches", NULL }, handle_commandnummatches, "Returns number of command matches", commandnummatches_help },
{ { "_command", "matchesarray", NULL }, handle_commandmatchesarray, "Returns command matches array", commandmatchesarray_help },
{ { "debug", "channel", NULL }, handle_debugchan, "Enable debugging on a channel", debugchan_help, complete_ch_3 },
+ { { "debug", "level", NULL }, handle_debuglevel, "Set global debug level", debuglevel_help },
{ { "help", NULL }, handle_help, "Display help list, or specific help on a command", help_help },
{ { "load", NULL }, handle_load, "Load a dynamic module by name", load_help, complete_fn },
{ { "no", "debug", "channel", NULL }, handle_nodebugchan, "Disable debugging on a channel", nodebugchan_help, complete_ch_4 },
Index: logger.c
===================================================================
RCS file: /usr/cvsroot/asterisk/logger.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- logger.c 25 Jan 2005 06:10:19 -0000 1.55
+++ logger.c 5 Mar 2005 04:04:55 -0000 1.56
@@ -564,6 +564,10 @@
/* Ignore anything that never gets logged anywhere */
if (!(global_logmask & (1 << level)))
return;
+
+ /* Ignore anything other than the currently debugged file if there is one */
+ if ((level == __LOG_DEBUG) && !ast_strlen_zero(debug_filename) && strcasecmp(debug_filename, file))
+ return;
/* begin critical section */
ast_mutex_lock(&loglock);
More information about the svn-commits
mailing list