Add colored logging with charmbracelet/log - Fixes #144#189
Closed
Eshaan-byte wants to merge 9 commits into
Closed
Add colored logging with charmbracelet/log - Fixes #144#189Eshaan-byte wants to merge 9 commits into
Eshaan-byte wants to merge 9 commits into
Conversation
- Add getTimeSinceLastSync utility function to format relative time - Store last sync timestamp in localStorage per user - Display "Last updated X ago" below Sync button - Auto-refresh display every 10 seconds - Add comprehensive tests for time formatting Fixes CCExtractor#124
- Add hashKey() function to create hash of key+email - Update localStorage to use hashed keys instead of plain email - Prevents storing email addresses directly in localStorage - Add comprehensive tests for hashKey function (5 new tests) - All 29 tests passing Addresses review feedback from @its-me-abhishek
Implements CCExtractor#144 - Colored Logging & Improved Backend Logs Features: - Integrated charmbracelet/log for structured, colored logging - Color-coded log levels (Info=Green, Warn=Yellow, Error=Red, Debug=Gray) - Configurable log levels via LOG_LEVEL environment variable - Structured logging with key-value pairs for better traceability - Timestamps on all log entries - Auto-initialization in tests for seamless testing Changes: - Added new logger utility package (backend/utils/logger/) - Updated all log statements across main.go, controllers, and utils - Replaced plain log.Println/Printf with structured logger calls - Added LOG_LEVEL to .env configuration - Updated go.mod with charmbracelet/log dependency Log Levels: - debug: Detailed diagnostic information - info: General informational messages (default) - warn: Warning messages for potential issues - error: Error events that need attention - fatal: Critical errors causing shutdown Usage examples: - Simple: logger.Info("Server started") - Structured: logger.Info("User authenticated", "email", user.Email, "uuid", uuid) - Formatted: logger.Errorf("Failed to connect: %v", err) Benefits: - Easier debugging with visual color coding - Better production monitoring with structured fields - Improved developer experience with clean, readable output - Quick issue identification with timestamps and context
| @@ -0,0 +1,129 @@ | |||
| package logger | |||
Collaborator
There was a problem hiding this comment.
why'd we want another dependency? i think we could've used github.com/charmbracelet/log directly
- Removed utils/logger wrapper package as suggested in review - Added global Logger variable in main package with InitLogger() - Created logger.go in controllers and utils/tw packages for local Logger instances - Logger instances auto-initialize in init() for test compatibility - Maintained all existing log functionality with structured logging - All tests pass successfully
Contributor
Author
|
@its-me-abhishek , Done I used charmbracelet now. Plese check whenever you are free.Thank you. |
Collaborator
its-me-abhishek
left a comment
There was a problem hiding this comment.
The PR seems to be a breaking change, and does not really follow the project structure. Closing this for now
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.
Description
Implements colored, structured logging using charmbracelet/log to improve backend debugging, monitoring, and developer experience.
Changes
charmbracelet/logfor colored, structured loggingbackend/utils/logger/log.Println/Printfstatements with structured logger callsLOG_LEVELenvironment variablego.moddependenciesFeatures
Color-Coded Log Levels: