Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging colour for < 200 should be white? #3728

Closed
maggie44 opened this issue Sep 14, 2023 · 1 comment · Fixed by #3741
Closed

Logging colour for < 200 should be white? #3728

maggie44 opened this issue Sep 14, 2023 · 1 comment · Fixed by #3741

Comments

@maggie44
Copy link

Description

When the logger logs a response with a status code < 200 it is coloured red:

gin/logger.go

Lines 81 to 95 in c2ba8f1

// StatusCodeColor is the ANSI color for appropriately logging http status code to a terminal.
func (p *LogFormatterParams) StatusCodeColor() string {
code := p.StatusCode
switch {
case code >= http.StatusOK && code < http.StatusMultipleChoices:
return green
case code >= http.StatusMultipleChoices && code < http.StatusBadRequest:
return white
case code >= http.StatusBadRequest && code < http.StatusInternalServerError:
return yellow
default:
return red
}
}

Http status codes under 200 are informative rather than errors. Would it be better for < 200 to be white?

I notice this with web socket switching: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/101

@viralparmarme
Copy link
Contributor

@maggie44 I've raised a PR for this. Please review and approve it: #3741

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 a pull request may close this issue.

2 participants