Add Support for Customizing Log Elements While Keeping Log Levels Mandatory#20
Merged
warengonzaga merged 5 commits intodevfrom Jul 12, 2025
Merged
Conversation
Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for customizing log elements except log levels
Add Support for Customizing Log Elements While Keeping Log Levels Mandatory
Jul 1, 2025
Member
|
This is a live example of using Coding Agent from GitHub mobile. 🤝 |
Contributor
There was a problem hiding this comment.
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! |
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.
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.