diff --git a/app.js b/app.js index b0f65801..29897d73 100644 --- a/app.js +++ b/app.js @@ -1,6 +1,8 @@ var app = require('express')(); +app.use( require( './middleware/access_log' ) ); + /** ----------------------- middleware ----------------------- **/ app.use( require('./middleware/headers') ); diff --git a/middleware/access_log.js b/middleware/access_log.js new file mode 100644 index 00000000..ff79eb00 --- /dev/null +++ b/middleware/access_log.js @@ -0,0 +1,14 @@ +/** + * Print out access logs. + */ + +'use strict'; + +var peliasConfig = require( 'pelias-config' ).generate().api; +var morgan = require( 'morgan' ); + +module.exports = peliasConfig.accessLog ? + morgan( peliasConfig.accessLog ) : + function noop(req, res, next){ + next(); + }; diff --git a/package.json b/package.json index ae77f1ae..f64ca731 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,8 @@ "is-object": "^1.0.1", "markdown": "0.5.0", "pelias-esclient": "0.0.25", + "morgan": "1.5.2", + "pelias-config": "^0.1.4", "pelias-suggester-pipeline": "2.0.2" }, "devDependencies": {