Browse Source

Remove non-JSON log lines

We can have logs with a lot more fidelity by logging structured JSON
directly.
pull/1220/head
Julian Simioni 6 years ago
parent
commit
49a988ce37
No known key found for this signature in database
GPG Key ID: B9EEB0C6EE0910A1
  1. 9
      query/autocomplete.js
  2. 11
      query/reverse.js
  3. 16
      query/search.js
  4. 12
      query/search_original.js

9
query/autocomplete.js

@ -60,18 +60,14 @@ function generateQuery( clean ){
const vs = new peliasQuery.Vars( defaults );
let logStr = '[query:autocomplete] [parser:addressit] ';
// sources
if( check.array(clean.sources) && clean.sources.length ){
vs.var( 'sources', clean.sources );
logStr += '[param:sources] ';
}
// layers
if( check.array(clean.layers) && clean.layers.length ){
vs.var( 'layers', clean.layers);
logStr += '[param:layers] ';
}
// boundary country
@ -79,7 +75,6 @@ function generateQuery( clean ){
vs.set({
'boundary:country': clean['boundary.country']
});
logStr += '[param:boundary_country] ';
}
// pass the input tokens to the views so they can choose which tokens
@ -112,7 +107,6 @@ function generateQuery( clean ){
'focus:point:lat': clean['focus.point.lat'],
'focus:point:lon': clean['focus.point.lon']
});
logStr += '[param:focus_point] ';
}
// boundary rect
@ -126,7 +120,6 @@ function generateQuery( clean ){
'boundary:rect:bottom': clean['boundary.rect.min_lat'],
'boundary:rect:left': clean['boundary.rect.min_lon']
});
logStr += '[param:boundary_rect] ';
}
// run the address parser
@ -134,8 +127,6 @@ function generateQuery( clean ){
textParser( clean.parsed_text, vs );
}
logger.info(logStr);
return {
type: 'autocomplete',
body: query.render(vs)

11
query/reverse.js

@ -28,25 +28,20 @@ function generateQuery( clean ){
const vs = new peliasQuery.Vars( defaults );
let logStr = '[query:reverse] ';
// set size
if( clean.querySize ){
vs.var( 'size', clean.querySize);
logStr += '[param:querySize] ';
}
// sources
if( check.array(clean.sources) && clean.sources.length ) {
vs.var('sources', clean.sources);
logStr += '[param:sources] ';
}
// layers
if( check.array(clean.layers) && clean.layers.length ) {
// only include non-coarse layers
vs.var( 'layers', _.intersection(clean.layers, ['address', 'street', 'venue']));
logStr += '[param:layers] ';
}
// focus point to score by distance
@ -56,7 +51,6 @@ function generateQuery( clean ){
'focus:point:lat': clean['point.lat'],
'focus:point:lon': clean['point.lon']
});
logStr += '[param:focus_point] ';
}
// bounding circle
@ -82,7 +76,6 @@ function generateQuery( clean ){
'boundary:circle:radius': clean['boundary.circle.radius'] + 'km'
});
}
logStr += '[param:boundary_circle] ';
}
// boundary country
@ -90,17 +83,13 @@ function generateQuery( clean ){
vs.set({
'boundary:country': clean['boundary.country']
});
logStr += '[param:boundary_country] ';
}
// categories
if (clean.categories) {
vs.var('input:categories', clean.categories);
logStr += '[param:categories] ';
}
logger.info(logStr);
return {
type: 'reverse',
body: query.render(vs)

16
query/search.js

@ -32,7 +32,6 @@ function generateQuery( clean ){
const vs = new peliasQuery.Vars( defaults );
let logStr = '[query:search] [parser:libpostal] ';
// input text
vs.var( 'input:name', clean.text );
@ -40,25 +39,21 @@ function generateQuery( clean ){
// sources
if( check.array(clean.sources) && clean.sources.length ) {
vs.var( 'sources', clean.sources);
logStr += '[param:sources] ';
}
// layers
if( check.array(clean.layers) && clean.layers.length ) {
vs.var('layers', clean.layers);
logStr += '[param:layers] ';
}
// categories
if (clean.categories) {
vs.var('input:categories', clean.categories);
logStr += '[param:categories] ';
}
// size
if( clean.querySize ) {
vs.var( 'size', clean.querySize );
logStr += '[param:querySize] ';
}
// focus point
@ -68,7 +63,6 @@ function generateQuery( clean ){
'focus:point:lat': clean['focus.point.lat'],
'focus:point:lon': clean['focus.point.lon']
});
logStr += '[param:focus_point] ';
}
// boundary rect
@ -82,7 +76,6 @@ function generateQuery( clean ){
'boundary:rect:bottom': clean['boundary.rect.min_lat'],
'boundary:rect:left': clean['boundary.rect.min_lon']
});
logStr += '[param:boundary_rect] ';
}
// boundary circle
@ -99,7 +92,6 @@ function generateQuery( clean ){
'boundary:circle:radius': Math.round( clean['boundary.circle.radius'] ) + 'km'
});
}
logStr += '[param:boundary_circle] ';
}
// boundary country
@ -107,7 +99,6 @@ function generateQuery( clean ){
vs.set({
'boundary:country': clean['boundary.country']
});
logStr += '[param:boundary_country] ';
}
// run the address parser
@ -119,13 +110,6 @@ function generateQuery( clean ){
//console.log(JSON.stringify(q, null, 2));
if (q !== undefined) {
logger.debug(logStr);
}
else {
logger.debug('[parser:libpostal] query type not supported');
}
return q;
}

12
query/search_original.js

@ -57,33 +57,27 @@ function generateQuery( clean ){
var vs = new peliasQuery.Vars( defaults );
let logStr = '[query:search] [parser:addressit] ';
// input text
vs.var( 'input:name', clean.text );
// sources
if( check.array(clean.sources) && clean.sources.length ) {
vs.var( 'sources', clean.sources);
logStr += '[param:sources] ';
}
// layers
if( check.array(clean.layers) && clean.layers.length ) {
vs.var( 'layers', clean.layers);
logStr += '[param:layers] ';
}
// categories
if (clean.categories) {
vs.var('input:categories', clean.categories);
logStr += '[param:categories] ';
}
// size
if( clean.querySize ) {
vs.var( 'size', clean.querySize );
logStr += '[param:size] ';
}
// focus point
@ -93,7 +87,6 @@ function generateQuery( clean ){
'focus:point:lat': clean['focus.point.lat'],
'focus:point:lon': clean['focus.point.lon']
});
logStr += '[param:focus_point] ';
}
// boundary rect
@ -107,7 +100,6 @@ function generateQuery( clean ){
'boundary:rect:bottom': clean['boundary.rect.min_lat'],
'boundary:rect:left': clean['boundary.rect.min_lon']
});
logStr += '[param:boundary_rect] ';
}
// boundary circle
@ -124,7 +116,6 @@ function generateQuery( clean ){
'boundary:circle:radius': Math.round( clean['boundary.circle.radius'] ) + 'km'
});
}
logStr += '[param:boundary_circle] ';
}
// boundary country
@ -132,7 +123,6 @@ function generateQuery( clean ){
vs.set({
'boundary:country': clean['boundary.country']
});
logStr += '[param:boundary_country] ';
}
// run the address parser
@ -140,8 +130,6 @@ function generateQuery( clean ){
textParser( clean.parsed_text, vs );
}
logger.info(logStr);
return {
type: 'original',
body: query.render(vs)

Loading…
Cancel
Save