7 This file is part of avahi.
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.
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.
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
27 #include <avahi-common/cdecl.h>
29 /** \file log.h Extensible logging subsystem */
34 #define AVAHI_GCC_PRINTF_ATTR(a,b) __attribute__ ((format (printf, a, b)))
36 /** Macro for usage of GCC's printf compilation warnings */
37 #define AVAHI_GCC_PRINTF_ATTR(a,b)
40 #define AVAHI_GCC_PRINTF_ATTR12 AVAHI_GCC_PRINTF_ATTR(1,2)
41 #define AVAHI_GCC_PRINTF_ATTR23 AVAHI_GCC_PRINTF_ATTR(2,3)
43 /** Log level for avahi_log_xxx() */
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 */
53 /** Prototype for a user supplied log function */
54 typedef void (*AvahiLogFunction)(AvahiLogLevel level, const gchar *txt);
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);
61 /** Issue a log message using a va_list object */
62 void avahi_log_ap(AvahiLogLevel level, const gchar *format, va_list ap);
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;
67 /** Shortcut for avahi_log(AVAHI_LOG_ERROR, ...) */
68 void avahi_log_error(const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR12;
70 /** Shortcut for avahi_log(AVAHI_LOG_WARN, ...) */
71 void avahi_log_warn(const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR12;
73 /** Shortcut for avahi_log(AVAHI_LOG_NOTICE, ...) */
74 void avahi_log_notice(const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR12;
76 /** Shortcut for avahi_log(AVAHI_LOG_INFO, ...) */
77 void avahi_log_info(const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR12;
79 /** Shortcut for avahi_log(AVAHI_LOG_DEBUG, ...) */
80 void avahi_log_debug(const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR12;