Skip to content

Commit 1bf40ca

Browse files
authored
Gitea serv, hooks, manager and the like should always display Fatals (#13032)
The gitea cmd/serv.go setup function deletes the console logger to prevent stdout interference with commands. However, the problem is that it then calls setting.NewContext which may cause an exit with log.Fatal - which will then not be shown. Now, log.Fatal is so disastrous that the interference that logging causes is wanted. However, we can avoid stdout interference by emitting on stderr. This PR forces the creation of a console logger on stderr listening on Fatal for these commands. Most commands have a `--debug` option now that will print more reasons too - however, defaulting to give the log for Fatal seems reasonable. Signed-off-by: Andrew Thornton <[email protected]>
1 parent 4df6807 commit 1bf40ca

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

cmd/serv.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ func setup(logPath string, debug bool) {
5454
_ = log.DelLogger("console")
5555
if debug {
5656
_ = log.NewLogger(1000, "console", "console", `{"level":"trace","stacktracelevel":"NONE","stderr":true}`)
57+
} else {
58+
_ = log.NewLogger(1000, "console", "console", `{"level":"fatal","stacktracelevel":"NONE","stderr":true}`)
5759
}
5860
setting.NewContext()
5961
if debug {

0 commit comments

Comments
 (0)