add a new cli/manager.conf option "debug" to enable/disable
debugging code in the manager. At the moment the debugging code is very lightweight, if the option is enabled manager messages also carry a sequence number and the info where they have been generated e.g. SequenceNumber: 10 File: chan_sip.c Line: 11927 Func: handle_response_register It is not worthwhile having this as a compile time option right now, because the extra work involved at runtime is just checking one variable. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@47132 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
parent
4a545a7662
commit
0bf4235ff1
|
@ -111,8 +111,14 @@ int ast_manager_unregister( char *action );
|
|||
\param event Event name
|
||||
\param contents Contents of event
|
||||
*/
|
||||
int manager_event(int category, const char *event, const char *contents, ...)
|
||||
__attribute__ ((format (printf, 3,4)));
|
||||
/* XXX the parser in gcc 2.95 gets confused if you don't put a space
|
||||
* between the last arg before VA_ARGS and the comma */
|
||||
#define manager_event(category, event, contents , ...) \
|
||||
__manager_event(category, event, __FILE__, __LINE__, __PRETTY_FUNCTION__, contents , ## __VA_ARGS__)
|
||||
|
||||
int __manager_event(int category, const char *event,
|
||||
const char *file, int line, const char *func, const char *contents, ...)
|
||||
__attribute__ ((format (printf, 6,7)));
|
||||
|
||||
/*! Get header from mananger transaction */
|
||||
char *astman_get_header(struct message *m, char *var);
|
||||
|
|
|
@ -110,13 +110,14 @@ static int portno = DEFAULT_MANAGER_PORT;
|
|||
static int asock = -1; /* the accept socket */
|
||||
static int displayconnects = 1;
|
||||
static int timestampevents = 0;
|
||||
static int numberevents = 1;
|
||||
static int httptimeout = 60;
|
||||
|
||||
static pthread_t accept_thread_ptr; /*!< the accept thread */
|
||||
static int block_sockets = 0;
|
||||
static int num_sessions = 0;
|
||||
|
||||
static int manager_debug; /*!< enable some debugging code in the manager */
|
||||
|
||||
AST_THREADSTORAGE(manager_event_buf);
|
||||
#define MANAGER_EVENT_BUF_INITSIZE 256
|
||||
|
||||
|
@ -425,6 +426,21 @@ static int handle_showmancmd(int fd, int argc, char *argv[])
|
|||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static int handle_mandebug(int fd, int argc, char *argv[])
|
||||
{
|
||||
if (argc == 2)
|
||||
ast_cli(fd, "manager debug is %s\n", manager_debug? "on" : "off");
|
||||
else if (argc == 3) {
|
||||
if (!strcasecmp(argv[2], "on"))
|
||||
manager_debug = 1;
|
||||
else if (!strcasecmp(argv[2], "off"))
|
||||
manager_debug = 0;
|
||||
else
|
||||
return RESULT_SHOWUSAGE;
|
||||
}
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static int handle_showmanager(int fd, int argc, char *argv[])
|
||||
{
|
||||
struct ast_manager_user *user = NULL;
|
||||
|
@ -598,6 +614,10 @@ static struct ast_cli_entry cli_manager[] = {
|
|||
{ { "manager", "show", "user", NULL },
|
||||
handle_showmanager, "Display information on a specific manager user",
|
||||
showmanager_help, NULL, NULL },
|
||||
|
||||
{ { "manager", "debug", NULL },
|
||||
handle_mandebug, "Show, enable, disable debugging of the manager code",
|
||||
"Usage: manager debug [on|off]\n Show, enable, disable debugging of the manager code.\n", NULL, NULL },
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -2189,7 +2209,8 @@ static int append_event(const char *str, int category)
|
|||
}
|
||||
|
||||
/*! \brief manager_event: Send AMI event to client */
|
||||
int manager_event(int category, const char *event, const char *fmt, ...)
|
||||
int __manager_event(int category, const char *event,
|
||||
const char *file, int line, const char *func, const char *fmt, ...)
|
||||
{
|
||||
struct mansession *s;
|
||||
char auth[80];
|
||||
|
@ -2214,11 +2235,13 @@ int manager_event(int category, const char *event, const char *fmt, ...)
|
|||
"Timestamp: %ld.%06lu\r\n",
|
||||
now.tv_sec, (unsigned long) now.tv_usec);
|
||||
}
|
||||
if (numberevents) {
|
||||
if (manager_debug) {
|
||||
static int seq;
|
||||
ast_dynamic_str_thread_append(&buf, 0, &manager_event_buf,
|
||||
"SequenceNumber: %d\r\n",
|
||||
ast_atomic_fetchadd_int(&seq, 1));
|
||||
ast_dynamic_str_thread_append(&buf, 0, &manager_event_buf,
|
||||
"File: %s\r\nLine: %d\r\nFunc: %s\r\n", file, line, func);
|
||||
}
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
@ -2844,8 +2867,8 @@ int init_manager(void)
|
|||
if ((val = ast_variable_retrieve(cfg, "general", "timestampevents")))
|
||||
timestampevents = ast_true(val);
|
||||
|
||||
if ((val = ast_variable_retrieve(cfg, "general", "numberevents")))
|
||||
numberevents = ast_true(val);
|
||||
if ((val = ast_variable_retrieve(cfg, "general", "debug")))
|
||||
manager_debug = ast_true(val);
|
||||
|
||||
if ((val = ast_variable_retrieve(cfg, "general", "httptimeout")))
|
||||
newhttptimeout = atoi(val);
|
||||
|
|
Loading…
Reference in New Issue