middleware: document printPrettyStack and harden NoColor panic test#1131
Merged
Conversation
defaultLogEntry.Panic called PrintPrettyStack unconditionally, which always used ANSI colour codes regardless of the DefaultLogFormatter's NoColor field. Add PrintPrettyStackColor(rvr, useColor bool) and thread the flag through prettyStack.parse. PrintPrettyStack now delegates to it with useColor=true so existing callers are unaffected. defaultLogEntry.Panic passes l.useColor so the panic output respects the same flag that controls the rest of the request log. Fixes #1042 Signed-off-by: alliasgher <alliasgher123@gmail.com>
Address review: only defaultLogEntry.Panic needs the useColor variant and it lives in the same package, so PrintPrettyStackColor does not need to be exported. Rename it to printPrettyStack; the public PrintPrettyStack API is unchanged. Signed-off-by: alliasgher <alliasgher123@gmail.com>
…-followup # Conflicts: # middleware/recoverer.go
Force IsTTY=true so cW would emit ANSI codes if useColor were true. Without it the assertion is a no-op on non-TTY runners (e.g. CI) and passes even against the buggy code path. Supersedes #1061. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
VojtechVitek
commented
Jul 5, 2026
VojtechVitek
left a comment
Contributor
Author
There was a problem hiding this comment.
LGTM.
Thank you @alliasgher for #1086.
This was referenced Jul 5, 2026
eleboucher
pushed a commit
to eleboucher/apoci
that referenced
this pull request
Jul 6, 2026
…#132) This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [github.com/go-chi/chi/v5](https://github.com/go-chi/chi) | `v5.3.0` → `v5.3.1` |  |  | --- ### Release Notes <details> <summary>go-chi/chi (github.com/go-chi/chi/v5)</summary> ### [`v5.3.1`](https://github.com/go-chi/chi/releases/tag/v5.3.1) [Compare Source](go-chi/chi@v5.3.0...v5.3.1) #### What's Changed - Honor Discard() in httpFancyWriter.ReadFrom by [@​DucMinhNe](https://github.com/DucMinhNe) in [#​1110](go-chi/chi#1110) - Tidy build directives by [@​JRaspass](https://github.com/JRaspass) in [#​1113](go-chi/chi#1113) - feat(middleware): add text/xml and application/xml to default compressible types by [@​VojtechVitek](https://github.com/VojtechVitek) in [#​1127](go-chi/chi#1127) - Fix defaultLogEntry.Panic not respecting NoColor setting by [@​doganarif](https://github.com/doganarif) in [#​1050](go-chi/chi#1050) - middleware: document printPrettyStack and harden NoColor panic test by [@​VojtechVitek](https://github.com/VojtechVitek) in [#​1131](go-chi/chi#1131) - feat(mux): support http QUERY method ietf rfc10008 by [@​VojtechVitek](https://github.com/VojtechVitek) in [#​1132](go-chi/chi#1132) - ci: pin GitHub Actions to full commit SHAs by [@​XananasX7](https://github.com/XananasX7) in [#​1116](go-chi/chi#1116) #### New Contributors - [@​DucMinhNe](https://github.com/DucMinhNe) made their first contribution in [#​1110](go-chi/chi#1110) - [@​doganarif](https://github.com/doganarif) made their first contribution in [#​1050](go-chi/chi#1050) - [@​XananasX7](https://github.com/XananasX7) made their first contribution in [#​1116](go-chi/chi#1116) **Full Changelog**: <go-chi/chi@v5.3.0...v5.3.1> </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMDEuMSIsInVwZGF0ZWRJblZlciI6IjQzLjEwMS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJ0eXBlL3BhdGNoIl19--> Reviewed-on: https://git.erwanleboucher.dev/eleboucher/apoci/pulls/132
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.
Follow-up to #1050, which fixed the core regression from #1042 (
defaultLogEntry.Panic()ignoredDefaultLogFormatter.NoColorbecausePrintPrettyStackhardcodesuseColor = true).This carries over the two remaining pieces from the other PRs on that issue, on top of the merged fix:
printPrettyStack, explaining theuseColorbehavior (from middleware: honour NoColor in defaultLogEntry.Panic #1086).TestRecovererNoColor: forceIsTTY = true(saved/restored) socWwould emit ANSI codes ifuseColorwere true. Without this the assertion is a no-op on non-TTY runners (e.g. CI) and passes even against the buggy code path — verified it fails when the bug is reintroduced. (from respect NoColor setting in defaultLogEntry.Panic() #1061)It preserves @alliasgher's original #1086 commits via a merge commit so authorship is retained.
Supersedes #1041, #1061, #1086.
Fixes #1042.