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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: Make level more intuitive #2414

Open
opadfnezig opened this issue Feb 20, 2024 · 0 comments
Open

[Feature Request]: Make level more intuitive #2414

opadfnezig opened this issue Feb 20, 2024 · 0 comments
Labels
Feature Request Request for new functionality to support use cases not already covered Needs Investigation

Comments

@opadfnezig
Copy link

馃攷 Search Terms

level

The vision

I think it really would be nice to receive some kind of warning into console, if you didn't setup level propery. Like level is not provided. using default(3)
or when trying to log something wich is higer than max log level set in logger receive warning in console, like line 21>logger.log('debug', 'Debug log message'); 'trying to log message with level higer than logger's level' (just once, so you will know it)

Use case

I've played a bit with custom levels in winston, and found out that there is param called level in logger wich ruins code in some cases.

It's not mandatory, so I don't expect it to actually influence max log level if not used, but it is set to level 3 by default. I've spent couple of days to figure out why my custom levels didn't work (first thought it's transport issue).

This code woun't work, unless level is provided. No error, no warning, you just won't receive logs.

const winston = require('winston');

const customLevels = {
    levels: {
        critical: 0,
        error: 1,
        warn: 2,
        info: 3,
        debug: 4,
    }
};

const logger = winston.createLogger({
    //level: 'debug',
    transports: [
        new winston.transports.Console(),
    ],
    levels: customLevels.levels
});

logger.log('debug', 'Debug log message');

I think this feature should simplify working with library, make it more intuitive, especially for new customers.

Additional information

No response

@opadfnezig opadfnezig added Feature Request Request for new functionality to support use cases not already covered Needs Investigation labels Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Request for new functionality to support use cases not already covered Needs Investigation
Projects
None yet
Development

No branches or pull requests

1 participant