From 317181e8ea1b3406919b946ca5524f8b9f34817d Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Wed, 4 Sep 2019 15:59:18 +0100 Subject: Introduce callback for logging Introduce an API for custom log handler functions. This allows libfuse applications to send messages to syslog(3) or other logging systems. See include/fuse_log.h for details. Convert libfuse from fprintf(stderr, ...) to log_fuse(level, ...). Most messages are error messages with FUSE_LOG_ERR log level. There are also some debug messages which now use the FUSE_LOG_DEBUG log level. Note that lib/mount_util.c is used by both libfuse and fusermount3. Since fusermount3 does not link against libfuse, we cannot call fuse_log() from lib/mount_util.c. This file will continue to use fprintf(stderr, ...) until someone figures out how to split it up. Signed-off-by: Stefan Hajnoczi --- lib/fuse_signals.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/fuse_signals.c') diff --git a/lib/fuse_signals.c b/lib/fuse_signals.c index e6f7112..4271947 100644 --- a/lib/fuse_signals.c +++ b/lib/fuse_signals.c @@ -24,7 +24,7 @@ static void exit_handler(int sig) if (fuse_instance) { fuse_session_exit(fuse_instance); if(sig <= 0) { - fprintf(stderr, "assertion error: signal value <= 0\n"); + fuse_log(FUSE_LOG_ERR, "assertion error: signal value <= 0\n"); abort(); } fuse_instance->error = sig; @@ -79,7 +79,7 @@ int fuse_set_signal_handlers(struct fuse_session *se) void fuse_remove_signal_handlers(struct fuse_session *se) { if (fuse_instance != se) - fprintf(stderr, + fuse_log(FUSE_LOG_ERR, "fuse: fuse_remove_signal_handlers: unknown session\n"); else fuse_instance = NULL; -- cgit v1.2.3