Skip to content

refactor: update logger types and default options for console and stdout plugins#9

Merged
tianyingchun merged 1 commit intohyperse-io:mainfrom
tclxshunquan-wang:feat/plugin
Jul 2, 2025
Merged

refactor: update logger types and default options for console and stdout plugins#9
tianyingchun merged 1 commit intohyperse-io:mainfrom
tclxshunquan-wang:feat/plugin

Conversation

@tclxshunquan-wang
Copy link
Contributor

@tclxshunquan-wang tclxshunquan-wang commented Jul 2, 2025

Summary by CodeRabbit

  • New Features

    • The Logger type is now exported for external use, allowing easier integration and type referencing.
  • Documentation

    • Updated documentation for logger plugins to clarify and correct default values for configuration options, reflecting that several formatting options now default to true.
  • Refactor

    • Updated default values for various logging options, so features like displaying level names, timestamps, and using a 24-hour clock are enabled by default.
    • Renamed and updated internal type declarations for improved clarity and consistency.

@coderabbitai
Copy link

coderabbitai bot commented Jul 2, 2025

Walkthrough

This update modifies default values for several logging options in both the console and stdout logger plugins, changing them from false to true in documentation and type definitions. It also renames and exports the Logger type in the core logger package, updates related type annotations, and adjusts import statements for clarity.

Changes

Files/Paths Change Summary
packages/logger-plugin-console/README.md, packages/logger-plugin-stdout/README.md Updated documentation to reflect new default values (true) for several boolean logging options.
packages/logger-plugin-console/src/types/type-options.ts, packages/logger-plugin-stdout/src/types/type-options.ts Changed default values for options (showLevelName, capitalizeLevelName, showTimestamp, use24HourClock) to true.
packages/logger/src/types/type-logger.ts Renamed BaseLogger interface to Logger, added default generics, updated method return types accordingly.
packages/logger/src/core/create-logger.ts Updated return type of createLogger and related import statements to use new Logger type.
packages/logger/src/core/logger.ts Adjusted import style and aliasing for Logger type; no functional changes.
.changeset/rotten-dragons-wish.md Added changeset describing the updates and their impact on exports and documentation.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Logger
    participant Plugin (Console/Stdout)

    User->>Logger: createLogger(options)
    Logger->>Plugin (Console/Stdout): Initialize with options (defaults now true)
    Plugin (Console/Stdout)-->>Logger: Ready to log with updated defaults
    User->>Logger: log(message)
    Logger->>Plugin (Console/Stdout): Format and output message (with level name, timestamp, etc.)
Loading

Poem

🐇
New logs now shine with names and time,
Level and date in every line.
The Logger type hops out to play—
More clear, more bright, in every way!
With defaults set to true anew,
Console and stdout, thank you!

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 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

@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: 12

🧹 Nitpick comments (1)
.changeset/rotten-dragons-wish.md (1)

7-11: Reconsider categorization of documentation changes.

The documentation improvements for default values might be better categorized as "📝 Documentation" or "✨ Features" rather than "🐛 Bug Fixes", since these appear to be enhancements rather than actual bug fixes.

Consider updating the changeset to:

-### 🐛 Bug Fixes
+### 📝 Documentation

- Improved documentation for default values in console plugin options.
- Improved documentation for default values in stdout plugin options.
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0fcc276 and 41382bc.

📒 Files selected for processing (8)
  • .changeset/rotten-dragons-wish.md (1 hunks)
  • packages/logger-plugin-console/README.md (3 hunks)
  • packages/logger-plugin-console/src/types/type-options.ts (3 hunks)
  • packages/logger-plugin-stdout/README.md (3 hunks)
  • packages/logger-plugin-stdout/src/types/type-options.ts (3 hunks)
  • packages/logger/src/core/create-logger.ts (2 hunks)
  • packages/logger/src/core/logger.ts (1 hunks)
  • packages/logger/src/types/type-logger.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
packages/logger/src/core/create-logger.ts (1)
packages/logger/src/types/type-logger.ts (1)
  • LoggerContext (5-8)
packages/logger/src/types/type-logger.ts (3)
packages/logger/src/core/logger.ts (1)
  • Logger (31-181)
packages/logger/src/types/type-message.ts (1)
  • LoggerMessage (8-8)
