Conversation
|
This will be a good addition, @wsyqn6! |
There was a problem hiding this comment.
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 Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4146 +/- ##
==========================================
- Coverage 99.21% 98.81% -0.41%
==========================================
Files 42 44 +2
Lines 3182 3456 +274
==========================================
+ Hits 3157 3415 +258
- Misses 17 30 +13
- Partials 8 11 +3
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:
|
|
Please rebase the master branch |
I've rebased this PR onto the latest |
add colored latency to log output based on latency thresholds
Summary
This PR introduces a new function
LatencyColorin 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