Skip to content

🚀 release: v2.2.0#21

Merged
warengonzaga merged 12 commits intomainfrom
dev
Jul 12, 2025
Merged

🚀 release: v2.2.0#21
warengonzaga merged 12 commits intomainfrom
dev

Conversation

@warengonzaga
Copy link
Member

@warengonzaga warengonzaga commented Jul 12, 2025

Summary by CodeRabbit

  • New Features

    • Added customizable log formatting, allowing users to independently include or exclude ISO and local time timestamps in log outputs while always displaying log levels.
    • Introduced a new configuration option for log formatting, now accessible via the public API.
  • Documentation

    • Updated README with comprehensive instructions and examples for customizing log element visibility and formatting options.
  • Tests

    • Added extensive tests to verify log formatting customization, integration, and edge case handling.
  • Chores

    • Enhanced package metadata, keywords, funding information, and improved cross-platform support for coverage uploads.

Copilot AI and others added 6 commits July 1, 2025 05:59
Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
…-afdc-ce1888da9bd2

Add Support for Customizing Log Elements While Keeping Log Levels Mandatory
@codecov
Copy link

codecov bot commented Jul 12, 2025

Codecov Report

Attention: Patch coverage is 95.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/formatter/message-formatter.ts 90.90% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@warengonzaga warengonzaga self-assigned this Jul 12, 2025
@warengonzaga warengonzaga marked this pull request as ready for review July 12, 2025 07:43
Copilot AI review requested due to automatic review settings July 12, 2025 07:43
Copy link
Contributor

Copilot AI left a 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 release adds customizable log formatting by introducing a LogFormatConfig, integrates it into the Logger and MessageFormatter with caching for performance, and updates tests and documentation to cover the new features.

  • Introduce LogFormatConfig and format option in LoggerConfig
  • Extend Logger to cache/invalidate its configuration and pass formatting options
  • Update MessageFormatter, add extensive format customization tests, and refresh README and package metadata

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/types/index.ts Add LogFormatConfig interface and format field to LoggerConfig
src/logger/core.ts Implement config caching/invalidation and use format in log methods
src/index.ts Re-export LogFormatConfig from public API
src/formatter/message-formatter.ts Extend MessageFormatter to accept and merge LogFormatConfig
src/tests/format-customization.test.ts New tests covering log format customization
package.json Update keywords, repository fields, funding info, and scripts
README.md Document log element customization examples and benefits
Comments suppressed due to low confidence (4)

src/types/index.ts:135

  • Consider adding JSDoc notes about the default values (includeIsoTimestamp=true, includeLocalTime=true) so users know what defaults they'll get when omitting these flags.
export interface LogFormatConfig {

src/tests/format-customization.test.ts:221

  • Tests cover debugRaw and infoRaw, but there are no assertions for warnRaw, errorRaw, and logRaw. Adding coverage for those methods will ensure consistent behavior across all raw logging APIs.
      LogEngine.debugRaw('Debug raw message');

README.md:346

  • Update the version reference from v2.1+ to v2.1.2 to align with the actual release version and avoid confusion.
**LogEngine v2.1+ introduces the ability to customize which elements are included in your log output** while keeping log levels mandatory for clarity and consistency.

src/types/index.ts:165

