# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1638137255 -3600
# Node ID 73ecfe81152680dd791eaba2cccd345ee71e578a
# Parent  202319a990e7fd6449444a9e049310fae88c8370
util.startup: Teach prosodyctl to be --quiet as complement to --verbose

Original motivation was tiresome warnings about Lua 5.4 not being
supported yet.

Can still be handy to tweak log level, e.g. to prevent logging to
interfere with command output.

diff -r 202319a990e7 -r 73ecfe811526 man/prosodyctl.man
--- a/man/prosodyctl.man	Wed Feb 02 18:30:54 2022 +0100
+++ b/man/prosodyctl.man	Sun Nov 28 23:07:35 2021 +0100
@@ -1,6 +1,6 @@
 .\" Automatically generated by Pandoc 2.17.0.1
 .\"
-.TH "PROSODYCTL" "1" "2017-09-02" "" ""
+.TH "PROSODYCTL" "1" "2022-02-02" "" ""
 .hy
 .SH NAME
 .PP
@@ -135,6 +135,12 @@
 .TP
 \f[B]\f[CB]--help\f[B]\f[R]
 Display help text for the specified command.
+.TP
+\f[B]\f[CB]--verbose\f[B]\f[R]
+Increase log level to show debug messages.
+.TP
+\f[B]\f[CB]--quiet\f[B]\f[R]
+Reduce log level to only show errors.
 .SH FILES
 .TP
 \f[B]\f[CB]/etc/prosody/prosody.cfg.lua\f[B]\f[R]
diff -r 202319a990e7 -r 73ecfe811526 man/prosodyctl.markdown
--- a/man/prosodyctl.markdown	Wed Feb 02 18:30:54 2022 +0100
+++ b/man/prosodyctl.markdown	Sun Nov 28 23:07:35 2021 +0100
@@ -2,7 +2,7 @@
 author:
 - Dwayne Bent <dbb.1@liqd.org>
 - Kim Alvefur
-date: 2017-09-02
+date: 2022-02-02
 section: 1
 title: PROSODYCTL
 ---
@@ -137,6 +137,12 @@
 `--help`
 :   Display help text for the specified command.
 
+`--verbose`
+:   Increase log level to show debug messages.
+
+`--quiet`
+:   Reduce log level to only show errors.
+
 # FILES
 
 `/etc/prosody/prosody.cfg.lua`
diff -r 202319a990e7 -r 73ecfe811526 util/startup.lua
--- a/util/startup.lua	Wed Feb 02 18:30:54 2022 +0100
+++ b/util/startup.lua	Sun Nov 28 23:07:35 2021 +0100
@@ -470,7 +470,13 @@
 function startup.force_console_logging()
 	original_logging_config = config.get("*", "log");
 	local log_level = os.getenv("PROSODYCTL_LOG_LEVEL");
-	if not log_level and prosody.opts.verbose then log_level = "debug"; end
+	if not log_level then
+		if prosody.opts.verbose then
+			log_level = "debug";
+		elseif prosody.opts.quiet then
+			log_level = "error";
+		end
+	end
 	config.set("*", "log", { { levels = { min = log_level or "info" }, to = "console" } });
 end