From c2401132bf72cbda6555f1ef4403851c14faeba5 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 5 Jun 2005 05:17:21 +0200 Subject: volume_id: use udev-provided log-level Signed-off-by: Kay Sievers --- extras/volume_id/Makefile | 2 +- extras/volume_id/udev_volume_id.c | 18 ++++++++++++++++-- udev.c | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/extras/volume_id/Makefile b/extras/volume_id/Makefile index 91527cc9f5..56fdf278b9 100644 --- a/extras/volume_id/Makefile +++ b/extras/volume_id/Makefile @@ -33,7 +33,7 @@ override CFLAGS+=-D_FILE_OFFSET_BITS=64 VOLUME_ID_BASE=volume_id include $(VOLUME_ID_BASE)/Makefile.inc -OBJS = udev_volume_id.o $(VOLUME_ID_OBJS) $(SYSFS) +OBJS = udev_volume_id.o $(VOLUME_ID_OBJS) ../../udev.a HEADERS = $(VOLUME_ID_HEADERS) $(OBJS): $(HEADERS) diff --git a/extras/volume_id/udev_volume_id.c b/extras/volume_id/udev_volume_id.c index a00b01a27d..7c6fc4050d 100644 --- a/extras/volume_id/udev_volume_id.c +++ b/extras/volume_id/udev_volume_id.c @@ -40,12 +40,26 @@ #define BLKGETSIZE64 _IOR(0x12,114,size_t) #ifdef USE_LOG -void log_message(int level, const char *format, ...) +void log_message(int priority, const char *format, ...) { va_list args; + static int udev_log = -1; + + if (udev_log == -1) { + const char *value; + + value = getenv("UDEV_LOG"); + if (value) + udev_log = log_priority(value); + else + udev_log = LOG_ERR; + } + + if (priority > udev_log) + return; va_start(args, format); - vsyslog(level, format, args); + vsyslog(priority, format, args); va_end(args); } #endif diff --git a/udev.c b/udev.c index 999d25d4e5..3f76e98b24 100644 --- a/udev.c +++ b/udev.c @@ -152,7 +152,7 @@ int main(int argc, char *argv[], char *envp[]) goto hotplug; } - /* export logging flag, as called scripts may want to do the same as udev */ + /* export logging flag, as called programs may want to do the same as udev */ if (udev_log_priority) { char priority[32]; -- cgit v1.2.3-54-g00ecf