From d026a35d747c0a993281408a9644ab843cf89fdd Mon Sep 17 00:00:00 2001 From: "greg@kroah.com" Date: Thu, 12 Feb 2004 18:57:06 -0800 Subject: [PATCH] [PATCH] more logging.h cleanups to be a bit more flexible. --- logging.h | 18 +++--------------- udev.c | 15 ++++++++++++--- udevd.c | 11 ++++++++--- udevinfo.c | 12 +++++++++--- udevsend.c | 11 ++++++++--- 5 files changed, 40 insertions(+), 27 deletions(-) diff --git a/logging.h b/logging.h index df0d7ded..2ba2ac49 100644 --- a/logging.h +++ b/logging.h @@ -57,23 +57,11 @@ } while (0) #endif -/* each program must declare this variable and function somewhere */ -extern unsigned char logname[42]; -extern int log_ok(void); - -static void log_message (int level, const char *format, ...) +extern void log_message (int level, const char *format, ...) __attribute__ ((format (printf, 2, 3))); -static inline void log_message (int level, const char *format, ...) -{ - va_list args; - if (!log_ok()) - return; - - va_start(args, format); - vsyslog(level, format, args); - va_end(args); -} +/* each program that uses syslog must declare this variable somewhere */ +extern unsigned char logname[42]; #undef init_logging static inline void init_logging(char *program_name) diff --git a/udev.c b/udev.c index 0f01fa41..9f10cc21 100644 --- a/udev.c +++ b/udev.c @@ -38,12 +38,21 @@ /* global variables */ char **main_argv; char **main_envp; -unsigned char logname[42]; -int log_ok(void) +#ifdef LOG +unsigned char logname[42]; +void log_message (int level, const char *format, ...) { - return udev_log; + va_list args; + + if (!udev_log) + return; + + va_start(args, format); + vsyslog(level, format, args); + va_end(args); } +#endif static void sig_handler(int signum) { diff --git a/udevd.c b/udevd.c index 14616b98..9fbb4e96 100644 --- a/udevd.c +++ b/udevd.c @@ -51,12 +51,17 @@ LIST_HEAD(running_list); static void exec_queue_manager(void); static void msg_queue_manager(void); +#ifdef LOG unsigned char logname[42]; - -int log_ok(void) +void log_message (int level, const char *format, ...) { - return 1; + va_list args; + + va_start(args, format); + vsyslog(level, format, args); + va_end(args); } +#endif static void msg_dump_queue(void) { diff --git a/udevinfo.c b/udevinfo.c index 103ebce0..44eb1427 100644 --- a/udevinfo.c +++ b/udevinfo.c @@ -38,12 +38,18 @@ char **main_argv; int main_argc; -unsigned char logname[42]; -int log_ok(void) +#ifdef LOG +unsigned char logname[42]; +void log_message (int level, const char *format, ...) { - return 1; + va_list args; + + va_start(args, format); + vsyslog(level, format, args); + va_end(args); } +#endif static int print_all_attributes(const char *path) { diff --git a/udevsend.c b/udevsend.c index b2fbcbbc..c738fe22 100644 --- a/udevsend.c +++ b/udevsend.c @@ -40,12 +40,17 @@ #include "udevd.h" #include "logging.h" +#ifdef LOG unsigned char logname[42]; - -int log_ok(void) +void log_message (int level, const char *format, ...) { - return 1; + va_list args; + + va_start(args, format); + vsyslog(level, format, args); + va_end(args); } +#endif static inline char *get_action(void) { -- 2.39.5