Implement centralized structured logging service #115
+187
−8
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.
Overview
This PR introduces a production-ready structured logging system that replaces scattered console statements throughout the codebase with a centralized, environment-aware logging service.
Problem
Currently, the codebase has console statements scattered across 15+ files, which:
Solution
New Structured Logger (
src/lib/logger.ts)A centralized logging utility featuring:
debug,info,warn,errorUpdated Files
src/lib/api-utils.tsconsole.errorwithlogger.errorin error handlersrc/app/employer/documents/components/AgentChatInterface.tsxconsole.log/errorwith appropriate logger methodslogger.debug(dev-only)src/app/employer/documents/fetchWithRetries.tsconsole.warnwithlogger.warnUsage Example
Benefits
✅ Better Debugging: Structured logs with context make issues easier to trace
✅ Production-Ready: Automatic log level filtering based on environment
✅ Maintainability: Easy to add log aggregation services (Datadog, Sentry, etc.)
✅ Consistency: Uniform format across the entire application
✅ Performance: Production builds only log warnings and errors
Testing
Manually tested in development environment:
Migration Path
This PR updates the most critical files. Future PRs can gradually replace remaining console statements across:
Breaking Changes
None - This is a purely additive change with no impact on existing functionality.
Looking forward to feedback! Happy to make any adjustments.