2.0.1 • Published 5 years ago
loggerify v2.0.1
loggerify
Fast, lightweight, minimalist logging framework for node.
Installation
$ npm install loggerifyQuick Start
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 successfullyFeatures
- Logging as config
- Easy to use
- Wrapping Classes, objects, Functions and Arrow Functions at the same api
Motivation
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!
Examples
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)Loggerify Class
class Dog {
constructor() {
}
bark() {
console.log('WOOF')
}
}
const loggeredDog = new (configuredLoggerifier(Dog));
loggeredDog.bark();
//function bark started with the arguments: {}
//WOOF
//function bark ended successfullyLoggerify Object
const dog = {
bark: () => {
console.log('WOOF')
}
}
const loggeredDog = configuredLoggerifier(dog);
loggeredDog.bark();
//function bark started with the arguments: {}
//WOOF
//function bark ended successfullyLoggerify Function
function bark () {
console.log('WOOF');
}
const loggeredBark = configuredLoggerifier(bark);
loggeredBark();
//function bark started with the arguments: {}
//WOOF
//function bark ended successfullyTests
To run the test suite, first install the dependencies, then run npm test:
$ npm install
$ npm testWhat's next?
- Custom log message by using function name as key
- Injecting custom log function to the function as parameter
Contributing
Feel free to open issues and to share PR's :)
People
The original author of Loggerify is Daniel Sinai