]> git.meshlink.io Git - catta/blob - include/catta/log.h
rename everything avahi to catta
[catta] / include / catta / log.h
1 #ifndef foologhfoo
2 #define foologhfoo
3
4 /***
5   This file is part of catta.
6
7   catta is free software; you can redistribute it and/or modify it
8   under the terms of the GNU Lesser General Public License as
9   published by the Free Software Foundation; either version 2.1 of the
10   License, or (at your option) any later version.
11
12   catta is distributed in the hope that it will be useful, but WITHOUT
13   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14   or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
15   Public License for more details.
16
17   You should have received a copy of the GNU Lesser General Public
18   License along with catta; if not, write to the Free Software
19   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20   USA.
21 ***/
22
23 #include <stdarg.h>
24
25 #include <catta/cdecl.h>
26 #include <catta/gccmacro.h>
27
28 /** \file log.h Extensible logging subsystem */
29
30 CATTA_C_DECL_BEGIN
31
32 /** Log level for catta_log_xxx() */
33 typedef enum {
34     CATTA_LOG_ERROR  = 0,    /**< Error messages */
35     CATTA_LOG_WARN   = 1,    /**< Warning messages */
36     CATTA_LOG_NOTICE = 2,    /**< Notice messages */
37     CATTA_LOG_INFO   = 3,    /**< Info messages */
38     CATTA_LOG_DEBUG  = 4,    /**< Debug messages */
39     CATTA_LOG_LEVEL_MAX
40 } CattaLogLevel;
41
42 /** Prototype for a user supplied log function */
43 typedef void (*CattaLogFunction)(CattaLogLevel level, const char *txt);
44
45 /** Set a user supplied log function, replacing the default which
46  * prints to log messages unconditionally to STDERR. Pass NULL for
47  * resetting to the default log function */
48 void catta_set_log_function(CattaLogFunction function);
49
50 /** Issue a log message using a va_list object */
51 void catta_log_ap(CattaLogLevel level, const char *format, va_list ap);
52
53 /** Issue a log message by passing a log level and a format string */
54 void catta_log(CattaLogLevel level, const char*format, ...) CATTA_GCC_PRINTF_ATTR23;
55
56 /** Shortcut for catta_log(CATTA_LOG_ERROR, ...) */
57 void catta_log_error(const char*format, ...) CATTA_GCC_PRINTF_ATTR12;
58
59 /** Shortcut for catta_log(CATTA_LOG_WARN, ...) */
60 void catta_log_warn(const char*format, ...) CATTA_GCC_PRINTF_ATTR12;
61
62 /** Shortcut for catta_log(CATTA_LOG_NOTICE, ...) */
63 void catta_log_notice(const char*format, ...) CATTA_GCC_PRINTF_ATTR12;
64
65 /** Shortcut for catta_log(CATTA_LOG_INFO, ...) */
66 void catta_log_info(const char*format, ...) CATTA_GCC_PRINTF_ATTR12;
67
68 /** Shortcut for catta_log(CATTA_LOG_DEBUG, ...) */
69 void catta_log_debug(const char*format, ...) CATTA_GCC_PRINTF_ATTR12;
70
71 CATTA_C_DECL_END
72
73 #endif