From 7af9e83ca67eef41964b14e373964dfc848c0108 Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Tue, 15 Nov 2022 08:35:14 +0100 Subject: [PATCH] Default FUSE driver debuglevel to `warn` in background mode (fixes gh #113) --- doc/dwarfs.md | 3 ++- src/dwarfs.cpp | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/dwarfs.md b/doc/dwarfs.md index 198902bb..5d24dacf 100644 --- a/doc/dwarfs.md +++ b/doc/dwarfs.md @@ -109,7 +109,8 @@ options: the `-f` or `-d` FUSE options. This can give you some insight over what the file system driver is doing internally, but it's mainly meant for debugging and the `debug` and `trace` levels - in particular will slow down the driver. + in particular will slow down the driver. This defaults to `info` + in foreground mode (`-f`, `-d`) and to `warn` in background mode. - `-o tidy_strategy=`*name*: Use one of the following strategies to tidy the block cache: diff --git a/src/dwarfs.cpp b/src/dwarfs.cpp index 03e7a9dc..da8cf530 100644 --- a/src/dwarfs.cpp +++ b/src/dwarfs.cpp @@ -501,7 +501,7 @@ void usage(const char* progname) { << " -o readonly show read-only file system\n" << " -o (no_)cache_image (don't) keep image in kernel cache\n" << " -o (no_)cache_files (don't) keep files in kernel cache\n" - << " -o debuglevel=NAME error, warn, (info), debug, trace\n" + << " -o debuglevel=NAME error, warn, info, debug, trace\n" << " -o tidy_strategy=NAME (none)|time|swap\n" << " -o tidy_interval=TIME interval for cache tidying (5m)\n" << " -o tidy_max_age=TIME tidy blocks after this time (10m)\n" @@ -724,9 +724,11 @@ int run_dwarfs(int argc, char** argv) { opts.fsimage = std::filesystem::canonical(opts.fsimage).native(); - opts.debuglevel = opts.debuglevel_str - ? logger::parse_level(opts.debuglevel_str) - : logger::INFO; + if (opts.debuglevel_str) { + opts.debuglevel = logger::parse_level(opts.debuglevel_str); + } else { + opts.debuglevel = fuse_opts.foreground ? logger::INFO : logger::WARN; + } userdata.lgr.set_threshold(opts.debuglevel); userdata.lgr.set_with_context(opts.debuglevel >= logger::DEBUG);