From 3e166bd0550eceade275023616a02a8bf12d58c9 Mon Sep 17 00:00:00 2001 From: zeripath Date: Wed, 25 Dec 2019 15:44:57 +0000 Subject: [PATCH] Add debug option to serv to help debug problems (#9492) * Add debug option to serv to help debug problems * fixup! Add debug option to serv to help debug problems --- cmd/hook.go | 6 +++--- cmd/keys.go | 2 +- cmd/serv.go | 14 +++++++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/cmd/hook.go b/cmd/hook.go index 9f547362da..7e45304841 100644 --- a/cmd/hook.go +++ b/cmd/hook.go @@ -65,7 +65,7 @@ Gitea or set your environment appropriately.`, "") } } - setup("hooks/pre-receive.log") + setup("hooks/pre-receive.log", false) // the environment setted on serv command isWiki := (os.Getenv(models.EnvRepoIsWiki) == "true") @@ -131,7 +131,7 @@ Gitea or set your environment appropriately.`, "") } } - setup("hooks/update.log") + setup("hooks/update.log", false) return nil } @@ -147,7 +147,7 @@ Gitea or set your environment appropriately.`, "") } } - setup("hooks/post-receive.log") + setup("hooks/post-receive.log", false) // the environment setted on serv command repoUser := os.Getenv(models.EnvRepoUsername) diff --git a/cmd/keys.go b/cmd/keys.go index c0818fd2d2..7456815cd7 100644 --- a/cmd/keys.go +++ b/cmd/keys.go @@ -62,7 +62,7 @@ func runKeys(c *cli.Context) error { return errors.New("No key type and content provided") } - setup("keys.log") + setup("keys.log", false) authorizedString, err := private.AuthorizedPublicKeyByContent(content) if err != nil { diff --git a/cmd/serv.go b/cmd/serv.go index 1ac6b21e53..8ffe9b3a4f 100644 --- a/cmd/serv.go +++ b/cmd/serv.go @@ -41,12 +41,20 @@ var CmdServ = cli.Command{ cli.BoolFlag{ Name: "enable-pprof", }, + cli.BoolFlag{ + Name: "debug", + }, }, } -func setup(logPath string) { - _ = log.DelLogger("console") +func setup(logPath string, debug bool) { + if !debug { + _ = log.DelLogger("console") + } setting.NewContext() + if debug { + setting.ProdMode = false + } } func parseCmd(cmd string) (string, string) { @@ -80,7 +88,7 @@ func fail(userMessage, logMessage string, args ...interface{}) { func runServ(c *cli.Context) error { // FIXME: This needs to internationalised - setup("serv.log") + setup("serv.log", c.Bool("debug")) if setting.SSH.Disabled { println("Gitea: SSH has been disabled") -- 2.39.5