Re: [patch 9/9] Implement better error reporting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



oneMark McLoughlin wrote:
Add a qemudLog() function which uses syslog() if we're in
daemon mode, doesn't output INFO/DEBUG messages unless
the verbose flag is set and doesn't output DEBUG messages
unless compiled with --enable-debug.

You're all gonna hate this I know, but libvirtd handles syslog by forking an external logger(1) process. Messages sent to stderr go to syslog. This is partly necessary because the SunRPC code within glibc is a bit too happy to send debug messages to stderr & nowhere else.

The brief code snippet to enable this is below (and note my original patch which you can also find on this list enables a test for LOGGER in autoconf):

#ifdef LOGGER
        /* Send stderr to syslog using logger.  It's a lot simpler
         * to do this.  Note that SunRPC in glibc prints lots of
         * gumf to stderr and it'd be a load of work to change that.
         */
        int fd[2];
        if (pipe (fd) == -1) {
            perror ("pipe");
            exit (2);
        }
        int pid = fork ();
        if (pid == -1) {
            perror ("fork");
            exit (2);
        }
        if (pid == 0) {         /* Child - logger. */
            const char *args[] = {
                "logger", "-tlibvirtd", "-p", "daemon.notice", NULL
            };
            close (fd[1]);
            dup2 (fd[0], 0);
            close (fd[0]);
            execv (LOGGER, (char *const *) args);
            perror ("execv");
            _exit (1);
        }
        close (fd[0]);
        dup2 (fd[1], 2);
        close (fd[1]);
#endif

Rich.

--
Emerging Technologies, Red Hat  http://et.redhat.com/~rjones/
64 Baker Street, London, W1U 7DF     Mobile: +44 7866 314 421
 "[Negative numbers] darken the very whole doctrines of the equations
 and make dark of the things which are in their nature excessively
 obvious and simple" (Francis Maseres FRS, mathematician, 1759)


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]