"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
Re: got{web,}d: handle multiple -v
To:
gameoftrees@openbsd.org
Date:
Sat, 25 May 2024 19:38:26 +0200

Download raw body.

Thread
On 2024/05/25 17:51:42 +0200, Omar Polo <op@omarpolo.com> wrote:
> This is a slight deviation from the "usual" log.c, but it's a warranted
> one.  With this, only log_warn*() and fatal*() are logged by default.
> One -v enables log_info() and -vv enables log_debug().
> 
> Enjoy no more fcgi dumping in gotwebd -v :)
> 
> no changes to the man pages because they already states that multiple -v
> increases the verbosity.
> 
> ok?

attached an old diff by mistake; here's one which also changes the -v
handling in gotwebd to resemble gotd.

diff /home/op/w/got
commit - da30c05a101318828faf559ea66bc6ce1f638bc8
path + /home/op/w/got
blob - e6c663ff42ff32e1e3f11d9873f7735b9f1eb98e
file + gotwebd/gotwebd.c
--- gotwebd/gotwebd.c
+++ gotwebd/gotwebd.c
@@ -210,7 +210,7 @@ gotwebd_sighdlr(int sig, short event, void *arg)
 static int
 spawn_socket_process(struct gotwebd *env, const char *argv0, int n)
 {
-	const char	*argv[5];
+	const char	*argv[6];
 	int		 argc = 0;
 	int		 p[2];
 	pid_t		 pid;
@@ -240,8 +240,10 @@ spawn_socket_process(struct gotwebd *env, const char *
 	argv[argc++] = "-S";
 	if (env->gotwebd_debug)
 		argv[argc++] = "-d";
-	if (env->gotwebd_verbose)
+	if (env->gotwebd_verbose > 0)
 		argv[argc++] = "-v";
+	if (env->gotwebd_verbose > 1)
+		argv[argc++] = "-v";
 	argv[argc] = NULL;
 
 	if (p[0] != GOTWEBD_SOCK_FILENO) {
@@ -307,7 +309,8 @@ main(int argc, char **argv)
 			server_proc = 1;
 			break;
 		case 'v':
-			env->gotwebd_verbose++;
+			if (env->gotwebd_verbose < 3)
+				env->gotwebd_verbose++;
 			break;
 		default:
 			usage();
blob - 14609f4960c9b8d6580769df8494ba5c3d482139
file + lib/log.c
--- lib/log.c
+++ lib/log.c
@@ -135,9 +135,11 @@ log_info(const char *emsg, ...)
 {
 	va_list ap;
 
-	va_start(ap, emsg);
-	vlog(LOG_INFO, emsg, ap);
-	va_end(ap);
+	if (verbose > 0) {
+		va_start(ap, emsg);
+		vlog(LOG_INFO, emsg, ap);
+		va_end(ap);
+	}
 }
 
 void
@@ -145,7 +147,7 @@ log_debug(const char *emsg, ...)
 {
 	va_list ap;
 
-	if (verbose) {
+	if (verbose > 1) {
 		va_start(ap, emsg);
 		vlog(LOG_DEBUG, emsg, ap);
 		va_end(ap);