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

Gitea serv, hooks, manager and the like should always display Fatals #13032

Merged

Conversation

zeripath
Copy link
Contributor

@zeripath zeripath commented Oct 5, 2020

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 art27@cantab.net

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 <art27@cantab.net>
@zeripath zeripath added the type/enhancement An improvement of existing functionality label Oct 5, 2020
@zeripath zeripath added this to the 1.13.0 milestone Oct 5, 2020
@zeripath
Copy link
Contributor Author

zeripath commented Oct 5, 2020

Although this is an enhancement I think it should be 1.13 as it will significantly help with debugging problems in future.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 5, 2020
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Oct 6, 2020
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Oct 7, 2020
@codecov-io
Copy link

Codecov Report

Merging #13032 into master will increase coverage by 0.01%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #13032      +/-   ##
==========================================
+ Coverage   42.61%   42.62%   +0.01%     
==========================================
  Files         672      672              
  Lines       73785    73787       +2     
==========================================
+ Hits        31445    31454       +9     
+ Misses      37247    37244       -3     
+ Partials     5093     5089       -4     
Impacted Files Coverage Δ
cmd/serv.go 2.72% <50.00%> (+0.65%) ⬆️
models/unit.go 46.57% <0.00%> (-2.74%) ⬇️
models/gpg_key.go 53.33% <0.00%> (-0.58%) ⬇️
modules/log/event.go 59.90% <0.00%> (+0.47%) ⬆️
services/pull/pull.go 41.27% <0.00%> (+0.49%) ⬆️
modules/avatar/avatar.go 54.76% <0.00%> (+4.76%) ⬆️
modules/log/console.go 66.66% <0.00%> (+13.88%) ⬆️
modules/util/timer.go 85.71% <0.00%> (+42.85%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4df6807...fa83d4d. Read the comment docs.

@techknowlogick techknowlogick merged commit 1bf40ca into go-gitea:master Oct 7, 2020
@zeripath zeripath deleted the always-log-fatals-in-manager-et-al branch October 7, 2020 21:16
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants