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

11
query/reverse.js

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

16
query/search.js

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

12
query/search_original.js

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

Loading…
Cancel
Save