-
Notifications
You must be signed in to change notification settings - Fork 8.2k
feat(logger):color latency #4146
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
base: master
Are you sure you want to change the base?
Conversation
This will be a good addition, @wsyqn6! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new function, LatencyColor, to color-code log output based on request latency, helping developers quickly identify performance issues.
- Adds LatencyColor in logger.go to return ANSI color strings based on latency thresholds.
- Adjusts latency formatting and expected outputs in logger_test.go for both colored and non-colored log outputs.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
logger.go | Added LatencyColor function and modified latency truncation logic. |
logger_test.go | Updated test cases to match new latency truncation behavior and color assignment. |
Comments suppressed due to low confidence (1)
logger_test.go:320
- The helper variable name 'colorForLantency' appears to have a typo. Consider renaming it to 'colorForLatency' for clarity.
func TestColorForLatency(t *testing.T) {
@wsyqn6 Please rebase the master branch |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4146 +/- ##
==========================================
- Coverage 99.21% 98.88% -0.33%
==========================================
Files 42 44 +2
Lines 3182 3415 +233
==========================================
+ Hits 3157 3377 +220
- Misses 17 28 +11
- Partials 8 10 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
add colored latency to log output based on latency thresholds
Summary
This PR introduces a new function
LatencyColor
in the logger middleware of the Gin framework. This function assigns colors to log output based on the request latency, improving the readability and visual identification of performance bottlenecks.Motivation
The current logging system outputs latency as plain text, making it difficult to quickly identify performance issues at a glance. By adding color-coded latency information, developers can more easily distinguish between different latency levels, aiding in faster debugging and performance monitoring.
Changes