-
-
Notifications
You must be signed in to change notification settings - Fork 1
Add Support for Customizing Log Elements While Keeping Log Levels Mandatory #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Support for Customizing Log Elements While Keeping Log Levels Mandatory #20
Conversation
Co-authored-by: warengonzaga <[email protected]>
Co-authored-by: warengonzaga <[email protected]>
|
This is a live example of using Coding Agent from GitHub mobile. 🤝 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements customizable log elements functionality that allows users to control which components are included in log output while maintaining log levels as mandatory elements. The feature adds backward-compatible format configuration options for timestamps while preserving default behavior.
- Add
LogFormatConfiginterface with optionalincludeIsoTimestampandincludeLocalTimeproperties - Enhance MessageFormatter to conditionally include timestamps based on configuration
- Update Logger core to pass format configuration through all logging methods
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types/index.ts | Adds LogFormatConfig interface and extends LoggerConfig with format property |
| src/logger/core.ts | Updates all logging methods to retrieve and pass format configuration to MessageFormatter |
| src/index.ts | Exports the new LogFormatConfig type for public API |
| src/formatter/message-formatter.ts | Implements conditional timestamp formatting logic with backward compatibility |
| src/tests/format-customization.test.ts | Comprehensive test suite covering all format combinations and edge cases |
| README.md | Documents the new log element customization feature with examples |
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
Summary
This PR implements customizable log elements functionality, allowing users to control which components are included in log output while maintaining log levels as mandatory elements. This addresses the need for flexible log formatting in different deployment environments while preserving essential debugging information.
Key Features
✅ Customizable Timestamp Elements: Users can now control ISO timestamp and local time inclusion
✅ Mandatory Log Levels: Log levels always remain visible regardless of configuration (as required)
✅ Backward Compatible: Default behavior unchanged - existing code works without modifications
✅ Type Safe: Full TypeScript support with new
LogFormatConfiginterface✅ Comprehensive Testing: 17 new tests covering all scenarios (272 total tests passing)
Usage Examples
Implementation Details
Changes Made
New Types (
src/types/index.ts):LogFormatConfiginterface withincludeIsoTimestampandincludeLocalTimeoptionsLoggerConfiginterface with optionalformatpropertyEnhanced MessageFormatter (
src/formatter/message-formatter.ts):format()method to accept optionalLogFormatConfigparameterformatSystemMessage()for consistencyUpdated Logger Core (
src/logger/core.ts):Comprehensive Testing (
src/__tests__/format-customization.test.ts):Documentation (
README.md):Technical Approach
Use Cases
Testing
All existing tests continue to pass, ensuring no breaking changes:
Breaking Changes
None - This is a fully backward-compatible addition. Existing code continues to work without any modifications.
Related Issues
Closes #[issue-number] - Add Support for Customizing Log Elements
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
api.example.com/usr/local/bin/node /home/REDACTED/work/log-engine/log-engine/node_modules/jest-worker/build/workers/processChild.js(dns block)downloads.snyk.io/usr/local/bin/node wrapper_dist/bootstrap.js exec(dns block)o30291.ingest.sentry.io/usr/local/bin/node wrapper_dist/bootstrap.js exec(dns block)static.snyk.io/usr/local/bin/node wrapper_dist/bootstrap.js exec(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.