]> git.meshlink.io Git - catta/blob - avahi-core/log.h
* add logging API and make all code make use of it
[catta] / avahi-core / log.h
1 #ifndef foologhfoo
2 #define foologhfoo
3
4 /* $Id$ */
5
6 /***
7   This file is part of avahi.
8  
9   avahi is free software; you can redistribute it and/or modify it
10   under the terms of the GNU Lesser General Public License as
11   published by the Free Software Foundation; either version 2.1 of the
12   License, or (at your option) any later version.
13  
14   avahi is distributed in the hope that it will be useful, but WITHOUT
15   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16   or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
17   Public License for more details.
18  
19   You should have received a copy of the GNU Lesser General Public
20   License along with avahi; if not, write to the Free Software
21   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22   USA.
23 ***/
24
25 #include <stdarg.h>
26 #include <glib.h>
27
28 #ifdef __GNUC__
29 #define AVAHI_GCC_PRINTF_ATTR(a,b) __attribute__ ((format (printf, a, b)))
30 #else
31 /** Macro for usage of GCC's printf compilation warnings */
32 #define AVAHI_GCC_PRINTF_ATTR(a,b)
33 #endif
34
35 #define AVAHI_GCC_PRINTF_ATTR12 AVAHI_GCC_PRINTF_ATTR(1,2)
36 #define AVAHI_GCC_PRINTF_ATTR23 AVAHI_GCC_PRINTF_ATTR(2,3)
37
38 /** Log level for avahi_log_xxx() */
39 typedef enum {
40     AVAHI_LOG_ERROR  = 0,    /**< Error messages */
41     AVAHI_LOG_WARN   = 1,    /**< Warning messages */
42     AVAHI_LOG_NOTICE = 2,    /**< Notice messages */
43     AVAHI_LOG_INFO   = 3,    /**< Info messages */
44     AVAHI_LOG_DEBUG  = 4,    /**< Debug messages */
45     AVAHI_LOG_LEVEL_MAX
46 } AvahiLogLevel;
47
48 /** Prototype for a user supplied log function */
49 typedef void (*AvahiLogFunction)(AvahiLogLevel level, const gchar *txt);
50
51 /** Set a user supplied log function, replacing the default which
52  * prints to log messages unconditionally to STDERR. Pass NULL for
53  * resetting to the default log function */
54 void avahi_set_log_function(AvahiLogFunction function);
55
56 /** Issue a log message using a va_list object */
57 void avahi_log_ap(AvahiLogLevel level, const gchar *format, va_list ap);
58
59 /** Issue a log message by passing a log level and a format string */
60 void avahi_log(AvahiLogLevel level, const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR23;
61
62 /** Shortcut for avahi_log(AVAHI_LOG_ERROR, ...) */
63 void avahi_log_error(const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR12;
64
65 /** Shortcut for avahi_log(AVAHI_LOG_WARN, ...) */
66 void avahi_log_warn(const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR12;
67
68 /** Shortcut for avahi_log(AVAHI_LOG_NOTICE, ...) */
69 void avahi_log_notice(const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR12;
70
71 /** Shortcut for avahi_log(AVAHI_LOG_INFO, ...) */
72 void avahi_log_info(const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR12;
73
74 /** Shortcut for avahi_log(AVAHI_LOG_DEBUG, ...) */
75 void avahi_log_debug(const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR12;
76
77 #endif