fix: redirect early CLI console logger to stderr#37507
Merged
Merged
Conversation
Contributor
|
I think it needs some comments, otherwise some days later maybe some people would change it back to stdout again. |
Contributor
Author
|
IMHO it's just about being consistent. There are already log-messages on STDERR when doing a dump. Only these deprecation warnings go to stdout. But I get it, some comments would not hurt. |
When running `gitea dump` with output routed to stdout (--file -),
deprecation warnings from loadAvatarsFrom were written to stdout,
corrupting the archive stream.
Root cause: PrepareConsoleLoggerLevel (called in app.Before) sets up
a console logger via SetConsoleLogger, which used WriterConsoleOption{}
defaulting Stderr to false (i.e. stdout). This logger is installed before
the dump subcommand can redirect logging to stderr in runDump.
Fix: use WriterConsoleOption{Stderr: true} in SetConsoleLogger so all
early CLI diagnostic output goes to stderr from the start. This is correct
for all subcommands — diagnostic/log output should never pollute stdout.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
7b3c2e1 to
85cd94a
Compare
Contributor
Author
|
It may be a bit too verbose but it clearly describes why it needs to be STDERR. |
wxiaoguang
reviewed
May 2, 2026
Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
wxiaoguang
reviewed
May 2, 2026
Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
wxiaoguang
approved these changes
May 2, 2026
Contributor
Author
|
Thanks @wxiaoguang for looking into this. It actually broke my backup because of the output to STDOUT. I fixed it by removing the deprecated fields from the config. |
Contributor
|
Added more comments. More complicated than it looks |
f499450 to
dbb3540
Compare
bircni
approved these changes
May 2, 2026
silverwind
added a commit
to McMichalK/gitea
that referenced
this pull request
May 5, 2026
* origin/main: (49 commits) ci: lint PR titles with commitlint (go-gitea#37498) Make ServeSetHeaders default to download attachment if filename exists (go-gitea#37552) fix(actions): validate workflow param to prevent 500 error (go-gitea#37546) Fix various problems (go-gitea#37547) docs: fix 4 typos in CHANGELOG.md (go-gitea#37549) [skip ci] Updated translations via Crowdin chore(deps): update action dependencies (go-gitea#37540) fix: Fix `nolyfill` for renovate (go-gitea#37537) Refactor pull request view (7) (go-gitea#37524) Update go js py dependencies (go-gitea#37525) Don't unblock run-level-concurrency-blocked runs in the resolver (go-gitea#37461) Refactor pull request view (6) (go-gitea#37522) Refactor pull request view (5) (go-gitea#37517) fix: persist mirror repository metadata (go-gitea#37519) fix(packages): use file names for generic web downloads (go-gitea#37514) fix: merge autodetect can't close other PRs but only the last one when multiple PRs are pushed at once (go-gitea#37512) Fix update branch protection order (go-gitea#37508) Refactor "flex-list" to "flex-divided-list" (go-gitea#37505) fix: redirect early CLI console logger to stderr (go-gitea#37507) Fix mCaptcha broken after Vite migration (go-gitea#37492) ... # Conflicts: # templates/repo/diff/box.tmpl
zjjhot
added a commit
to zjjhot/gitea
that referenced
this pull request
May 6, 2026
* main: (36 commits) refactor(deps): migrate from `nektos/act` fork to `gitea/runner` (go-gitea#37557) ci: lint PR titles with commitlint (go-gitea#37498) Make ServeSetHeaders default to download attachment if filename exists (go-gitea#37552) fix(actions): validate workflow param to prevent 500 error (go-gitea#37546) Fix various problems (go-gitea#37547) docs: fix 4 typos in CHANGELOG.md (go-gitea#37549) [skip ci] Updated translations via Crowdin chore(deps): update action dependencies (go-gitea#37540) fix: Fix `nolyfill` for renovate (go-gitea#37537) Refactor pull request view (7) (go-gitea#37524) Update go js py dependencies (go-gitea#37525) Don't unblock run-level-concurrency-blocked runs in the resolver (go-gitea#37461) Refactor pull request view (6) (go-gitea#37522) Refactor pull request view (5) (go-gitea#37517) fix: persist mirror repository metadata (go-gitea#37519) fix(packages): use file names for generic web downloads (go-gitea#37514) fix: merge autodetect can't close other PRs but only the last one when multiple PRs are pushed at once (go-gitea#37512) Fix update branch protection order (go-gitea#37508) Refactor "flex-list" to "flex-divided-list" (go-gitea#37505) fix: redirect early CLI console logger to stderr (go-gitea#37507) ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When running
gitea dumpwith output routed to stdout (--file -), deprecation warnings from loadAvatarsFrom were written to stdout, corrupting the archive stream.Root cause: PrepareConsoleLoggerLevel (called in app.Before) sets up a console logger via SetConsoleLogger, which used WriterConsoleOption{} defaulting Stderr to false (i.e. stdout). This logger is installed before the dump subcommand can redirect logging to stderr in runDump.
Fix: use WriterConsoleOption{Stderr: true} in SetConsoleLogger so all early CLI diagnostic output goes to stderr from the start. This is correct for all subcommands — diagnostic/log output should never pollute stdout.