From 731a3ce2cb632bd4c3b90a7c0a0ca1c2ae4c24be Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Mon, 1 Jan 2024 14:55:22 +0100 Subject: [PATCH] feat: Allow disabling debug logging --- cmd/rio/main.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/rio/main.go b/cmd/rio/main.go index edd5c60..08eec7e 100644 --- a/cmd/rio/main.go +++ b/cmd/rio/main.go @@ -78,7 +78,6 @@ func Handler(pagesDomain, giteaUrl string, giteaClient *gitea.Client) http.Handl } func runServer(ctx *cli.Context) error { - log.SetLevel(log.DebugLevel) giteaUrl := ctx.String("gitea-url") domain := ctx.String("pages-domain") certsFile := ctx.String("certs-file") @@ -89,6 +88,13 @@ func runServer(ctx *cli.Context) error { acmePort := ctx.String("acme-port") acmeDisable := ctx.Bool("acme-disable") + // Init Logging + if ctx.Bool("debug") { + log.SetLevel(log.DebugLevel) + } else { + log.SetLevel(log.InfoLevel) + } + // Setup the Gitea stuff httpClient := http.Client{Timeout: 10 * time.Second} client, err := gitea.NewClient( @@ -237,6 +243,11 @@ func main() { Usage: "Whether to disable automatic ACME certificates", EnvVars: []string{"ACME_DISABLE"}, }, + &cli.BoolFlag{ + Name: "debug", + Usage: "Whether to enable debug logging", + EnvVars: []string{"DEBUG_ENABLE"}, + }, }, }