Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug option to serv to help debug problems #9492

Merged
merged 2 commits into from
Dec 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -131,7 +131,7 @@ Gitea or set your environment appropriately.`, "")
}
}

setup("hooks/update.log")
setup("hooks/update.log", false)

return nil
}
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 11 additions & 3 deletions cmd/serv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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")
Expand Down