[asterisk-dev] manager events to show file and line info ?
Johansson Olle E
olle at voop.com
Thu Oct 26 13:30:27 MST 2006
26 okt 2006 kl. 21.58 skrev Luigi Rizzo:
> in trying to debug why certain manager events don't
> carry the correct callerid number (which may well be my fault),
> i thought it was useful to have the events themselves include
> the place where they were generated.
>
> How about committing this patch ? It is really simple...
>
In SIP, I add certain non-harmful but informational headers
if SIP debug is turned on... You could add this if
manager debug is on (which does not exist, but may be needed)
or if option_debug is over 3 (pretty advanced)...
No one is supposed to run a production server with option_debug on that
level unless they're debugging...
/Olle
> cheers
> luigi
>
> Index: include/asterisk/manager.h
> ===================================================================
> --- include/asterisk/manager.h (revision 46307)
> +++ include/asterisk/manager.h (working copy)
> @@ -111,9 +111,15 @@
> \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);
>
> Index: main/manager.c
> ===================================================================
> --- main/manager.c (revision 46319)
> +++ main/manager.c (working copy)
> @@ -2136,7 +2136,8 @@
> }
>
> /*! \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];
> @@ -2166,6 +2167,8 @@
> 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);
> _______________________________________________
> --Bandwidth and Colocation provided by Easynews.com --
>
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-dev
---
Olle E. Johansson * Asterisk Evangelist, developer * VOOP A/S
olle at voop.com
More information about the asterisk-dev
mailing list