Open
Conversation
Contributor
Reviewer's GuideThis PR adds a new console logging feature by introducing a configuration flag for console output, updating middleware and the Wrap function to pass and act on the new flag, implementing a colored logger utility, and providing an example demonstrating usage. Sequence Diagram: Request Handling with New Console LoggingsequenceDiagram
actor User as "HTTP Client"
participant GVW as "govisual.Wrap (wrap.go)"
participant MW as "middleware.Wrap (middleware.go)"
participant Store as "store.Store"
participant Logger as "utils.LogRequest (logger.go)"
participant Console
User->>+GVW: HTTP Request
GVW->>GVW: Load Config (incl. LogRequestToConsole)
GVW->>+MW: Wrap(handler, store, ..., config.LogRequestToConsole, pathMatcher)
Note right of MW: Request processing begins
MW-->>MW: Capture request details (method, path, etc.)
MW-->>MW: Execute wrapped HTTP handler
MW-->>MW: Capture response details (status code, etc.)
MW-->>MW: Create reqLog: model.RequestLog
alt If config.LogRequestToConsole is true
MW->>+Logger: LogRequest(reqLog)
Logger->>Console: Print formatted log message
Logger-->>-MW: Return
end
MW->>+Store: Add(reqLog)
Store-->>-MW: Return
MW-->>-GVW: HTTP Response
GVW-->>-User: HTTP Response
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey @erancihan - I've reviewed your changes - here's some feedback:
- The example in test/example.go uses r.PathValue and {param} routes with http.ServeMux, which isn’t supported—either switch to a router library or implement path param parsing.
- Using time.Since(reqLog.Timestamp) for console logging may not accurately reflect handler duration; capture the start time before invoking the handler to compute precise execution time.
- ANSI color codes may not render correctly on all platforms (e.g., Windows terminals); consider adding detection or a flag to disable color output.
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟡 Testing: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Collaborator
Author
|
this MR does too many things and is very troublesome to rebase on it's own. will be splitting it to bits and pushing it that way |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Summary by Sourcery
Introduce optional console logging for HTTP requests in the middleware, enabling colorized request output to the console.
New Features:
Enhancements: