-
Notifications
You must be signed in to change notification settings - Fork 153
Feature request: export LogLevel values as object #2780
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
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
Hey @adityamatt , thanks for raising the issue. What is the problem you are trying to solve? Can you share a bit more of context and info why it has to be enum and why it does not work with the current implementation? |
Hi @am29d , Our current use:
I propose rather than importing a type and defining a variable, if we can import the enum itself, it would simplify things
|
Thank you for providing the additional info, I think adding the log levels in a similar way to the one you describe is valid. As a project, we have been trying to move away from enums and instead use objects with the For this specific feature, I would like to see the following:
const LogLevel = {
DEBUG: 'DEBUG',
INFO: 'INFO',
WARN: 'WARN',
ERROR: 'ERROR',
SILENT: 'SILENT',
CRITICAL: 'CRITICAL',
} as const;
+ import { LogLevel } from '../constants.js';
- type LogLevelDebug = 'DEBUG';
- type LogLevelInfo = 'INFO';
- type LogLevelWarn = 'WARN';
- type LogLevelError = 'ERROR';
- type LogLevelSilent = 'SILENT';
- type LogLevelCritical = 'CRITICAL';
type LogLevel =
- | LogLevelDebug
- | Lowercase<LogLevelDebug>
- | LogLevelInfo
- | Lowercase<LogLevelInfo>
- | LogLevelWarn
- | Lowercase<LogLevelWarn>
- | LogLevelError
- | Lowercase<LogLevelError>
- | LogLevelSilent
- | Lowercase<LogLevelSilent>
- | LogLevelCritical
- | Lowercase<LogLevelCritical>;
+ | (typeof LogLevel)[keyof typeof LogLevel]
+ | Lowercase<(typeof LogLevel)[keyof typeof LogLevel]>;
I'm adding the |
@dreamorosi, Can I work on this issue? Also, from the code I've gone through in the tests, the log levels are set via string as of now. Something like this: const logger = new Logger({
logLevel: 'ERROR',
}); Would it make sense to update all of them to use newly defined const logger = new Logger({
logLevel: LogLevel.ERROR,
}); Or should I leave it be? |
Hi @marlapativ, absolutely you can! Regarding the tests, I'd like to leave some of them with string so that we can cover that case as well. Not all users will adopt this new method, but I don't see any issue in converting some to use it. I'll assign the issue to you, thank you for picking it up! |
I've raised a PR with the changes. I've also randomly updated some tests to use the new constant. Please merge if it looks good. Thanks. |
This issue is now closed. Please be mindful that future comments 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. |
Summary
LogLevel for the lambda is currently a type
Can we turn this into an enum and export it ?
Why is this needed?
We can import this enum and use it
Which area does this relate to?
Logger
Solution
Acknowledgment
Future readers
Please react with 👍 and your use case to help us understand customer demand.
The text was updated successfully, but these errors were encountered: