oRTP 0.25.0

- Main Page
- Data Structures
- Files

- File List
- Globals

logging.h
Go to the documentation of this file.
1 /*
2 The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) stack.
3 Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
26 #ifndef ORTP_LOGGING_H
27 #define ORTP_LOGGING_H
28
29 #include <ortp/port.h>
30
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #endif
35
36 typedef enum {
37 ORTP_DEBUG=1,
38 ORTP_MESSAGE=1<<1,
39 ORTP_WARNING=1<<2,
40 ORTP_ERROR=1<<3,
41 ORTP_FATAL=1<<4,
42 ORTP_TRACE=1<<5,
43 ORTP_LOGLEV_END=1<<6
44 } OrtpLogLevel;
45
46
47 typedef void (*OrtpLogFunc)(OrtpLogLevel lev, const char *fmt, va_list args);
48
49 ORTP_PUBLIC void ortp_set_log_file(FILE *file);
50 ORTP_PUBLIC void ortp_set_log_handler(OrtpLogFunc func);
51 ORTP_PUBLIC OrtpLogFunc ortp_get_log_handler();
52
53 ORTP_VAR_PUBLIC OrtpLogFunc ortp_logv_out;
54
55 #define ortp_log_level_enabled(level) (ortp_get_log_level_mask() & (level))
56
57 ORTP_PUBLIC void ortp_logv(int level, const char *fmt, va_list args);
58
63 ORTP_PUBLIC void ortp_logv_flush(void);
64
65 ORTP_PUBLIC void ortp_set_log_level_mask(int levelmask);
66 ORTP_PUBLIC int ortp_get_log_level_mask(void);
67
73 ORTP_PUBLIC void ortp_set_log_thread_id(unsigned long thread_id);
74
75 #ifdef __GNUC__
76 #define CHECK_FORMAT_ARGS(m,n) __attribute__((format(printf,m,n)))
77 #else
78 #define CHECK_FORMAT_ARGS(m,n)
79 #endif
80 #ifdef __clang__
81 /*in case of compile with -g static inline can produce this type of warning*/
82 #pragma GCC diagnostic ignored "-Wunused-function"
83 #endif
84 #ifdef ORTP_DEBUG_MODE
85 static ORTP_INLINE void CHECK_FORMAT_ARGS(1,2) ortp_debug(const char *fmt,...)
86 {
87 va_list args;
88 va_start (args, fmt);
89 ortp_logv(ORTP_DEBUG, fmt, args);
90 va_end (args);
91 }
92 #else
93
94 #define ortp_debug(...)
95
96 #endif
97
98 #ifdef ORTP_NOMESSAGE_MODE
99
100 #define ortp_log(...)
101 #define ortp_message(...)
102 #define ortp_warning(...)
103
104 #else
105
106 static ORTP_INLINE void CHECK_FORMAT_ARGS(2,3) ortp_log(OrtpLogLevel lev, const char *fmt,...) {
107 va_list args;
108 va_start (args, fmt);
109 ortp_logv(lev, fmt, args);
110 va_end (args);
111 }
112
113 static ORTP_INLINE void CHECK_FORMAT_ARGS(1,2) ortp_message(const char *fmt,...)
114 {
115 va_list args;
116 va_start (args, fmt);
117 ortp_logv(ORTP_MESSAGE, fmt, args);
118 va_end (args);
119 }
120
121 static ORTP_INLINE void CHECK_FORMAT_ARGS(1,2) ortp_warning(const char *fmt,...)
122 {
123 va_list args;
124 va_start (args, fmt);
125 ortp_logv(ORTP_WARNING, fmt, args);
126 va_end (args);
127 }
128
129 #endif
130
131 static ORTP_INLINE void CHECK_FORMAT_ARGS(1,2) ortp_error(const char *fmt,...)
132 {
133 va_list args;
134 va_start (args, fmt);
135 ortp_logv(ORTP_ERROR, fmt, args);
136 va_end (args);
137 }
138
139 static ORTP_INLINE void CHECK_FORMAT_ARGS(1,2) ortp_fatal(const char *fmt,...)
140 {
141 va_list args;
142 va_start (args, fmt);
143 ortp_logv(ORTP_FATAL, fmt, args);
144 va_end (args);
145 }
146
147
148 #ifdef __QNX__
149 void ortp_qnx_log_handler(const char *domain, OrtpLogLevel lev, const char *fmt, va_list args);
150 #endif
151
152
153 #ifdef __cplusplus
154 }
155 #endif
156
157 #endif
ortp_logv_flush
ORTP_PUBLIC void ortp_logv_flush(void)
Definition: logging.c:200
ortp_set_log_file
ORTP_PUBLIC void ortp_set_log_file(FILE *file)
Definition: logging.c:37
ortp_set_log_thread_id
ORTP_PUBLIC void ortp_set_log_thread_id(unsigned long thread_id)
Definition: logging.c:72
ortp_set_log_handler
ORTP_PUBLIC void ortp_set_log_handler(OrtpLogFunc func)
Definition: logging.c:50
ortp_set_log_level_mask
ORTP_PUBLIC void ortp_set_log_level_mask(int levelmask)
Definition: logging.c:64