]> www.infradead.org Git - users/dhowells/kafs-client.git/commitdiff
Use syslog in kafs-preload program
authorDavid Howells <dhowells@redhat.com>
Tue, 11 Dec 2018 00:23:00 +0000 (00:23 +0000)
committerDavid Howells <dhowells@redhat.com>
Tue, 11 Dec 2018 00:23:00 +0000 (00:23 +0000)
Write verbose messages to the syslog in the kafs-preload programme and also
set the name of the facility.

Signed-off-by: David Howells <dhowells@redhat.com>
src/preload-cells.c

index e0edc6aadfc341f4ee4b9e966d5a0ec7605f8f5a..4199f60fbf2965b4ed2844d0a351dff124b62630 100644 (file)
@@ -35,6 +35,12 @@ static void verbose(const char *fmt, ...)
        va_list va;
 
        va_start(va, fmt);
+       if (isatty(2)) {
+               vprintf(fmt, va);
+               putchar('\n');
+       } else {
+               vsyslog(LOG_INFO, fmt, va);
+       }
        vprintf(fmt, va);
        putchar('\n');
        va_end(va);
@@ -139,6 +145,11 @@ int main(int argc, char *argv[])
                }
        }
 
+       if (!redirect_to_stdout) {
+               openlog("kafs-preload", 0, LOG_USER);
+               syslog(LOG_NOTICE, "kAFS: Preloading cell database");
+       }
+
        argc -= optind;
        argv += optind;