2.0.0 • Published 8 years ago
simple-express-logger v2.0.0
simple-express-logger
##Description
Logs requests to the console in a format like this: Request: {GET} /api/foo
NOTE: This simply logs every request coming into the server, not just requests who's routes have been handled in express
##Usage
1. Install via npm: $ npm install --save simple-express-logger
2. Import and instantiate the module, then use it as middleware
var express = require('express');
var logger = require('simple-express-logger');
var app = express();
app.use(logger());
Checkout the API section for information about customization through an optional options
object
API
logger([options])
options
<Object
> Set of configurable options. Can have the following fields:customOutput
<Function>
Function used in place ofconsole.log
. Useful for externally redirecting the output.extraFields
<Array String>
Set of field names on thereq
<Object>
to also be logged. For example, anoptions
object of{ extraFields: [ 'headers' ] }
will log somthing similar to the following line:headers: "{ "foo": 1, "bar": 2 }"