Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .changeset/rotten-dragons-wish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"@hyperse/logger-plugin-console": patch
"@hyperse/logger-plugin-stdout": patch
"@hyperse/logger": patch
---

### 🐛 Bug Fixes

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

### 🏷️ Types

- Exported the `Logger` type for external usage.


8 changes: 4 additions & 4 deletions packages/logger-plugin-console/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ If `true`, each message will have the level name attached to it.
[ VERBOSE ] Verbose information
```

- **Default**: `false`
- **Default**: `true`

### `capitalizeLevelName?: boolean`

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

- **Default**: `false`
- **Default**: `true`

### `showDate?: boolean`

Expand All @@ -160,7 +160,7 @@ If `true`, each message will have a timestamp attached to it.
[ 13:43:10.23 ] bar
```

- **Default**: `false`
- **Default**: `true`

### `use24HourClock?: boolean`

Expand All @@ -178,7 +178,7 @@ If `true`, timestamps will use 24-hour format instead of 12-hour format.
[ 1:27:55.33 PM ] pow
```

- **Default**: `false`
- **Default**: `true`

### `showArrow?: boolean`

Expand Down
8 changes: 4 additions & 4 deletions packages/logger-plugin-console/src/types/type-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ export type ConsoleOptions = {
*
* `[ 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.

*/
showLevelName?: boolean;

/**
* 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.

*/
capitalizeLevelName?: boolean;

Expand All @@ -64,7 +64,7 @@ export type ConsoleOptions = {
* If true, each message logged to the terminal will have a timestamp corresponding to the exact time the message was logged.
*
* `[ 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.

*/
showTimestamp?: boolean;

Expand All @@ -78,7 +78,7 @@ export type ConsoleOptions = {
* ### **12 hour clock:**
*
* `[ 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.

*/
use24HourClock?: boolean;

Expand Down
8 changes: 4 additions & 4 deletions packages/logger-plugin-stdout/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ If `true`, each message will have the level name attached to it.
[ VERBOSE ] Verbose information
```

- **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.


### `capitalizeLevelName?: boolean`

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.


### `showDate?: boolean`

Expand All @@ -160,7 +160,7 @@ If `true`, each message will have a timestamp attached to it.
[ 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: 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.


### `use24HourClock?: boolean`

Expand All @@ -178,7 +178,7 @@ If `true`, timestamps will use 24-hour format instead of 12-hour format.
[ 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: 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.


### `showArrow?: boolean`

Expand Down
8 changes: 4 additions & 4 deletions packages/logger-plugin-stdout/src/types/type-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ export type StdoutOptions = {
*
* `[ 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 in type definition

The JSDoc default value change from false to true for showLevelName aligns with the README documentation but represents a breaking change in the API contract.

🤖 Prompt for AI Agents
In packages/logger-plugin-stdout/src/types/type-options.ts at line 46, the JSDoc
default value for the showLevelName option has been changed from false to true,
which is a breaking change in the API contract. Ensure this change is
intentional and update any related documentation or usage examples accordingly
to reflect the new default behavior.

*/
showLevelName?: boolean;

/**
* 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.

*/
capitalizeLevelName?: boolean;

Expand All @@ -65,7 +65,7 @@ export type StdoutOptions = {
* If true, each message logged to the terminal will have a timestamp corresponding to the exact time the message was logged.
*
* `[ 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 in type definition

The JSDoc default value change from false to true for showTimestamp matches the README but is a breaking change.

🤖 Prompt for AI Agents
In packages/logger-plugin-stdout/src/types/type-options.ts at line 68, the JSDoc
default value for showTimestamp 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.

*/
showTimestamp?: boolean;

Expand All @@ -79,7 +79,7 @@ export type StdoutOptions = {
* ### **12 hour clock:**
*
* `[ 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.

*/
use24HourClock?: boolean;

Expand Down
3 changes: 2 additions & 1 deletion packages/logger/src/core/create-logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { DeepPartial, LoggerMessage } from '../types/index.js';
import type { LoggerContext } from '../types/type-logger.js';
import type { Logger as BaseLogger } from '../types/type-logger.js';
import { Logger } from './logger.js';

export const createLogger = <
Expand All @@ -12,6 +13,6 @@ export const createLogger = <
| Promise<DeepPartial<LoggerContext<Context>>>;
errorHandling?: (error: Error) => void;
}
) => {
): BaseLogger<LoggerContext<Context>, Message> => {
return new Logger<Context, Message>(options);
};
5 changes: 4 additions & 1 deletion packages/logger/src/core/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import { LogLevel } from '../constant/log-level.js';
import { executeFunction } from '../helpers/helper-execute-fun.js';
import { mergeOptions } from '../helpers/helper-merge-options.js';
import { simpleDeepClone } from '../helpers/helper-simple-deep-clone.js';
import type { BaseLogger, LoggerContext } from '../types/type-logger.js';
import type {
Logger as BaseLogger,
LoggerContext,
} from '../types/type-logger.js';
import type { LoggerPlugin } from '../types/type-logger-plugin.js';
import type { LoggerMessage } from '../types/type-message.js';
import type { DeepPartial } from '../types/type-partial-deep.js';
Expand Down
10 changes: 5 additions & 5 deletions packages/logger/src/types/type-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ export type LoggerPluginList<
Message extends LoggerMessage,
> = Array<LoggerPlugin<Context, Message>>;

export interface BaseLogger<
Context extends LoggerContext,
Message extends LoggerMessage,
export interface Logger<
Context extends LoggerContext = LoggerContext,
Message extends LoggerMessage = LoggerMessage,
> {
use: (
...plugins: LoggerPlugin<Context, Message>[]
) => Pick<BaseLogger<Context, Message>, 'use' | 'build'>;
) => Pick<Logger<Context, Message>, 'use' | 'build'>;
build: () => Pick<
BaseLogger<Context, Message>,
Logger<Context, Message>,
'debug' | 'info' | 'warn' | 'error' | 'verbose'
>;
debug: (message: Message) => void;
Expand Down