Open winston0410 opened 1 year ago
Hi, thanks for the issue! 👋
Wondering, would something like this work for you?
// file: logger.ts
import { defaultReporter, _diary } from 'diary';
import { compare } from 'diary/utils';
export const diary = (name: string) => _diary(name, event => {
if (compare(event.level, process.env.LOG_LEVEL) return defaultReporter(event);
});
alternatively, leave it with me! Ill have to have a think about a possible api.
Hey thanks for coming back, and I think that would work. But I notice that defaultReporter
is not exported from diary
, only default_reporter
?
And yes it would be better if there is a dedicate API that only requires user to change a property to affect which log level to use
Is this feature in relation to a problem?
I want to use an env variable to filter log by level. For example, when I use LOG_LEVEL=error, I dont want to see log in level debug.
Describe the solution you'd like
Provide a setup function like
enable
, so it does not read env var initially, but user can pass env var to itAlternative
No response
Additional context
No response