1/* $Id$ */ 2 3/*** 4 This file is part of avahi. 5 6 avahi is free software; you can redistribute it and/or modify it 7 under the terms of the GNU Lesser General Public License as 8 published by the Free Software Foundation; either version 2.1 of the 9 License, or (at your option) any later version. 10 11 avahi is distributed in the hope that it will be useful, but WITHOUT 12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General 14 Public License for more details. 15 16 You should have received a copy of the GNU Lesser General Public 17 License along with avahi; if not, write to the Free Software 18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 USA. 20***/ 21 22#ifdef HAVE_CONFIG_H 23#include <config.h> 24#endif 25 26#include <stdio.h> 27#include <stdarg.h> 28 29#include "log.h" 30 31static AvahiLogFunction log_function = NULL; 32 33void avahi_set_log_function(AvahiLogFunction function) { 34 log_function = function; 35} 36 37void avahi_log_ap(AvahiLogLevel level, const char*format, va_list ap) { 38 char txt[256]; 39 40 vsnprintf(txt, sizeof(txt), format, ap); 41 42 if (log_function) 43 log_function(level, txt); 44 else 45 fprintf(stderr, "%s\n", txt); 46} 47 48void avahi_log(AvahiLogLevel level, const char*format, ...) { 49 va_list ap; 50 va_start(ap, format); 51 avahi_log_ap(level, format, ap); 52 va_end(ap); 53} 54 55void avahi_log_error(const char*format, ...) { 56 va_list ap; 57 va_start(ap, format); 58 avahi_log_ap(AVAHI_LOG_ERROR, format, ap); 59 va_end(ap); 60} 61 62void avahi_log_warn(const char*format, ...) { 63 va_list ap; 64 va_start(ap, format); 65 avahi_log_ap(AVAHI_LOG_WARN, format, ap); 66 va_end(ap); 67} 68 69void avahi_log_notice(const char*format, ...) { 70 va_list ap; 71 va_start(ap, format); 72 avahi_log_ap(AVAHI_LOG_NOTICE, format, ap); 73 va_end(ap); 74} 75 76void avahi_log_info(const char*format, ...) { 77 va_list ap; 78 va_start(ap, format); 79 avahi_log_ap(AVAHI_LOG_INFO, format, ap); 80 va_end(ap); 81} 82 83void avahi_log_debug(const char*format, ...) { 84 va_list ap; 85 va_start(ap, format); 86 avahi_log_ap(AVAHI_LOG_DEBUG, format, ap); 87 va_end(ap); 88} 89