muffin-logger-express
This library allows you to quickly integrate logger in your node.js application. The library can be used with express as middleware. It structures your everyday logs. Each log is created with respect to current date. Logs are categorized in different folders (by default) as follows :
- server-logs
- default-logs
- error-logs
Once the server runs - log folders will contain log files. eg: default-logs/2018-3-25-log. Each log line is saved as an object in the log file. Which can be usefull in purpose to generate reports if required. eg:
You can also:
- Integrate Rollbar for error notifications.
Installation
$ npm install muffin-logger-express
Plugins
muffin-logger-express is currently extended with the following optional node library for error notification.
Library | NPM Link |
---|---|
Rollbar | https://www.npmjs.com/package/rollbar |
Usage
const express = ;const app = ;const Muffin = ;app; // express application // logs server requests app; // logs errors in error file app; // logs prints in default log file app;
To configure muffin-logger-express for custom folder structure and fields.
const Muffin = ;Muffin;app; // express application
Integrating Rollbar
const Muffin = ;Muffin;app; // express application
default logs
By default- default logs (print statements) will be logged on non production environment. To make it log on production environment you will need to set log priority parameter. If log priority is more then 0 then it will be logged on all environment. req.log(< object >, < priority >);
app;
Example app
For an example we have created an app file - start.js
$ node start.js
Development
Want to contribute? Great! muffin-logger-express is an open source with a https://github.com/prajyotpro/muffin-logger-express on GitHub.
To help make sure we are building the right things in the right order, we ask that you create issues and pull requests or simply upvote or comment on existing issues or pull requests.
Todos
- Write MORE Tests
- Integrate more server error notifiers by email ( similar to rollbar ).
- Integrating gulp
- Integrating travis
License
MIT