chiark / gitweb /
udevd: add timestamp to --debug output
authorKay Sievers <kay.sievers@vrfy.org>
Fri, 17 Jul 2009 11:24:37 +0000 (13:24 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Fri, 17 Jul 2009 11:26:46 +0000 (13:26 +0200)
libudev/libudev-util-private.c
udev/udevd.c

index 5f5f4c1d89f82e823c203500fc5cea44fcdc5dd6..f7daa9460beabeca74c08a80c548f1b5b129365a 100644 (file)
@@ -249,6 +249,8 @@ int util_run_program(struct udev *udev, const char *command, char **envp,
        int i;
        int err = 0;
 
        int i;
        int err = 0;
 
+       info(udev, "'%s' started\n", command);
+
        /* build argv from command */
        util_strscpy(arg, sizeof(arg), command);
        i = 0;
        /* build argv from command */
        util_strscpy(arg, sizeof(arg), command);
        i = 0;
@@ -273,7 +275,6 @@ int util_run_program(struct udev *udev, const char *command, char **envp,
                argv[0] = arg;
                argv[1] = NULL;
        }
                argv[0] = arg;
                argv[1] = NULL;
        }
-       info(udev, "'%s'\n", command);
 
        /* prepare pipes from child to parent */
        if (result != NULL || udev_get_log_priority(udev) >= LOG_INFO) {
 
        /* prepare pipes from child to parent */
        if (result != NULL || udev_get_log_priority(udev) >= LOG_INFO) {
index 2cdc18b41e45a3a831d044a80d027e50dbd39d31..69d509ce915baddcd9fd5ed25d961d9477e0f75c 100644 (file)
@@ -31,6 +31,7 @@
 #include <time.h>
 #include <getopt.h>
 #include <dirent.h>
 #include <time.h>
 #include <getopt.h>
 #include <dirent.h>
+#include <sys/time.h>
 #include <sys/prctl.h>
 #include <sys/socket.h>
 #include <sys/signalfd.h>
 #include <sys/prctl.h>
 #include <sys/socket.h>
 #include <sys/signalfd.h>
@@ -53,8 +54,15 @@ static void log_fn(struct udev *udev, int priority,
                   const char *format, va_list args)
 {
        if (debug) {
                   const char *format, va_list args)
 {
        if (debug) {
-               fprintf(stderr, "[%d] %s: ", (int) getpid(), fn);
-               vfprintf(stderr, format, args);
+               char buf[1024];
+               struct timeval tv;
+               struct timezone tz;
+
+               vsnprintf(buf, sizeof(buf), format, args);
+               gettimeofday(&tv, &tz);
+               fprintf(stderr, "%llu.%06u [%u] %s: %s",
+                       (unsigned long long) tv.tv_sec, (unsigned int) tv.tv_usec,
+                       (int) getpid(), fn, buf);
        } else {
                vsyslog(priority, format, args);
        }
        } else {
                vsyslog(priority, format, args);
        }
@@ -266,6 +274,7 @@ static void worker_new(struct event *event)
                        struct worker_message msg;
                        int err;
 
                        struct worker_message msg;
                        int err;
 
+                       info(event->udev, "seq %llu running\n", udev_device_get_seqnum(dev));
                        udev_event = udev_event_new(dev);
                        if (udev_event == NULL)
                                _exit(3);
                        udev_event = udev_event_new(dev);
                        if (udev_event == NULL)
                                _exit(3);