ll

log-leveler

calculate log levels from a set of enabled/disabled loggers

Showing:

Popularity

Downloads/wk

0

GitHub Stars

1

Maintenance

Last Commit

6yrs ago

Contributors

1

Package

Dependencies

0

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

log-leveler

If you're not particularly fond of log levels and would rather just toggle different loggers on and off, but utilize a logger library that requires levels, this library may be helpful.

Install

npm install log-leveler

Useage

Given a set of enabled/disabled loggers, log-leveler calculates your logger levels, and enabled level for you to feed into your favorite level-friendly logger.

var leveler = require('log-leveler');

var config = leveler({
    info: true,
    debug: false,
    warn: true,
    error: false,
    brad: true,
    gecko: false
});

console.log(config.levels);
// { info: 0, warn: 1, brad: 2, debug: 3, error: 4, gecko: 5 }

console.log(config.level);
// brad

Enabled loggers will be sorted to the lower indexed levels, and your level will be set to the last enabled logger.

Example of using it with winston:

var config = leveler({
    info: true,
    debug: false,
    warn: true,
    error: true
});

app.log = new (winston.Logger)({
    levels: config.levels,
    transports: [
        new (winston.transports.Console)({
            level: config.level
        })
    ]
});

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial