Browse Source

additional backend error logging

production_patch_logging
Peter Johnson 8 years ago
parent
commit
650dd5784e
  1. 13
      service/mget.js
  2. 15
      service/search.js

13
service/mget.js

@ -11,7 +11,7 @@
**/
var peliasLogger = require( 'pelias-logger' ).get( 'api' );
var logger = require( 'pelias-logger' ).get( 'api' );
function service( backend, query, cb ){
@ -24,8 +24,17 @@ function service( backend, query, cb ){
// query new backend
backend().client.mget( cmd, function( err, data ){
// log total ms elasticsearch reported the query took to execute
if( data && data.took ){
logger.verbose( 'time elasticsearch reported:', data.took / 1000 );
}
// handle backend errors
if( err ){ return cb( err ); }
if( err ){
logger.error( 'backend error', err );
return cb( err );
}
// map returned documents
var docs = [];

15
service/search.js

@ -5,18 +5,23 @@
**/
var peliasLogger = require( 'pelias-logger' ).get( 'api' );
var logger = require( 'pelias-logger' ).get( 'api' );
function service( backend, cmd, cb ){
// query new backend
backend().client.search( cmd, function( err, data ){
// handle backend errors
if( err ){ return cb( err ); }
// log total ms elasticsearch reported the query took to execute
peliasLogger.verbose( 'time elasticsearch reported:', data.took / 1000 );
if( data && data.took ){
logger.verbose( 'time elasticsearch reported:', data.took / 1000 );
}
// handle backend errors
if( err ){
logger.error( 'backend error', err );
return cb( err );
}
// map returned documents
var docs = [];

Loading…
Cancel
Save