diff options
author | Stefan Hajnoczi <stefanha@gmail.com> | 2019-09-04 15:59:18 +0100 |
---|---|---|
committer | Nikolaus Rath <Nikolaus@rath.org> | 2019-09-04 15:59:18 +0100 |
commit | 317181e8ea1b3406919b946ca5524f8b9f34817d (patch) | |
tree | 0d0e0a2eb0d3d309dbabbdcdd6cb62131507b592 /lib/modules | |
parent | f39c71dcf99292c188bb6f0a117d7e118f92bfb1 (diff) | |
download | libfuse-317181e8ea1b3406919b946ca5524f8b9f34817d.tar.gz |
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 <stefanha@redhat.com>
Diffstat (limited to 'lib/modules')
-rw-r--r-- | lib/modules/iconv.c | 8 | ||||
-rw-r--r-- | lib/modules/subdir.c | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/modules/iconv.c b/lib/modules/iconv.c index 84f4236..431d02c 100644 --- a/lib/modules/iconv.c +++ b/lib/modules/iconv.c @@ -659,7 +659,7 @@ static struct fuse_fs *iconv_new(struct fuse_args *args, ic = calloc(1, sizeof(struct iconv)); if (ic == NULL) { - fprintf(stderr, "fuse-iconv: memory allocation failed\n"); + fuse_log(FUSE_LOG_ERR, "fuse-iconv: memory allocation failed\n"); return NULL; } @@ -667,7 +667,7 @@ static struct fuse_fs *iconv_new(struct fuse_args *args, goto out_free; if (!next[0] || next[1]) { - fprintf(stderr, "fuse-iconv: exactly one next filesystem required\n"); + fuse_log(FUSE_LOG_ERR, "fuse-iconv: exactly one next filesystem required\n"); goto out_free; } @@ -678,13 +678,13 @@ static struct fuse_fs *iconv_new(struct fuse_args *args, old = strdup(setlocale(LC_CTYPE, "")); ic->tofs = iconv_open(from, to); if (ic->tofs == (iconv_t) -1) { - fprintf(stderr, "fuse-iconv: cannot convert from %s to %s\n", + fuse_log(FUSE_LOG_ERR, "fuse-iconv: cannot convert from %s to %s\n", to, from); goto out_free; } ic->fromfs = iconv_open(to, from); if (ic->tofs == (iconv_t) -1) { - fprintf(stderr, "fuse-iconv: cannot convert from %s to %s\n", + fuse_log(FUSE_LOG_ERR, "fuse-iconv: cannot convert from %s to %s\n", from, to); goto out_iconv_close_to; } diff --git a/lib/modules/subdir.c b/lib/modules/subdir.c index f84d8c1..23f58f8 100644 --- a/lib/modules/subdir.c +++ b/lib/modules/subdir.c @@ -633,7 +633,7 @@ static struct fuse_fs *subdir_new(struct fuse_args *args, d = calloc(1, sizeof(struct subdir)); if (d == NULL) { - fprintf(stderr, "fuse-subdir: memory allocation failed\n"); + fuse_log(FUSE_LOG_ERR, "fuse-subdir: memory allocation failed\n"); return NULL; } @@ -641,19 +641,19 @@ static struct fuse_fs *subdir_new(struct fuse_args *args, goto out_free; if (!next[0] || next[1]) { - fprintf(stderr, "fuse-subdir: exactly one next filesystem required\n"); + fuse_log(FUSE_LOG_ERR, "fuse-subdir: exactly one next filesystem required\n"); goto out_free; } if (!d->base) { - fprintf(stderr, "fuse-subdir: missing 'subdir' option\n"); + fuse_log(FUSE_LOG_ERR, "fuse-subdir: missing 'subdir' option\n"); goto out_free; } if (d->base[0] && d->base[strlen(d->base)-1] != '/') { char *tmp = realloc(d->base, strlen(d->base) + 2); if (!tmp) { - fprintf(stderr, "fuse-subdir: memory allocation failed\n"); + fuse_log(FUSE_LOG_ERR, "fuse-subdir: memory allocation failed\n"); goto out_free; } d->base = tmp; |