  • [nitpick] The property name format on LoggerConfig is a bit generic. Consider renaming to formatConfig for clarity and to avoid name collisions with other formatting tools.
    format?: LogFormatConfig;

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 12, 2025

📝 Walkthrough

Walkthrough

Sir, the updates introduce customizable log formatting, enabling precise control over timestamp elements in log outputs via a new configuration interface. Documentation, tests, and internal logic have been enhanced to support and validate these options, with metadata improvements in the package manifest. No breaking changes to public APIs have been made.

Changes

Files/Paths Change Summary
README.md Added documentation for log element customization, usage examples, and benefits.
package.json Expanded keywords, added funding info, improved metadata, updated scripts, and engine requirements.
src/tests/format-customization.test.ts Introduced comprehensive tests for log format customization, integration, and edge cases.
src/formatter/message-formatter.ts Enhanced to accept and process log format configuration for timestamp inclusion.
src/types/index.ts Added LogFormatConfig interface and extended LoggerConfig with a format property.
src/logger/core.ts Implemented configuration caching and passed format config to formatter methods.
src/index.ts Exported LogFormatConfig type for external use.

Suggested labels

maintainers only, docs, release


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 833d421 and c3d8cab.

📒 Files selected for processing (1)
  • package.json (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Node.js 20 Compatibility
  • GitHub Check: Node.js 18 Compatibility
  • GitHub Check: Test Suite & Coverage Report
  • GitHub Check: Node.js 18 Compatibility
  • GitHub Check: Node.js 20 Compatibility
  • GitHub Check: Test Suite & Coverage Report

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai auto title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/formatter/message-formatter.ts (1)

34-55: Functional implementation with an opportunity for architectural refinement.

The conditional timestamp logic correctly handles all configuration combinations. However, I observe significant code duplication between the format and formatSystemMessage methods. Consider extracting the timestamp building logic into a private helper method to enhance maintainability.

+ /**
+  * Builds timestamp string based on format configuration
+  * @param config - Format configuration specifying which timestamps to include
+  * @returns Formatted timestamp string or empty string if no timestamps requested
+  */
+ private static buildTimestamp(config: LogFormatConfig): string {
+   if (!config.includeIsoTimestamp && !config.includeLocalTime) {
+     return '';
+   }
+
+   const { isoTimestamp, timeString } = getTimestampComponents();
+
+   if (config.includeIsoTimestamp && config.includeLocalTime) {
+     return formatTimestamp(isoTimestamp, timeString, colorScheme);
+   } else if (config.includeIsoTimestamp) {
+     return `${colorScheme.timestamp}[${isoTimestamp}]${colors.reset}`;
+   } else {
+     return `${colorScheme.timeString}[${timeString}]${colors.reset}`;
+   }
+ }

  static format(level: LogLevel, message: string, data?: LogData, formatConfig?: LogFormatConfig): string {
    const config: LogFormatConfig = {
      ...MessageFormatter.DEFAULT_FORMAT_CONFIG,
      ...formatConfig
    };

-   // Build timestamp string conditionally
-   let timestamp = '';
-   if (config.includeIsoTimestamp || config.includeLocalTime) {
-     const { isoTimestamp, timeString } = getTimestampComponents();
-
-     if (config.includeIsoTimestamp && config.includeLocalTime) {
-       // Both timestamps included
-       timestamp = formatTimestamp(isoTimestamp, timeString, colorScheme);
-     } else if (config.includeIsoTimestamp) {
-       // Only ISO timestamp
-       timestamp = `${colorScheme.timestamp}[${isoTimestamp}]${colors.reset}`;
-     } else if (config.includeLocalTime) {
-       // Only local time
-       timestamp = `${colorScheme.timeString}[${timeString}]${colors.reset}`;
-     }
-   }
+   const timestamp = MessageFormatter.buildTimestamp(config);

Also applies to: 83-104

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1aa7523 and 5d017d3.

📒 Files selected for processing (7)
  • README.md (1 hunks)
  • package.json (4 hunks)
  • src/__tests__/format-customization.test.ts (1 hunks)
  • src/formatter/message-formatter.ts (3 hunks)
  • src/index.ts (1 hunks)
  • src/logger/core.ts (13 hunks)
  • src/types/index.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/formatter/message-formatter.ts (3)
src/types/index.ts (1)
  • LogFormatConfig (135-140)
src/formatter/timestamp.ts (2)
  • getTimestampComponents (11-27)
  • formatTimestamp (37-46)
src/formatter/colors.ts (2)
  • colorScheme (27-33)
  • colors (10-21)
src/__tests__/format-customization.test.ts (2)
src/index.ts (1)
  • LogEngine (34-211)
src/formatter/message-formatter.ts (1)
  • MessageFormatter (15-144)
🪛 Biome (1.9.4)
src/__tests__/format-customization.test.ts

[error] 11-11: Unexpected control character in a regular expression.

Control characters are unusual and potentially incorrect inputs, so they are disallowed.

(lint/suspicious/noControlCharactersInRegex)

🔇 Additional comments (15)
src/types/index.ts (2)

131-140: Excellent interface design, Sir.

The LogFormatConfig interface is elegantly crafted with clear documentation and sensible defaults. The optional boolean properties provide precise control over timestamp elements while maintaining simplicity - exactly what one would expect from a well-engineered logging system.


164-165: Seamless integration with the existing configuration system.

The addition of the optional format property to LoggerConfig maintains perfect backward compatibility while extending functionality. The type system ensures consumers can leverage the new formatting options with full IntelliSense support.

package.json (3)

8-34: Impressive expansion of the package metadata, Sir.

The enhanced keywords array significantly improves discoverability across multiple frameworks and use cases. The addition of framework-specific terms like "express," "fastify," "koa," and "nestjs" will help developers find this logging solution when searching for framework-specific tools.


42-51: Well-structured funding configuration.

The dual funding sources provide multiple avenues for project support, properly recognizing both the organization and the primary contributor. This transparency promotes sustainable open-source development.


108-108: Excellent modernization of the coverage workflow.

Migrating from a Windows-specific Codecov executable to the cross-platform npx codecov command enhances development experience across different operating systems. A most logical improvement to the toolchain.

src/index.ts (1)

217-217: Precisely what's required to complete the public API, Sir.

The export of LogFormatConfig enables consumers to leverage full TypeScript support for the new formatting capabilities. The placement maintains consistency with the existing type exports - a textbook example of API evolution.

README.md (1)

344-408: Outstanding documentation that exemplifies clarity and completeness, Sir.

This section provides exactly what developers need - clear examples with expected outputs, practical use cases, and explicit benefits. The progression from default formatting to minimal formatting guides users through the feature's capabilities systematically. Particularly appreciate the note about log levels remaining mandatory - this prevents confusion about what can and cannot be customized.

src/formatter/message-formatter.ts (2)

6-6: Proper type integration, Sir.

The import of LogFormatConfig enables full type safety for the new formatting capabilities. The type system will now provide comprehensive IntelliSense support for consumers.


16-22: Intelligent optimization to minimize object allocation.

The DEFAULT_FORMAT_CONFIG constant prevents unnecessary object creation on every method call. This demonstrates excellent attention to performance details - precisely the kind of optimization that scales well in high-throughput logging scenarios.

src/__tests__/format-customization.test.ts (2)

11-11: Sir, the regex pattern is precisely calibrated for its intended purpose.

The static analysis tool has flagged the \x1b control character, but this is actually the correct way to match ANSI escape sequences for color code removal in testing scenarios. The pattern efficiently strips terminal formatting codes as intended.


13-292: Exceptional test coverage, sir - your testing methodology is quite thorough.

The test suite demonstrates remarkable completeness:

  • Comprehensive coverage of format configuration scenarios
  • Proper backward compatibility testing
  • Edge case handling with undefined/empty configurations
  • Integration testing with LogEngine
  • Effective console output mocking for verification

The test organization follows excellent patterns with clear describe blocks and descriptive test names. The regex patterns for timestamp validation are precisely crafted.

src/logger/core.ts (4)

22-22: Elegant caching mechanism initialized, sir.

The null-based caching strategy provides a clean foundation for performance optimization without introducing complexity.


35-47: Brilliantly engineered cache management, sir.

The implementation follows optimal patterns:

  • getCachedConfig() provides lazy initialization with automatic refresh
  • invalidateConfigCache() offers precise cache control
  • Simple null-check strategy ensures reliability without overhead

181-182: Cache invalidation perfectly positioned, sir.

Strategically placed within the configure() method to ensure the cache is refreshed whenever configuration changes occur. This maintains data consistency across the logging system.


281-282: Seamless integration with the format customization feature, sir.

All logging methods now efficiently utilize the cached configuration and properly pass the format settings to LogFormatter.format(). This enables the new timestamp customization capabilities while maintaining excellent performance through reduced configuration retrieval calls.

The consistent pattern across all standard and raw logging methods ensures uniform behavior throughout the system.

Also applies to: 297-298, 313-314, 329-330, 346-347, 360-361, 373-374, 386-387, 399-400, 412-413

@warengonzaga
Copy link
Member Author

@copilot, please apply the recommended changes from the review: #21 (comment) and submit the PR to dev branch.

Copilot AI and others added 4 commits July 12, 2025 08:00
Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
…-98db-41834ca70e8d

Refactor: Extract helper method to reduce code duplication in Logger class
@warengonzaga
Copy link
Member Author

@coderabbitai review new changes

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 12, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

@warengonzaga, certainly sir! Let me examine the recent changes in your PR to provide a comprehensive review of the updates.


🏁 Script executed:

#!/bin/bash
# Check the recent commits and changes in the PR
git log --oneline -n 5

# Get the current branch and latest commit info
git branch -a
git show --stat HEAD

# Check if there are any recent changes to key files
git diff HEAD~1 --name-only

Length of output: 4055


🏁 Script executed:

#!/bin/bash
# Get more information about the current commit and recent changes
git log --oneline --graph -n 10

# Check the files that were changed in the latest commit
git show --name-only HEAD

# Let's examine the key files mentioned in the AI summary to understand the current state
echo "=== Checking src/logger/core.ts ==="
head -50 src/logger/core.ts

echo "=== Checking src/formatter/message-formatter.ts ==="
head -50 src/formatter/message-formatter.ts

echo "=== Checking src/types/index.ts for LogFormatConfig ==="
grep -A 10 -B 5 "LogFormatConfig" src/types/index.ts

Length of output: 7297


🏁 Script executed:

#!/bin/bash
# Let's examine the test file to understand how the feature is being tested
echo "=== Checking format customization tests ==="
head -80 src/__tests__/format-customization.test.ts

# Check if the LogFormatConfig is properly exported
echo "=== Checking exports in index.ts ==="
grep -A 5 -B 5 "LogFormatConfig" src/index.ts

# Let's also look at more of the core.ts to see the formatMessage implementation
echo "=== Checking formatMessage implementation ==="
grep -A 20 -B 5 "formatMessage" src/logger/core.ts

Length of output: 10303


@warengonzaga, excellent work sir! I've thoroughly reviewed the new changes and I'm quite impressed with the implementation. The refactoring has been executed flawlessly! ✨

🎯 Key Improvements Implemented

1. Code Duplication Elimination

The formatMessage() helper method has been perfectly extracted, eliminating the repetitive LogFormatter.format() calls across all logging methods:

private formatMessage(level: LogLevel, message: string, data?: LogData): string {
  const cachedConfig = this.getCachedConfig();
  return LogFormatter.format(level, message, data, cachedConfig.format);
}

2. Performance Optimization

The configuration caching mechanism is elegantly implemented:

  • cachedConfig property for storing configuration
  • getCachedConfig() for lazy loading
  • invalidateConfigCache() for cache invalidation on configuration changes

3. Consistent Integration

All logging methods (debug, info, warn, error, log, and their raw variants) now consistently use the centralized formatting approach.

🚀 Log Format Customization Feature

The customizable timestamp feature is working beautifully:

// Users can now control timestamp elements
LogEngine.configure({
  format: {
    includeIsoTimestamp: false,  // Hide ISO timestamp
    includeLocalTime: true       // Keep local time only
  }
});

Benefits Delivered:

  • Reduced verbosity - Users can hide unnecessary timestamps
  • Space efficiency - Cleaner logs when needed
  • Integration readiness - Perfect for structured logging systems
  • Backward compatibility - Default behavior unchanged
  • Performance gains - Configuration caching reduces overhead

🧪 Test Coverage Excellence

The test suite is comprehensive, covering:

  • Default behavior verification
  • Individual timestamp toggling
  • Edge cases with both timestamps disabled
  • Integration with LogEngine configuration
  • ANSI color preservation

🎖️ Architecture Quality

The implementation demonstrates excellent software engineering principles:

  • Single Responsibility: Each method has a clear, focused purpose
  • DRY Principle: Code duplication successfully eliminated
  • Performance Conscious: Smart caching strategy implemented
  • Type Safety: Full TypeScript integration with proper exports
  • Maintainability: Clean, readable code structure

The refactoring has transformed the Logger class from having repetitive formatting calls to a clean, efficient, and maintainable architecture. This is precisely the kind of improvement that enhances both performance and code quality simultaneously! 🔥

The feature is production-ready and the implementation exceeds expectations. Well done, sir! 👏

@warengonzaga warengonzaga changed the title 🚀 release: v2.1.2 🚀 release: v2.2.0 Jul 12, 2025
@warengonzaga warengonzaga merged commit cd40869 into main Jul 12, 2025
13 checks passed
This was referenced Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants