From d240314a1a18a1d914af1b5763fe8c9a572e6409 Mon Sep 17 00:00:00 2001 From: Eryu Guan Date: Fri, 9 Aug 2019 16:25:35 +0800 Subject: virtiofsd: print log only when priority is high enough MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce "-o log_level=" command line option to specify current log level (priority), valid values are "debug info warn err", e.g. ./virtiofsd -o log_level=debug ... So only log priority higher than "debug" will be printed to stderr/syslog. And the default level is info. The "-o debug"/"-d" options are kept, and imply debug log level. Signed-off-by: Eryu Guan dgilbert: Reworked for libfuse's log_func Signed-off-by: Dr. David Alan Gilbert with fix by: Signed-off-by: Xiao Yang Reviewed-by: Daniel P. Berrangé Signed-off-by: Dr. David Alan Gilbert --- tools/virtiofsd/helper.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tools/virtiofsd/helper.c') diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c index 9692ef9f1f..6d50a46a7e 100644 --- a/tools/virtiofsd/helper.c +++ b/tools/virtiofsd/helper.c @@ -34,7 +34,6 @@ t, offsetof(struct fuse_cmdline_opts, p), v \ } - static const struct fuse_opt fuse_helper_opts[] = { FUSE_HELPER_OPT("-h", show_help), FUSE_HELPER_OPT("--help", show_help), @@ -55,6 +54,10 @@ static const struct fuse_opt fuse_helper_opts[] = { FUSE_OPT_KEY("subtype=", FUSE_OPT_KEY_KEEP), FUSE_HELPER_OPT("max_idle_threads=%u", max_idle_threads), FUSE_HELPER_OPT("--syslog", syslog), + FUSE_HELPER_OPT_VALUE("log_level=debug", log_level, FUSE_LOG_DEBUG), + FUSE_HELPER_OPT_VALUE("log_level=info", log_level, FUSE_LOG_INFO), + FUSE_HELPER_OPT_VALUE("log_level=warn", log_level, FUSE_LOG_WARNING), + FUSE_HELPER_OPT_VALUE("log_level=err", log_level, FUSE_LOG_ERR), FUSE_OPT_END }; @@ -142,6 +145,9 @@ void fuse_cmdline_help(void) " --syslog log to syslog (default stderr)\n" " -f foreground operation\n" " --daemonize run in background\n" + " -o log_level= log level, default to \"info\"\n" + " level could be one of \"debug, " + "info, warn, err\"\n" " -o max_idle_threads the maximum number of idle worker " "threads\n" " allowed (default: 10)\n" -- cgit v1.2.3