Skip to content

Commit 3e166bd

Browse files
zeripathlunny
authored andcommitted
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
1 parent 8b2f29c commit 3e166bd

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

cmd/hook.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Gitea or set your environment appropriately.`, "")
6565
}
6666
}
6767

68-
setup("hooks/pre-receive.log")
68+
setup("hooks/pre-receive.log", false)
6969

7070
// the environment setted on serv command
7171
isWiki := (os.Getenv(models.EnvRepoIsWiki) == "true")
@@ -131,7 +131,7 @@ Gitea or set your environment appropriately.`, "")
131131
}
132132
}
133133

134-
setup("hooks/update.log")
134+
setup("hooks/update.log", false)
135135

136136
return nil
137137
}
@@ -147,7 +147,7 @@ Gitea or set your environment appropriately.`, "")
147147
}
148148
}
149149

150-
setup("hooks/post-receive.log")
150+
setup("hooks/post-receive.log", false)
151151

152152
// the environment setted on serv command
153153
repoUser := os.Getenv(models.EnvRepoUsername)

cmd/keys.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func runKeys(c *cli.Context) error {
6262
return errors.New("No key type and content provided")
6363
}
6464

65-
setup("keys.log")
65+
setup("keys.log", false)
6666

6767
authorizedString, err := private.AuthorizedPublicKeyByContent(content)
6868
if err != nil {

cmd/serv.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,20 @@ var CmdServ = cli.Command{
4141
cli.BoolFlag{
4242
Name: "enable-pprof",
4343
},
44+
cli.BoolFlag{
45+
Name: "debug",
46+
},
4447
},
4548
}
4649

47-
func setup(logPath string) {
48-
_ = log.DelLogger("console")
50+
func setup(logPath string, debug bool) {
51+
if !debug {
52+
_ = log.DelLogger("console")
53+
}
4954
setting.NewContext()
55+
if debug {
56+
setting.ProdMode = false
57+
}
5058
}
5159

5260
func parseCmd(cmd string) (string, string) {
@@ -80,7 +88,7 @@ func fail(userMessage, logMessage string, args ...interface{}) {
8088

8189
func runServ(c *cli.Context) error {
8290
// FIXME: This needs to internationalised
83-
setup("serv.log")
91+
setup("serv.log", c.Bool("debug"))
8492

8593
if setting.SSH.Disabled {
8694
println("Gitea: SSH has been disabled")

0 commit comments

Comments
 (0)