4 * Simple logging functions that can be compiled away into nothing.
6 * Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
7 * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation version 2 of the License.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 675 Mass Ave, Cambridge, MA 02139, USA.
27 #define info(format, arg...) do { } while (0)
28 #define dbg(format, arg...) do { } while (0)
29 #define dbg_parse(format, arg...) do { } while (0)
30 #define init_logging(foo) do { } while (0)
38 #define info(format, arg...) \
40 log_message (LOG_INFO , format , ## arg); \
45 #define dbg(format, arg...) \
47 log_message (LOG_DEBUG , "%s: " format , __FUNCTION__ , ## arg); \
51 /* Parser needs it's own debugging statement, we usually don't care about this at all */
54 #define dbg_parse(format, arg...) \
56 log_message (LOG_DEBUG , "%s: " format , __FUNCTION__ , ## arg); \
60 /* each program must declare this variable and function somewhere */
61 extern unsigned char logname[42];
62 extern int log_ok(void);
64 static void log_message (int level, const char *format, ...)
65 __attribute__ ((format (printf, 2, 3)));
66 static inline void log_message (int level, const char *format, ...)
73 va_start(args, format);
74 vsyslog(level, format, args);
79 static inline void init_logging(char *program_name)
81 snprintf(logname, 42,"%s[%d]", program_name, getpid());
82 openlog(logname, 0, LOG_DAEMON);