1 /**
2  *  Copyright (C) 2011-2012  Juho Vähä-Herttua
3  *
4  *  This library is free software; you can redistribute it and/or
5  *  modify it under the terms of the GNU Lesser General Public
6  *  License as published by the Free Software Foundation; either
7  *  version 2.1 of the License, or (at your option) any later version.
8  *
9  *  This library is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  *  Lesser General Public License for more details.
13  */
14 
15 #ifndef LOGGER_H
16 #define LOGGER_H
17 
18 /* Define syslog style log levels */
19 #define LOGGER_EMERG       0       /* system is unusable */
20 #define LOGGER_ALERT       1       /* action must be taken immediately */
21 #define LOGGER_CRIT        2       /* critical conditions */
22 #define LOGGER_ERR         3       /* error conditions */
23 #define LOGGER_WARNING     4       /* warning conditions */
24 #define LOGGER_NOTICE      5       /* normal but significant condition */
25 #define LOGGER_INFO        6       /* informational */
26 #define LOGGER_DEBUG       7       /* debug-level messages */
27 
28 typedef void (*logger_callback_t)(void *cls, int level, const char *msg);
29 
30 typedef struct logger_s logger_t;
31 
32 logger_t *logger_init();
33 void logger_destroy(logger_t *logger);
34 
35 void logger_set_level(logger_t *logger, int level);
36 void logger_set_callback(logger_t *logger, logger_callback_t callback, void *cls);
37 
38 void logger_log(logger_t *logger, int level, const char *fmt, ...);
39 
40 #endif
41