mirror of https://github.com/pelias/api.git
Severyn Kozak
10 years ago
15 changed files with 67 additions and 29 deletions
@ -0,0 +1,20 @@
|
||||
/** |
||||
* Create a middleware that prints access logs via pelias-logger. |
||||
*/ |
||||
|
||||
'use strict'; |
||||
|
||||
var morgan = require( 'morgan' ); |
||||
var through = require( 'through2' ); |
||||
var peliasLogger = require( 'pelias-logger' ).get( 'api' ); |
||||
|
||||
function createAccessLogger( logFormat ){ |
||||
return morgan( logFormat, { |
||||
stream: through( function write( ln, _, next ){ |
||||
peliasLogger.info( ln.toString().trim() ); |
||||
next(); |
||||
}) |
||||
}); |
||||
} |
||||
|
||||
module.exports = createAccessLogger; |
Loading…
Reference in new issue