refactor: update logger types and default options for console and stdout plugins#9
Conversation
WalkthroughThis update modifies default values for several logging options in both the console and stdout logger plugins, changing them from Changes
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.)
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
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
📒 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
BaseLoggertoLoggerprovides clearer naming, and adding default generic parameters improves the developer experience by reducing boilerplate.
21-21: Action Required: Update lingeringBaseLoggerreferences to the newLoggerinterfaceSeveral core files still reference the old
BaseLoggername. Please update these to useLoggerdirectly to keep the API consistent.• packages/logger/src/core/logger.ts
– Change theimplementsclause and return-typePickfromBaseLogger<…>toLogger<…>.
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 useLoggerinstead of aliasing it asBaseLogger.
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 BaseLoggermaintains 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 inpackages/logger-plugin-console/src/constant.tsthe defaults for:
showLevelName: truecapitalizeLevelName: trueshowTimestamp: trueuse24HourClock: trueall 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.tsand 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 summaryThe AI summary claims that
showDatedefault was changed fromfalsetotrue, but the documentation still shows the default asfalse. This indicates either an incomplete change or an inaccurate summary.Likely an incorrect or invalid review comment.
| ``` | ||
|
|
||
| - **Default**: `false` | ||
| - **Default**: `true` |
There was a problem hiding this comment.
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:
- Documenting this as a breaking change in the changelog
- Bumping the major version number according to semantic versioning
- 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` |
There was a problem hiding this comment.
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` |
There was a problem hiding this comment.
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` |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
Summary by CodeRabbit
New Features
Loggertype is now exported for external use, allowing easier integration and type referencing.Documentation
true.Refactor