A simple Node.js logger. Very closely attached to a request.
With Type Labels
Without Type Labels
It also supports a minimal profiling functionality to calculate the time from request start to end.
Installation
Download node at nodejs.org and install it, if you haven't already.
npm install reqlog --save
Usage
var reqlog = ;reqlog;reqlog;reqlog;reqlog;
Complete example
var http = ;var reqlog = ; reqlog; var errorData = database: status: 'crashed' ; reqlog;reqlog;reqlog;reqlog; var server = http;server;server;
API
init(typeLabels)
Type: boolean
Init method should be used on server start, to configure whether the logs should use typeLabels or not (check screenshots above)
log/warn/error/info (label, [data])
label
Type: string
A log label
data
Type: any
Default: false
Any data that you want to log alongside your label.
It can be of any type, and it's optional.
start(req, res)
req
Type: Object
The request object
res
Type: Object
The response object
It logs the request start, end and the time passed.
Tests
npm installnpm test
Dependencies
- chalk: Terminal string styling done right. Much color.
Dev Dependencies
- eslint: An AST-based pattern checker for JavaScript.
- eslint-config-google: ESLint shareable config for the Google style
License
MIT