1/* 2 * simple logging functions that can be expanded into nothing 3 * 4 * Copyright (C) 2003-2004 Greg Kroah-Hartman <greg@kroah.com> 5 * Copyright (C) 2004-2006 Kay Sievers <kay.sievers@vrfy.org> 6 * 7 * This program is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License as published by the 9 * Free Software Foundation version 2 of the License. 10 * 11 * This program is distributed in the hope that it will be useful, but 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License along 17 * with this program; if not, write to the Free Software Foundation, Inc., 18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 * 20 */ 21 22#ifndef LOGGING_H 23#define LOGGING_H 24 25#define err(format, arg...) do { } while (0) 26#define info(format, arg...) do { } while (0) 27#define dbg(format, arg...) do { } while (0) 28#define logging_init(foo) do { } while (0) 29#define logging_close(foo) do { } while (0) 30 31#ifdef USE_LOG 32#include <stdarg.h> 33#include <unistd.h> 34#include <syslog.h> 35 36#undef err 37#define err(format, arg...) \ 38 do { \ 39 log_message(LOG_ERR ,"%s: " format ,__FUNCTION__ ,## arg); \ 40 } while (0) 41 42#undef info 43#define info(format, arg...) \ 44 do { \ 45 log_message(LOG_INFO ,"%s: " format ,__FUNCTION__ ,## arg); \ 46 } while (0) 47 48#ifdef DEBUG 49#undef dbg 50#define dbg(format, arg...) \ 51 do { \ 52 log_message(LOG_DEBUG ,"%s: " format ,__FUNCTION__ ,## arg); \ 53 } while (0) 54#endif 55 56extern void log_message(int priority, const char *format, ...) 57 __attribute__ ((format (printf, 2, 3))); 58 59#undef logging_init 60static inline void logging_init(const char *program_name) 61{ 62 openlog(program_name, LOG_PID | LOG_CONS, LOG_DAEMON); 63} 64 65#undef logging_close 66static inline void logging_close(void) 67{ 68 closelog(); 69} 70 71#endif /* USE_LOG */ 72 73#endif 74