chi icon indicating copy to clipboard operation
chi copied to clipboard

middleware: honour NoColor in defaultLogEntry.Panic

Open alliasgher opened this issue 7 months ago • 2 comments

Summary

defaultLogEntry.Panic called PrintPrettyStack unconditionally. That function hardcodes useColor := true, so the panic stack trace was always printed with ANSI colour codes even when DefaultLogFormatter.NoColor was set to true.

Fix

  • Add PrintPrettyStackColor(rvr interface{}, useColor bool) that accepts an explicit colour flag.
  • Refactor PrintPrettyStack to delegate to it with useColor=true — no change for existing callers.
  • Refactor prettyStack.parse to receive useColor rather than hardcode it.
  • defaultLogEntry.Panic now passes l.useColor, which is derived from DefaultLogFormatter.NoColor.

Fixes #1042

alliasgher avatar Apr 13 '26 22:04 alliasgher

Needs a rebase.

VojtechVitek avatar Jun 14 '26 10:06 VojtechVitek

Rebased onto master (01faae4). The wrap_writer fix that was in this branch already landed upstream, so this is now just the NoColor panic change.

alliasgher avatar Jun 14 '26 11:06 alliasgher

Merged via https://github.com/go-chi/chi/pull/1131. Thank you!

VojtechVitek avatar Jul 05 '26 15:07 VojtechVitek