ftmod_libpri: Improve libpri message logging.
Use the PRI_NEW_SET_API define provided by >=libpri-1.2 to distinguish between old style and new style pri_set_error() and pri_set_message() callback functions. Improve message logging by using ftdm_log_chan() if per-span data with a valid (d-)channel object is available. NOTE: pri_get_userdata() returns NULL if pri is NULL. This will reduce the horizontal space for libpri output a bit, but allows us to see which span the message/error came from. Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
This commit is contained in:
parent
9c288870e2
commit
020724e103
|
@ -114,42 +114,60 @@ static FIO_CHANNEL_REQUEST_FUNCTION(isdn_channel_request)
|
||||||
return FTDM_FAIL;
|
return FTDM_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
/**
|
|
||||||
* \brief Logs a libpri error
|
|
||||||
* \param s Error string
|
|
||||||
*/
|
|
||||||
static void s_pri_error(char *s)
|
|
||||||
#else
|
|
||||||
/**
|
|
||||||
* \brief Logs a libpri error
|
|
||||||
* \param pri libpri structure (unused)
|
|
||||||
* \param s Error string
|
|
||||||
*/
|
|
||||||
static void s_pri_error(struct pri *pri, char *s)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
ftdm_log(FTDM_LOG_ERROR, "%s", s);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef PRI_NEW_SET_API
|
||||||
/**
|
/**
|
||||||
* \brief Logs a libpri message
|
* \brief Logs a libpri message
|
||||||
* \param s Message string
|
* \param pri libpri structure
|
||||||
*/
|
* \param s Message string
|
||||||
static void s_pri_message(char *s)
|
|
||||||
#else
|
|
||||||
/**
|
|
||||||
* \brief Logs a libpri message
|
|
||||||
* \param pri libpri structure (unused)
|
|
||||||
* \param s Message string
|
|
||||||
*/
|
*/
|
||||||
static void s_pri_message(struct pri *pri, char *s)
|
static void s_pri_message(struct pri *pri, char *s)
|
||||||
#endif
|
{
|
||||||
|
struct lpwrap_pri *spri = pri_get_userdata(pri);
|
||||||
|
|
||||||
|
if (spri && spri->dchan) {
|
||||||
|
ftdm_log_chan(spri->dchan, FTDM_LOG_DEBUG, "%s", s);
|
||||||
|
} else {
|
||||||
|
ftdm_log(FTDM_LOG_DEBUG, "%s", s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Logs a libpri error
|
||||||
|
* \param pri libpri structure
|
||||||
|
* \param s Error string
|
||||||
|
*/
|
||||||
|
static void s_pri_error(struct pri *pri, char *s)
|
||||||
|
{
|
||||||
|
struct lpwrap_pri *spri = pri_get_userdata(pri);
|
||||||
|
|
||||||
|
if (spri && spri->dchan) {
|
||||||
|
ftdm_log_chan(spri->dchan, FTDM_LOG_ERROR, "%s", s);
|
||||||
|
} else {
|
||||||
|
ftdm_log(FTDM_LOG_ERROR, "%s", s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else /* !PRI_NEW_SET_API */
|
||||||
|
/**
|
||||||
|
* \brief Logs a libpri message
|
||||||
|
* \param s Message string
|
||||||
|
*/
|
||||||
|
static void s_pri_message(char *s)
|
||||||
{
|
{
|
||||||
ftdm_log(FTDM_LOG_DEBUG, "%s", s);
|
ftdm_log(FTDM_LOG_DEBUG, "%s", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Logs a libpri error
|
||||||
|
* \param s Error string
|
||||||
|
*/
|
||||||
|
static void s_pri_error(char *s)
|
||||||
|
{
|
||||||
|
ftdm_log(FTDM_LOG_ERROR, "%s", s);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define PRI_DEBUG_Q921_ALL (PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_STATE)
|
#define PRI_DEBUG_Q921_ALL (PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_STATE)
|
||||||
#define PRI_DEBUG_Q931_ALL (PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q931_ANOMALY)
|
#define PRI_DEBUG_Q931_ALL (PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q931_ANOMALY)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue