0.0.2 • Published 2 years ago

simple-log-function v0.0.2

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

Simple Log Function

A wrapper for loglevel which reduces the callable signature to a single function. It also prevents formatting logic execution if the log level isn't running, which most loggers do not concern themselves with.

const log = require('simple-log-function');
//log something with the default level
log('something');
//log something with a warning level
log('something', log.levels.WARN);
//log something with a warning and a data context
log('something', log.levels.WARN, context);

If you make your own log wrapper and want it to report a higher level:

log.depth = 2; //default is 1

If you want to output structured logs

log.mode = 'json';

If you want to output a custom header in text mode

log.header = (filename)=>{
    return `My custom header:`;
};

Testing

npm run test

runs the tests (mocha + chai)