[PATCH] 055 release
[systemd_ALT/systemd_imz.git] / logging.h
blobe7653ee1b85228503d7a61fcd9dfbe3284c37b51
1 /*
2 * logging.h
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.
24 #ifndef LOGGING_H
25 #define LOGGING_H
27 #define info(format, arg...) do { } while (0)
28 #define dbg(format, arg...) do { } while (0)
29 #define logging_init(foo) do { } while (0)
30 #define logging_close(foo) do { } while (0)
32 #ifdef USE_LOG
33 #include <stdarg.h>
34 #include <unistd.h>
35 #include <syslog.h>
37 #undef info
38 #define info(format, arg...) \
39 do { \
40 log_message(LOG_INFO , format , ## arg); \
41 } while (0)
43 #ifdef DEBUG
44 #undef dbg
45 #define dbg(format, arg...) \
46 do { \
47 log_message(LOG_DEBUG , "%s: " format , __FUNCTION__ , ## arg); \
48 } while (0)
49 #endif
51 extern void log_message(int level, const char *format, ...)
52 __attribute__ ((format (printf, 2, 3)));
54 #undef logging_init
55 static inline void logging_init(const char *program_name)
57 openlog(program_name, LOG_PID, LOG_DAEMON);
60 #undef logging_close
61 static inline void logging_close(void)
63 closelog();
66 #endif /* USE_LOG */
68 #endif