npm.io
0.0.2 • Published 4 years ago

simple-log-function

Licence
Version
0.0.2
Deps
1
Size
8 kB
Vulns
0
Weekly
0

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)