Skip to content

khrome/simple-log-function

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

A simple, performant, logging solution

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published