From f058d9bb7b22a431b17a56242ab7e07e5187b1cd Mon Sep 17 00:00:00 2001 From: David Howells Date: Tue, 11 Dec 2018 00:23:00 +0000 Subject: [PATCH] Use syslog in kafs-preload program Write verbose messages to the syslog in the kafs-preload programme and also set the name of the facility. Signed-off-by: David Howells --- src/preload-cells.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/preload-cells.c b/src/preload-cells.c index e0edc6a..4199f60 100644 --- a/src/preload-cells.c +++ b/src/preload-cells.c @@ -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; -- 2.50.1