diff --git a/src/libudev/libudev-private.h b/src/libudev/libudev-private.h index af0f125c739..ae975575dc7 100644 --- a/src/libudev/libudev-private.h +++ b/src/libudev/libudev-private.h @@ -20,7 +20,6 @@ #ifndef _LIBUDEV_PRIVATE_H_ #define _LIBUDEV_PRIVATE_H_ -#include #include #include #include diff --git a/src/test/test-libudev.c b/src/test/test-libudev.c index 912b61396a3..ea190990ebf 100644 --- a/src/test/test-libudev.c +++ b/src/test/test-libudev.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include diff --git a/src/test/test-udev.c b/src/test/test-udev.c index 26d6537ccf9..566a73a066f 100644 --- a/src/test/test-udev.c +++ b/src/test/test-udev.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/src/udev/accelerometer/accelerometer.c b/src/udev/accelerometer/accelerometer.c index 32adf277777..4513bc63c20 100644 --- a/src/udev/accelerometer/accelerometer.c +++ b/src/udev/accelerometer/accelerometer.c @@ -69,19 +69,12 @@ #define LONG(x) ((x)/BITS_PER_LONG) #define test_bit(bit, array) ((array[LONG(bit)] >> OFF(bit)) & 1) -static int debug = 0; - _printf_(6,0) static void log_fn(struct udev *udev, int priority, const char *file, int line, const char *fn, const char *format, va_list args) { - if (debug) { - fprintf(stderr, "%s: ", fn); - vfprintf(stderr, format, args); - } else { - vsyslog(priority, format, args); - } + log_metav(priority, file, line, fn, format, args); } typedef enum { @@ -233,11 +226,13 @@ int main (int argc, char** argv) struct udev_enumerate *enumerate; struct udev_list_entry *list_entry; + log_parse_environment(); + log_open(); + udev = udev_new(); if (udev == NULL) return 1; - log_open(); udev_set_log_fn(udev, log_fn); /* CLI argument parsing */ @@ -250,9 +245,10 @@ int main (int argc, char** argv) switch (option) { case 'd': - debug = 1; + log_set_target(LOG_TARGET_CONSOLE); log_set_max_level(LOG_DEBUG); udev_set_log_priority(udev, LOG_DEBUG); + log_open(); break; case 'h': help(); diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c index f84281dd1a2..bfde57223ab 100644 --- a/src/udev/ata_id/ata_id.c +++ b/src/udev/ata_id/ata_id.c @@ -410,7 +410,7 @@ static void log_fn(struct udev *udev, int priority, const char *file, int line, const char *fn, const char *format, va_list args) { - vsyslog(priority, format, args); + log_metav(priority, file, line, fn, format, args); } int main(int argc, char *argv[]) @@ -435,11 +435,13 @@ int main(int argc, char *argv[]) {} }; + log_parse_environment(); + log_open(); + udev = udev_new(); if (udev == NULL) goto exit; - log_open(); udev_set_log_fn(udev, log_fn); while (1) { diff --git a/src/udev/cdrom_id/cdrom_id.c b/src/udev/cdrom_id/cdrom_id.c index 33b2bc33317..c93a7bf8d13 100644 --- a/src/udev/cdrom_id/cdrom_id.c +++ b/src/udev/cdrom_id/cdrom_id.c @@ -37,19 +37,12 @@ #include "libudev.h" #include "libudev-private.h" -static bool debug; - _printf_(6,0) static void log_fn(struct udev *udev, int priority, const char *file, int line, const char *fn, const char *format, va_list args) { - if (debug) { - fprintf(stderr, "%s: ", fn); - vfprintf(stderr, format, args); - } else { - vsyslog(priority, format, args); - } + log_metav(priority, file, line, fn, format, args); } /* device info */ @@ -875,11 +868,13 @@ int main(int argc, char *argv[]) int cnt; int rc = 0; + log_parse_environment(); + log_open(); + udev = udev_new(); if (udev == NULL) goto exit; - log_open(); udev_set_log_fn(udev, log_fn); while (1) { @@ -900,9 +895,10 @@ int main(int argc, char *argv[]) eject = true; break; case 'd': - debug = true; + log_set_target(LOG_TARGET_CONSOLE); log_set_max_level(LOG_DEBUG); udev_set_log_priority(udev, LOG_DEBUG); + log_open(); break; case 'h': printf("Usage: cdrom_id [options] \n" diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c index 5511df88255..4d9378a5c0a 100644 --- a/src/udev/scsi_id/scsi_id.c +++ b/src/udev/scsi_id/scsi_id.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -55,7 +54,6 @@ static bool dev_specified = false; static char config_file[MAX_PATH_LEN] = "/etc/scsi_id.config"; static enum page_code default_page_code = PAGE_UNSPECIFIED; static int sg_version = 4; -static int debug = 0; static bool reformat_serial = false; static bool export = false; static char vendor_str[64]; @@ -70,7 +68,7 @@ static void log_fn(struct udev *udev, int priority, const char *file, int line, const char *fn, const char *format, va_list args) { - vsyslog(priority, format, args); + log_metav(priority, file, line, fn, format, args); } static void set_type(const char *from, char *to, size_t len) @@ -390,7 +388,10 @@ static int set_options(struct udev *udev, break; case 'v': - debug++; + log_set_target(LOG_TARGET_CONSOLE); + log_set_max_level(LOG_DEBUG); + udev_set_log_priority(udev, LOG_DEBUG); + log_open(); break; case 'V': @@ -583,11 +584,13 @@ int main(int argc, char **argv) int newargc; char **newargv = NULL; + log_parse_environment(); + log_open(); + udev = udev_new(); if (udev == NULL) goto exit; - log_open(); udev_set_log_fn(udev, log_fn); /* diff --git a/src/udev/scsi_id/scsi_serial.c b/src/udev/scsi_id/scsi_serial.c index 378a73d8639..b3d20a3c2db 100644 --- a/src/udev/scsi_id/scsi_serial.c +++ b/src/udev/scsi_id/scsi_serial.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c index fae8b4c6b30..ddcf1ddf9ae 100644 --- a/src/udev/udevadm-settle.c +++ b/src/udev/udevadm-settle.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include diff --git a/src/udev/udevadm-test-builtin.c b/src/udev/udevadm-test-builtin.c index 179f2696937..a300e1e9d7c 100644 --- a/src/udev/udevadm-test-builtin.c +++ b/src/udev/udevadm-test-builtin.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c index 0f6cccffb56..84860498142 100644 --- a/src/udev/udevadm-test.c +++ b/src/udev/udevadm-test.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c index 668791b7a05..a52d1b5ad50 100644 --- a/src/udev/udevadm-trigger.c +++ b/src/udev/udevadm-trigger.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include