Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Narrow LogLevel type to not allow arbitrary strings #1309

Closed
1 of 2 tasks
danrivett opened this issue Feb 17, 2023 · 3 comments · Fixed by #1313
Closed
1 of 2 tasks

Feature request: Narrow LogLevel type to not allow arbitrary strings #1309

danrivett opened this issue Feb 17, 2023 · 3 comments · Fixed by #1313
Assignees
Labels
completed This item is complete and has been merged/shipped feature-request This item refers to a feature request for an existing or new utility logger This item relates to the Logger Utility

Comments

@danrivett
Copy link

Use case

Raising this ticket after the discussion in #1198.

Currently the LogLevel type allows for any string to be used, but at runtime it validates the value and if it doesn't match one of the valid log levels (as per isValidLogLevel()) it silently ignores the log level passed in and uses the default.

This has two problems:

  1. The issue isn't caught at compile time
  2. The passed in log level is silently ignored which may not be detected.

Regarding 1. above, the following typo currently compiles. It would be better for the typo to be detected at compile time:

const logger = new Logger({ logLevel: 'DEBG' });

Solution/User Experience

Narrow the LogLevel type definition, removing the | string part.

Alternative solutions

No response

Acknowledgment

@danrivett danrivett added triage This item has not been triaged by a maintainer, please wait feature-request This item refers to a feature request for an existing or new utility labels Feb 17, 2023
@dreamorosi dreamorosi added logger This item relates to the Logger Utility confirmed The scope is clear, ready for implementation and removed triage This item has not been triaged by a maintainer, please wait labels Feb 17, 2023
@dreamorosi dreamorosi self-assigned this Feb 17, 2023
@dreamorosi
Copy link
Contributor

Hi Dan, thank you for opening the issue.

I think this is a valuable addition to the logger, I'll be working on this.

@github-actions
Copy link
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@github-actions github-actions bot added the pending-release This item has been merged and will be released soon label Feb 27, 2023
@dreamorosi dreamorosi added completed This item is complete and has been merged/shipped and removed confirmed The scope is clear, ready for implementation pending-release This item has been merged and will be released soon labels Feb 27, 2023
@dreamorosi
Copy link
Contributor

This change was released as part of the latest v1.6.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed This item is complete and has been merged/shipped feature-request This item refers to a feature request for an existing or new utility logger This item relates to the Logger Utility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants