Webcom C SDK
webcom-log.h
Go to the documentation of this file.
1 /*
2  * webcom-sdk-c
3  *
4  * Copyright 2017 Orange
5  * <camille.oudot@orange.com>
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or (at your
10  * option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  */
22 
23 #ifndef INCLUDE_WEBCOM_C_WEBCOM_LOG_H_
24 #define INCLUDE_WEBCOM_C_WEBCOM_LOG_H_
25 
26 #include "webcom-config.h"
27 
46 
48 };
49 
68 };
69 
70 typedef void(*wc_log_f)(const char *f, const char *l, const char *file, const char *func, int line, const char *message);
71 
95 void wc_set_log_level(enum wc_log_facility f, enum wc_log_level l);
96 
97 #ifdef WITH_SYSLOG
98 #include <syslog.h> /* for options flags */
99 
119 void wc_log_use_syslog(const char *ident, int option, int facility);
120 #endif
121 
122 #ifdef WITH_JOURNALD
123 
138 void wc_log_use_journald(void);
139 #endif
140 
144 void wc_log_use_stderr(void);
145 
146 
153 
154 
155 
172 void wc_log(enum wc_log_facility f, enum wc_log_level l, const char *file, const char *func, int line, const char *fmt, ...)
173  __attribute__ ((format (printf, 6, 7)));
174 
204 #define W_LOG(_facility, _level, _fmt, ...) \
205  wc_log((_facility), (_level), \
206  __FILE__, __func__, __LINE__, \
207  _fmt"\n", ## __VA_ARGS__)
208 
209 #define W_EXDBG(_facility, _fmt, ...) W_LOG((_facility), WC_LOG_EXTRADEBUG, _fmt, ## __VA_ARGS__)
210 #define W_DBG( _facility, _fmt, ...) W_LOG((_facility), WC_LOG_DEBUG, _fmt, ## __VA_ARGS__)
211 #define W_INFO( _facility, _fmt, ...) W_LOG((_facility), WC_LOG_INFO, _fmt, ## __VA_ARGS__)
212 #define W_NOT( _facility, _fmt, ...) W_LOG((_facility), WC_LOG_NOTICE, _fmt, ## __VA_ARGS__)
213 #define W_WARN( _facility, _fmt, ...) W_LOG((_facility), WC_LOG_INFO, _fmt, ## __VA_ARGS__)
214 #define W_ERR( _facility, _fmt, ...) W_LOG((_facility), WC_LOG_ERR, _fmt, ## __VA_ARGS__)
215 #define W_CRIT( _facility, _fmt, ...) W_LOG((_facility), WC_LOG_CRIT, _fmt, ## __VA_ARGS__)
216 #define W_ALRT( _facility, _fmt, ...) W_LOG((_facility), WC_LOG_ALERT, _fmt, ## __VA_ARGS__)
217 #define W_EMRG( _facility, _fmt, ...) W_LOG((_facility), WC_LOG_EMERG, _fmt, ## __VA_ARGS__)
218 
219 
220 #ifndef LOCAL_LOG_FACILITY
221 # define LOCAL_LOG_FACILITY WC_LOG_GENERAL
222 #endif
223 
266 #define WL_LOG(_level, _fmt, ...) W_LOG(LOCAL_LOG_FACILITY, (_level), _fmt, ## __VA_ARGS__)
267 
268 #define WL_EXDBG(_fmt, ...) WL_LOG(WC_LOG_EXTRADEBUG, _fmt, ## __VA_ARGS__)
269 #define WL_DBG( _fmt, ...) WL_LOG(WC_LOG_DEBUG, _fmt, ## __VA_ARGS__)
270 #define WL_INFO( _fmt, ...) WL_LOG(WC_LOG_INFO, _fmt, ## __VA_ARGS__)
271 #define WL_NOT( _fmt, ...) WL_LOG(WC_LOG_NOTICE, _fmt, ## __VA_ARGS__)
272 #define WL_WARN( _fmt, ...) WL_LOG(WC_LOG_INFO, _fmt, ## __VA_ARGS__)
273 #define WL_ERR( _fmt, ...) WL_LOG(WC_LOG_ERR, _fmt, ## __VA_ARGS__)
274 #define WL_CRIT( _fmt, ...) WL_LOG(WC_LOG_CRIT, _fmt, ## __VA_ARGS__)
275 #define WL_ALRT( _fmt, ...) WL_LOG(WC_LOG_ALERT, _fmt, ## __VA_ARGS__)
276 #define WL_EMRG( _fmt, ...) WL_LOG(WC_LOG_EMERG, _fmt, ## __VA_ARGS__)
277 
302 #define APP_LOG(_level, _fmt, ...) W_LOG(WC_LOG_APPLICATION, (_level), _fmt, ## __VA_ARGS__)
303 
304 #define APP_EXDBG(_fmt, ...) APP_LOG(WC_LOG_EXTRADEBUG, _fmt, ## __VA_ARGS__)
305 #define APP_DBG( _fmt, ...) APP_LOG(WC_LOG_DEBUG, _fmt, ## __VA_ARGS__)
306 #define APP_INFO( _fmt, ...) APP_LOG(WC_LOG_INFO, _fmt, ## __VA_ARGS__)
307 #define APP_NOT( _fmt, ...) APP_LOG(WC_LOG_NOTICE, _fmt, ## __VA_ARGS__)
308 #define APP_WARN( _fmt, ...) APP_LOG(WC_LOG_INFO, _fmt, ## __VA_ARGS__)
309 #define APP_ERR( _fmt, ...) APP_LOG(WC_LOG_ERR, _fmt, ## __VA_ARGS__)
310 #define APP_CRIT( _fmt, ...) APP_LOG(WC_LOG_CRIT, _fmt, ## __VA_ARGS__)
311 #define APP_ALRT( _fmt, ...) APP_LOG(WC_LOG_ALERT, _fmt, ## __VA_ARGS__)
312 #define APP_EMRG( _fmt, ...) APP_LOG(WC_LOG_EMERG, _fmt, ## __VA_ARGS__)
313 
314 #endif /* INCLUDE_WEBCOM_C_WEBCOM_LOG_H_ */
Webcom server connection logs.
Definition: webcom-log.h:41
see syslog.h&#39;s LOG_DEBUG
Definition: webcom-log.h:62
void wc_log(enum wc_log_facility f, enum wc_log_level l, const char *file, const char *func, int line, const char *fmt,...) __attribute__((format(printf
see syslog.h&#39;s LOG_ERR
Definition: webcom-log.h:58
void wc_log_use_custom(wc_log_f f)
see syslog.h&#39;s LOG_ALERT
Definition: webcom-log.h:56
Special value used to set a priority on all facilities.
Definition: webcom-log.h:47
void wc_log_use_journald(void)
wc_log_level
Definition: webcom-log.h:54
void wc_set_log_level(enum wc_log_facility f, enum wc_log_level l)
see syslog.h&#39;s LOG_CRIT
Definition: webcom-log.h:57
void wc_log_use_stderr(void)
Definition: webcom-log.h:66
see syslog.h&#39;s LOG_INFO
Definition: webcom-log.h:61
see syslog.h&#39;s LOG_NOTICE
Definition: webcom-log.h:60
Other logs.
Definition: webcom-log.h:43
Webcom messages activity logs.
Definition: webcom-log.h:42
wc_log_facility
Definition: webcom-log.h:38
libwebsockets logs
Definition: webcom-log.h:39
void(* wc_log_f)(const char *f, const char *l, const char *file, const char *func, int line, const char *message)
Definition: webcom-log.h:70
see syslog.h&#39;s LOG_EMERG
Definition: webcom-log.h:55
Definition: webcom-log.h:63
void wc_log_use_syslog(const char *ident, int option, int facility)
Webcom protocol (JSON-based) parser logs.
Definition: webcom-log.h:40
see syslog.h&#39;s LOG_WARNING
Definition: webcom-log.h:59
Authentication-related logs.
Definition: webcom-log.h:45
Reserved for the application&#39;s logs.
Definition: webcom-log.h:44