Commit 0c8d9dda authored by Simon Morlat's avatar Simon Morlat

break logging API in order to add a log domain argument

parent d51e5aa8
......@@ -14,7 +14,7 @@ ORTP_MINOR_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f2)
ORTP_MICRO_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f3)
ORTP_EXTRA_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f4)
LIBORTP_SO_CURRENT=10 dnl increment this number when you add/change/remove an interface
LIBORTP_SO_CURRENT=11 dnl increment this number when you add/change/remove an interface
LIBORTP_SO_REVISION=0 dnl increment this number when you change source code, without changing interfaces; set to 0 when incrementing CURRENT
LIBORTP_SO_AGE=0 dnl increment this number when you add an interface, set to 0 if you remove an interface
......
......@@ -28,6 +28,10 @@
#include <ortp/port.h>
#ifndef ORTP_LOG_DOMAIN
#define ORTP_LOG_DOMAIN NULL
#endif
#ifdef __cplusplus
extern "C"
{
......@@ -44,17 +48,17 @@ typedef enum {
} OrtpLogLevel;
typedef void (*OrtpLogFunc)(OrtpLogLevel lev, const char *fmt, va_list args);
typedef void (*OrtpLogFunc)(const char *domain, OrtpLogLevel lev, const char *fmt, va_list args);
ORTP_PUBLIC void ortp_set_log_file(FILE *file);
ORTP_PUBLIC void ortp_set_log_handler(OrtpLogFunc func);
ORTP_PUBLIC OrtpLogFunc ortp_get_log_handler(void);
ORTP_VAR_PUBLIC OrtpLogFunc ortp_logv_out;
ORTP_PUBLIC void ortp_logv_out(const char *domain, OrtpLogLevel level, const char *fmt, va_list args);
#define ortp_log_level_enabled(level) (ortp_get_log_level_mask() & (level))
#define ortp_log_level_enabled(domain, level) (ortp_get_log_level_mask(domain) & (level))
ORTP_PUBLIC void ortp_logv(int level, const char *fmt, va_list args);
ORTP_PUBLIC void ortp_logv(const char *domain, OrtpLogLevel level, const char *fmt, va_list args);
/**
* Flushes the log output queue.
......@@ -62,8 +66,8 @@ ORTP_PUBLIC void ortp_logv(int level, const char *fmt, va_list args);
*/
ORTP_PUBLIC void ortp_logv_flush(void);
ORTP_PUBLIC void ortp_set_log_level_mask(int levelmask);
ORTP_PUBLIC int ortp_get_log_level_mask(void);
ORTP_PUBLIC void ortp_set_log_level_mask(const char *domain, int levelmask);
ORTP_PUBLIC unsigned int ortp_get_log_level_mask(const char *domain);
/**
* Tell oRTP the id of the thread used to output the logs.
......@@ -86,7 +90,7 @@ static ORTP_INLINE void CHECK_FORMAT_ARGS(1,2) ortp_debug(const char *fmt,...)
{
va_list args;
va_start (args, fmt);
ortp_logv(ORTP_DEBUG, fmt, args);
ortp_logv(ORTP_LOG_DOMAIN, ORTP_DEBUG, fmt, args);
va_end (args);
}
#else
......@@ -106,7 +110,7 @@ static ORTP_INLINE void CHECK_FORMAT_ARGS(1,2) ortp_debug(const char *fmt,...)
static ORTP_INLINE void CHECK_FORMAT_ARGS(2,3) ortp_log(OrtpLogLevel lev, const char *fmt,...) {
va_list args;
va_start (args, fmt);
ortp_logv(lev, fmt, args);
ortp_logv(ORTP_LOG_DOMAIN, lev, fmt, args);
va_end (args);
}
......@@ -114,7 +118,7 @@ static ORTP_INLINE void CHECK_FORMAT_ARGS(1,2) ortp_message(const char *fmt,...)
{
va_list args;
va_start (args, fmt);
ortp_logv(ORTP_MESSAGE, fmt, args);
ortp_logv(ORTP_LOG_DOMAIN, ORTP_MESSAGE, fmt, args);
va_end (args);
}
......@@ -122,7 +126,7 @@ static ORTP_INLINE void CHECK_FORMAT_ARGS(1,2) ortp_warning(const char *fmt,...)
{
va_list args;
va_start (args, fmt);
ortp_logv(ORTP_WARNING, fmt, args);
ortp_logv(ORTP_LOG_DOMAIN, ORTP_WARNING, fmt, args);
va_end (args);
}
......@@ -132,7 +136,7 @@ static ORTP_INLINE void CHECK_FORMAT_ARGS(1,2) ortp_error(const char *fmt,...)
{
va_list args;
va_start (args, fmt);
ortp_logv(ORTP_ERROR, fmt, args);
ortp_logv(ORTP_LOG_DOMAIN, ORTP_ERROR, fmt, args);
va_end (args);
}
......@@ -140,7 +144,7 @@ static ORTP_INLINE void CHECK_FORMAT_ARGS(1,2) ortp_fatal(const char *fmt,...)
{
va_list args;
va_start (args, fmt);
ortp_logv(ORTP_FATAL, fmt, args);
ortp_logv(ORTP_LOG_DOMAIN, ORTP_FATAL, fmt, args);
va_end (args);
}
......
This diff is collapsed.
......@@ -22,6 +22,7 @@
#include "ortp-config.h"
#endif
#include "ortp/ortp.h"
#include "utils.h"
#include <inttypes.h>
#include "scheduler.h"
......@@ -76,7 +77,7 @@ void ortp_init()
#ifdef _WIN32
win32_init_sockets();
#endif
ortp_init_logger();
av_profile_init(&av_profile);
ortp_global_stats_reset();
init_random_number_generator();
......@@ -127,6 +128,7 @@ void ortp_exit()
rtp_scheduler_destroy(__ortp_scheduler);
__ortp_scheduler=NULL;
}
ortp_uninit_logger();
}
}
......
......@@ -33,6 +33,15 @@ OList *o_list_new(void *data){
return new_elem;
}
OList * o_list_prepend(OList *elem, void * data){
OList *new_elem=o_list_new(data);
if (elem){
elem->prev = new_elem;
new_elem->next = elem;
}
return new_elem;
}
OList * o_list_append(OList *elem, void * data){
OList *new_elem=o_list_new(data);
OList *it=elem;
......@@ -56,6 +65,21 @@ OList * o_list_free(OList *list){
return NULL;
}
OList * o_list_free_with_data(OList *list, void (*freefunc)(void*)){
OList *elem = list;
OList *tmp;
if (!list) return NULL;
while(elem->next!=NULL) {
tmp = elem;
elem = elem->next;
freefunc(tmp->data);
ortp_free(tmp);
}
freefunc(elem->data);
ortp_free(elem);
return NULL;
}
OList *o_list_remove_link(OList *list, OList *elem){
OList *ret;
if (elem==list){
......
......@@ -30,6 +30,9 @@
#include "ortp/event.h"
#include "ortp/rtpsession.h"
void ortp_init_logger(void);
void ortp_uninit_logger(void);
struct _OList {
struct _OList *next;
struct _OList *prev;
......@@ -41,9 +44,11 @@ struct _OList {
#define o_list_prev(elem) ((elem)->prev)
OList * o_list_append(OList *elem, void * data);
OList * o_list_prepend(OList *elem, void * data);
OList * o_list_remove(OList *list, void *data);
OList * o_list_free(OList *elem);
OList *o_list_remove_link(OList *list, OList *elem);
OList * o_list_free_with_data(OList *list, void (*freefunc)(void*));
#define ORTP_POINTER_TO_INT(p) ((int)(intptr_t)(p))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment