kevbook.node-logger
v1.0.7
Published
All purpose logger for nodeJS apps
Downloads
4
Readme
node-logger
All purpose logger for nodeJS apps.
- Makes errors pretty & mostly readable - gives error, file, line number etc. Uses stack-trace module
- Outputs memory stats - heapUsed, heapTotal, rss, etc
- Logs uncaughtException
- Adds a gloabl
logger.debug
,logger.info
,logger.error
Usage
// A global logger is created
require('node-logger')({
level: 'info' // Default = debug,
prodMode: true // Default = false,
exitOnUncaught: false, // Default = false
mongodb: true // Default = false
});
// Global Log Levels: { debug, info, error }
// Exmaples
logger.info('Some Log Message');
logger.info({ a: 1, b: 2 });
logger.info('Some Log Message', 'Some Other Message');
logger.info('Some Log Message', { a: 1, b: 2 });
logger.info('Some Log Message', { a: 1, b: 2 }, 'Some other message');
Notes
- If prodMode = true - the error is a JSON string, its nicely formatted on the terminal
- If mongodb = true - exposes a logger.mongodb function that can be used as a mongoDB logger with the node-mongodb-native module