Skip to content

fix(middleware): Logger.Panic respects NoColor in DefaultLogFormatter#1125

Closed
happysnaker wants to merge 1 commit into
go-chi:masterfrom
happysnaker:fix-logger-panic-nocolor
Closed

fix(middleware): Logger.Panic respects NoColor in DefaultLogFormatter#1125
happysnaker wants to merge 1 commit into
go-chi:masterfrom
happysnaker:fix-logger-panic-nocolor

Conversation

@happysnaker

Copy link
Copy Markdown
Contributor

Summary

Fixes #1042

defaultLogEntry.Panic() was calling PrintPrettyStack(v) without passing the NoColor preference from DefaultLogFormatter, so panic output always used color regardless of the NoColor setting.

Changes

  • Adds optional useColor ...bool parameter to PrintPrettyStack (backward compatible, defaults to true)
  • Wires !l.NoColor from defaultLogEntry.Panic() through to PrintPrettyStack
  • The recoverer fallback path (no logEntry) still defaults to color, preserving existing behavior

Before

Panic stack traces ignored the NoColor: true setting on DefaultLogFormatter and always used ANSI colors.

After

When DefaultLogFormatter{NoColor: true} is used, panic stack traces are also printed without ANSI color codes.

defaultLogEntry.Panic() was calling PrintPrettyStack(v) without
passing the NoColor preference from DefaultLogFormatter, so panic
output always used color regardless of the NoColor setting.

This adds an optional useColor parameter to PrintPrettyStack to
preserve backward compatibility (defaults to true for the recoverer
fallback path), and wires !l.NoColor through from the logger's
Panic handler.

Fixes go-chi#1042
@VojtechVitek

Copy link
Copy Markdown
Contributor

Hi, #1042 was fixed via #1050 + #1131.

Thanks for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

middleware.Logger: defaultLogEntry.Panic() does not respect 'NoColor' of DefaultLogFormatter

2 participants