K2.6 patches and update.
[tomato.git] / release / src / router / udev / logging.h
blob6e1d5a20ef7d7f28faade207c422686f21182bf1
1 /*
2 * simple logging functions that can be expanded into nothing
4 * Copyright (C) 2003-2004 Greg Kroah-Hartman <greg@kroah.com>
5 * Copyright (C) 2004-2006 Kay Sievers <kay.sievers@vrfy.org>
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.
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.
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.
22 #ifndef LOGGING_H
23 #define LOGGING_H
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)
31 #ifdef USE_LOG
32 #include <stdarg.h>
33 #include <unistd.h>
34 #include <syslog.h>
36 #undef err
37 #define err(format, arg...) \
38 do { \
39 log_message(LOG_ERR ,"%s: " format ,__FUNCTION__ ,## arg); \
40 } while (0)
42 #undef info
43 #define info(format, arg...) \
44 do { \
45 log_message(LOG_INFO ,"%s: " format ,__FUNCTION__ ,## arg); \
46 } while (0)
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
56 extern void log_message(int priority, const char *format, ...)
57 __attribute__ ((format (printf, 2, 3)));
59 #undef logging_init
60 static inline void logging_init(const char *program_name)
62 openlog(program_name, LOG_PID | LOG_CONS, LOG_DAEMON);
65 #undef logging_close
66 static inline void logging_close(void)
68 closelog();
71 #endif /* USE_LOG */
73 #endif