packages/logger/src/types/type-logger-plugin.ts (1)
  • LoggerPlugin (16-30)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: deploy (20.x)
🔇 Additional comments (7)
packages/logger/src/types/type-logger.ts (2)

15-17: LGTM! Good improvement to the interface design.

The renaming from BaseLogger to Logger provides clearer naming, and adding default generic parameters improves the developer experience by reducing boilerplate.


21-21: Action Required: Update lingering BaseLogger references to the new Logger interface

Several core files still reference the old BaseLogger name. Please update these to use Logger directly to keep the API consistent.

• packages/logger/src/core/logger.ts
– Change the implements clause and return-type Pick from BaseLogger<…> to Logger<…>.
Example:

- class LoggerImpl<Context, Message> implements BaseLogger<LoggerContext<Context>, Message> {
+ class LoggerImpl<Context, Message> implements Logger<LoggerContext<Context>, Message> {

- ): Pick<BaseLogger<LoggerContext<Context>, Message>, 'use' | 'build'> {
+ ): Pick<Logger<LoggerContext<Context>, Message>, 'use' | 'build'> {

• packages/logger/src/core/create-logger.ts
– Update the import and return type to use Logger instead of aliasing it as BaseLogger.
Example:

- import type { Logger as BaseLogger } from '../types/type-logger.js';
+ import type { Logger } from '../types/type-logger.js';

- ): BaseLogger<LoggerContext<Context>, Message> => {
+ ): Logger<LoggerContext<Context>, Message> => {

Please ensure all other occurrences are similarly updated.

Likely an incorrect or invalid review comment.

packages/logger/src/core/logger.ts (1)

13-16: LGTM! Clean approach to handle interface renaming.

The aliasing of Logger as BaseLogger maintains backward compatibility within the implementation while using the new interface name. The multi-line import formatting also improves readability.

packages/logger-plugin-console/README.md (1)

133-133: Documentation defaults confirmed
Verified that in packages/logger-plugin-console/src/constant.ts the defaults for:

  • showLevelName: true
  • capitalizeLevelName: true
  • showTimestamp: true
  • use24HourClock: true

all match the updated README.md. No further changes required.

packages/logger/src/core/create-logger.ts (2)

3-3: LGTM! Consistent with the interface renaming approach.

The import aliasing matches the pattern used in logger.ts and maintains compatibility during the interface transition.


16-16: Good improvement to return type specificity.

Adding the explicit return type annotation with proper generics improves type safety and makes the function signature more clear.

packages/logger-plugin-stdout/README.md (1)

151-151: Inconsistency with AI summary

The AI summary claims that showDate default was changed from false to true, but the documentation still shows the default as false. This indicates either an incomplete change or an inaccurate summary.

Likely an incorrect or invalid review comment.

```

- **Default**: `false`
- **Default**: `true`
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Breaking change: Default value modification

Changing the default from false to true for showLevelName is a breaking change that will alter log output for existing users who rely on the previous default behavior.

Consider:

  1. Documenting this as a breaking change in the changelog
  2. Bumping the major version number according to semantic versioning
  3. Providing a migration guide for users who want to maintain the previous behavior
🤖 Prompt for AI Agents
In packages/logger-plugin-stdout/README.md at line 133, the default value for
showLevelName has been changed from false to true, which is a breaking change.
Update the changelog to clearly document this breaking change, increment the
major version number in the package version to reflect the breaking change, and
add a migration guide explaining how users can revert to the previous behavior
if needed.

```

- **Default**: `false`
- **Default**: `true`
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Breaking change: Default value modification

Changing the default from false to true for use24HourClock is a breaking change that will modify timestamp format for existing users.

🤖 Prompt for AI Agents
In packages/logger-plugin-stdout/README.md at line 181, the default value for
use24HourClock is changed from false to true, which is a breaking change
affecting timestamp format for existing users. Revert the default value back to
false to maintain backward compatibility or clearly document this breaking
change in the README with a prominent warning so users are aware of the impact
before upgrading.

```

- **Default**: `false`
- **Default**: `true`
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Breaking change: Default value modification

Changing the default from false to true for showTimestamp is a breaking change that will add timestamps to logs by default, potentially affecting log parsing and display for existing users.

🤖 Prompt for AI Agents
In packages/logger-plugin-stdout/README.md at line 163, the default value for
showTimestamp is changed from false to true, which is a breaking change. Update
the documentation to clearly highlight this change as a breaking change and
explain its impact on existing users, including how it affects log output and
parsing. Consider adding a migration note or recommendation for users to
explicitly set showTimestamp if they want to maintain previous behavior.

If `true`, the level name will be capitalized.

- **Default**: `false`
- **Default**: `true`
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Breaking change: Default value modification

Changing the default from false to true for capitalizeLevelName is a breaking change that will affect log formatting for existing users.

🤖 Prompt for AI Agents
In packages/logger-plugin-stdout/README.md at line 139, the default value for
capitalizeLevelName was changed from false to true, which is a breaking change
affecting existing users' log formatting. Revert the default value back to false
to maintain backward compatibility and update the documentation accordingly to
reflect this default.

*
* `[ 1:27:55.33 PM ] pow`
* @default false
* @default true
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Breaking change in type definition

The JSDoc default value change from false to true for use24HourClock is consistent with documentation but represents a breaking change.

🤖 Prompt for AI Agents
In packages/logger-plugin-stdout/src/types/type-options.ts at line 82, the JSDoc
default value for use24HourClock has been changed from false to true, which is a
breaking change. Confirm this change is intentional and update any related
documentation or dependent code to reflect the new default of true to maintain
consistency and avoid unexpected behavior.

/**
* If true, the level name will be capitalized
* @default false
* @default true
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Breaking change in type definition

The JSDoc default value change from false to true for capitalizeLevelName is consistent with documentation but constitutes a breaking change.

🤖 Prompt for AI Agents
In packages/logger-plugin-stdout/src/types/type-options.ts at line 52, the JSDoc
default value for the `capitalizeLevelName` option has been changed from false
to true. This is a breaking change in the type definition. Confirm that this
change is intentional and update any related documentation or usage accordingly
to reflect the new default value of true.

* `[ FATAL ] WHAT WILL I DO?!`
*
* @default false
* @default true
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Breaking change: Consistent with stdout plugin

The JSDoc default value change from false to true for showLevelName maintains consistency with the stdout plugin but represents a breaking change.

🤖 Prompt for AI Agents
In packages/logger-plugin-console/src/types/type-options.ts at line 45, update
the JSDoc default value for the showLevelName option from false to true to
maintain consistency with the stdout plugin. This involves changing the @default
annotation to true to reflect the new default behavior, acknowledging this as a
breaking change.

/**
* If true, the level name will be capitalized
* @default false
* @default true
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Breaking change: Consistent with stdout plugin

The JSDoc default value change from false to true for capitalizeLevelName aligns with the stdout plugin changes but is a breaking change.

🤖 Prompt for AI Agents
In packages/logger-plugin-console/src/types/type-options.ts at line 51, update
the JSDoc default value for the capitalizeLevelName option from false to true to
align with the stdout plugin changes. This change is breaking, so ensure the
documentation clearly reflects the new default value as true.

*
* `[ 1:27:55.33 PM ] pow`
* @default false
* @default true
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Breaking change: Consistent with stdout plugin

The JSDoc default value change from false to true for use24HourClock ensures consistency across plugins but represents a breaking change.

🤖 Prompt for AI Agents
In packages/logger-plugin-console/src/types/type-options.ts at line 81, update
the JSDoc default value for the use24HourClock option from false to true to
align with the stdout plugin. This change ensures consistency across plugins but
is a breaking change, so verify that all related documentation and usage reflect
this new default.

*
* `[ 13:43:10.23 ] bar`
* @default false
* @default true
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Breaking change: Consistent with stdout plugin

The JSDoc default value change from false to true for showTimestamp maintains plugin consistency but constitutes a breaking change.

🤖 Prompt for AI Agents
In packages/logger-plugin-console/src/types/type-options.ts at line 67, update
the JSDoc default value for the showTimestamp option from false to true to align
with the stdout plugin. This change is a breaking change, so ensure the
documentation clearly reflects the new default value as true.

@tianyingchun tianyingchun merged commit 8e449b1 into hyperse-io:main Jul 2, 2025
4 checks passed
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.

2 participants