feat: Allow disabling debug logging

This commit is contained in:
PapaTutuWawa 2024-01-01 14:55:22 +01:00
parent e390ca6047
commit 731a3ce2cb

View File

@ -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"},
},
},
}