]> git.meshlink.io Git - catta/blob - avahi-core/log.h
improve documentation
[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 #include <avahi-common/cdecl.h>
28
29 /** \file log.h Extensible logging subsystem */
30
31 AVAHI_C_DECL_BEGIN
32
33 #ifdef __GNUC__
34 #define AVAHI_GCC_PRINTF_ATTR(a,b) __attribute__ ((format (printf, a, b)))
35 #else
36 /** Macro for usage of GCC's printf compilation warnings */
37 #define AVAHI_GCC_PRINTF_ATTR(a,b)
38 #endif
39
40 #define AVAHI_GCC_PRINTF_ATTR12 AVAHI_GCC_PRINTF_ATTR(1,2)
41 #define AVAHI_GCC_PRINTF_ATTR23 AVAHI_GCC_PRINTF_ATTR(2,3)
42
43 /** Log level for avahi_log_xxx() */
44 typedef enum {
45     AVAHI_LOG_ERROR  = 0,    /**< Error messages */
46     AVAHI_LOG_WARN   = 1,    /**< Warning messages */
47     AVAHI_LOG_NOTICE = 2,    /**< Notice messages */
48     AVAHI_LOG_INFO   = 3,    /**< Info messages */
49     AVAHI_LOG_DEBUG  = 4,    /**< Debug messages */
50     AVAHI_LOG_LEVEL_MAX
51 } AvahiLogLevel;
52
53 /** Prototype for a user supplied log function */
54 typedef void (*AvahiLogFunction)(AvahiLogLevel level, const gchar *txt);
55
56 /** Set a user supplied log function, replacing the default which
57  * prints to log messages unconditionally to STDERR. Pass NULL for
58  * resetting to the default log function */
59 void avahi_set_log_function(AvahiLogFunction function);
60
61 /** Issue a log message using a va_list object */
62 void avahi_log_ap(AvahiLogLevel level, const gchar *format, va_list ap);
63
64 /** Issue a log message by passing a log level and a format string */
65 void avahi_log(AvahiLogLevel level, const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR23;
66
67 /** Shortcut for avahi_log(AVAHI_LOG_ERROR, ...) */
68 void avahi_log_error(const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR12;
69
70 /** Shortcut for avahi_log(AVAHI_LOG_WARN, ...) */
71 void avahi_log_warn(const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR12;
72
73 /** Shortcut for avahi_log(AVAHI_LOG_NOTICE, ...) */
74 void avahi_log_notice(const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR12;
75
76 /** Shortcut for avahi_log(AVAHI_LOG_INFO, ...) */
77 void avahi_log_info(const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR12;
78
79 /** Shortcut for avahi_log(AVAHI_LOG_DEBUG, ...) */
80 void avahi_log_debug(const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR12;
81
82 AVAHI_C_DECL_END
83
84 #endif