feat(logger):color latency
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
- Add LatencyColor Function: Implement a function that returns a color string based on the request latency.
This will be a good addition, @wsyqn6!
@wsyqn6 Please rebase the master branch
Codecov Report
:x: Patch coverage is 85.71429% with 4 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 98.81%. Comparing base (3dc1cd6) to head (8eb54b8).
:warning: Report is 184 commits behind head on master.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| logger.go | 85.71% | 4 Missing :warning: |
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
| Flag | Coverage Δ | |
|---|---|---|
? |
||
| --ldflags="-checklinkname=0" -tags sonic | 98.74% <85.71%> (?) |
|
| -tags go_json | 98.74% <85.71%> (?) |
|
| -tags nomsgpack | 98.79% <85.71%> (?) |
|
| go-1.18 | ? |
|
| go-1.19 | ? |
|
| go-1.20 | ? |
|
| go-1.21 | ? |
|
| go-1.23 | 98.81% <85.71%> (?) |
|
| go-1.24 | 98.81% <85.71%> (?) |
|
| macos-latest | 98.81% <85.71%> (-0.41%) |
:arrow_down: |
| ubuntu-latest | 98.81% <85.71%> (-0.41%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Please rebase the master branch
Please rebase the master branch
I've rebased this PR onto the latest master branch. The changes are now up to date and ready for review. Thanks for your patience!