Fast, lightweight, minimalist logging framework for node.
$ npm install loggerify
const config = {
error: {
shouldLog: true,
exceptions: [],
logFunction: console.error
},
start: {
shouldLog: true,
exceptions: [],
logFunction: console.info
},
end: {
shouldLog: true,
exceptions: [],
logFunction: console.debug
},
}
const loggerifyMe = () => console.log('LOG ME NOW')
const loggerify = require('loggerify')
const loggerifiedFunction = loggerify(config)(loggerifyMe)
loggerifiedFunction()
// function loggerifyMe started with the arguments: {}
// LOG ME NOW
// function loggerifyMe ended successfully
- Logging as config
- Easy to use
- Wrapping Classes, objects, Functions and Arrow Functions at the same api
Logging can become preety tough and uncomftorable, while you add more and more functions the code becoming less readable and clean. instead of doing logger.info evrey second line of code, you can use a loggerify framework that will do that for you!
const config = {
error: {
shouldLog: true,
exceptions: [],
logFunction: console.error
},
start: {
shouldLog: true,
exceptions: [],
logFunction: console.info
},
end: {
shouldLog: true,
exceptions: [],
logFunction: console.debug
},
}
const loggerify = require('loggerify')
const configuredLoggerifier = loggerify(config)
class Dog {
constructor() {
}
bark() {
console.log('WOOF')
}
}
const loggeredDog = new (configuredLoggerifier(Dog));
loggeredDog.bark();
//function bark started with the arguments: {}
//WOOF
//function bark ended successfully
const dog = {
bark: () => {
console.log('WOOF')
}
}
const loggeredDog = configuredLoggerifier(dog);
loggeredDog.bark();
//function bark started with the arguments: {}
//WOOF
//function bark ended successfully
function bark () {
console.log('WOOF');
}
const loggeredBark = configuredLoggerifier(bark);
loggeredBark();
//function bark started with the arguments: {}
//WOOF
//function bark ended successfully
To run the test suite, first install the dependencies, then run npm test
:
$ npm install
$ npm test
- Custom log message by using function name as key
- Injecting custom log function to the function as parameter
Feel free to open issues and to share PR's :)
The original author of Loggerify is Daniel Sinai