chi
chi copied to clipboard
middleware: honour NoColor in defaultLogEntry.Panic
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
PrintPrettyStackto delegate to it withuseColor=true— no change for existing callers. - Refactor
prettyStack.parseto receiveuseColorrather than hardcode it. defaultLogEntry.Panicnow passesl.useColor, which is derived fromDefaultLogFormatter.NoColor.
Fixes #1042
Needs a rebase.
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.
Merged via https://github.com/go-chi/chi/pull/1131. Thank you!