Browse Source

additional backend error logging

pull/751/head
Peter Johnson 8 years ago committed by Julian Simioni
parent
commit
72ec68f4c2
No known key found for this signature in database
GPG Key ID: 6DAD08919FDBF563
  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