26 #ifndef ORTP_LOGGING_H
27 #define ORTP_LOGGING_H
29 #include <ortp/port.h>
47 typedef void (*OrtpLogFunc)(OrtpLogLevel lev,
const char *fmt, va_list args);
49 ORTP_PUBLIC
void ortp_set_log_file(FILE *file);
50 ORTP_PUBLIC
void ortp_set_log_handler(OrtpLogFunc func);
52 ORTP_VAR_PUBLIC OrtpLogFunc ortp_logv_out;
54 ORTP_PUBLIC
extern unsigned int __ortp_log_mask;
56 #define ortp_log_level_enabled(level) (__ortp_log_mask & (level))
58 #if !defined(WIN32) && !defined(_WIN32_WCE)
59 #define ortp_logv(level,fmt,args) \
61 if (ortp_logv_out!=NULL && ortp_log_level_enabled(level)) \
62 ortp_logv_out(level,fmt,args);\
63 if ((level)==ORTP_FATAL) abort();\
66 ORTP_PUBLIC
void ortp_logv(
int level,
const char *fmt, va_list args);
69 ORTP_PUBLIC
void ortp_set_log_level_mask(
int levelmask);
72 #define CHECK_FORMAT_ARGS(m,n) __attribute__((format(printf,m,n)))
74 #define CHECK_FORMAT_ARGS(m,n)
78 #ifdef ORTP_DEBUG_MODE
79 static inline void CHECK_FORMAT_ARGS(1,2) ortp_debug(const
char *fmt,...)
83 ortp_logv(ORTP_DEBUG, fmt, args);
88 #define ortp_debug(...)
92 #ifdef ORTP_NOMESSAGE_MODE
95 #define ortp_message(...)
96 #define ortp_warning(...)
100 static inline void CHECK_FORMAT_ARGS(2,3) ortp_log(OrtpLogLevel lev, const
char *fmt,...) {
102 va_start (args, fmt);
103 ortp_logv(lev, fmt, args);
107 static inline void CHECK_FORMAT_ARGS(1,2) ortp_message(const
char *fmt,...)
110 va_start (args, fmt);
111 ortp_logv(ORTP_MESSAGE, fmt, args);
115 static inline void CHECK_FORMAT_ARGS(1,2) ortp_warning(const
char *fmt,...)
118 va_start (args, fmt);
119 ortp_logv(ORTP_WARNING, fmt, args);
125 static inline void CHECK_FORMAT_ARGS(1,2) ortp_error(const
char *fmt,...)
128 va_start (args, fmt);
129 ortp_logv(ORTP_ERROR, fmt, args);
133 static inline void CHECK_FORMAT_ARGS(1,2) ortp_fatal(const
char *fmt,...)
136 va_start (args, fmt);
137 ortp_logv(ORTP_FATAL, fmt, args);