Browse Source

Replace src/logger with pelias-logger.

(query, query)/*.js
	-Remove unused `../src/logger` `require()`s.

src/logger.js, package.json
	-Remove `src/logger` in favor of using `pelias-logger` for all
	logging, since it's the Pelias standard.

middleware/500.js
	-Replace usage of `src/logger` with pelias-logger.
pull/123/head
Severyn Kozak 10 years ago
parent
commit
a007af3572
  1. 4
      middleware/500.js
  2. 1
      package.json
  3. 6
      query/search.js
  4. 6
      query/suggest.js
  5. 5
      sanitiser/coarse.js
  6. 5
      sanitiser/doc.js
  7. 3
      sanitiser/search.js
  8. 5
      sanitiser/suggest.js
  9. 5
      src/logger.js

4
middleware/500.js

@ -1,8 +1,8 @@
var logger = require( '../src/logger' ); var logger = require( 'pelias-logger' ).get( 'middleware-500' );
// handle application errors // handle application errors
function middleware(err, req, res, next) { function middleware(err, req, res, next) {
logger.error( 'Error:', err ); logger.error( err );
logger.error( 'Stack trace:', err.trace ); logger.error( 'Stack trace:', err.trace );
res.header('Cache-Control','no-cache'); res.header('Cache-Control','no-cache');
if( res.statusCode < 400 ){ res.status(500); } if( res.statusCode < 400 ){ res.status(500); }

1
package.json

@ -41,6 +41,7 @@
"is-object": "^1.0.1", "is-object": "^1.0.1",
"markdown": "0.5.0", "markdown": "0.5.0",
"pelias-esclient": "0.0.25", "pelias-esclient": "0.0.25",
"pelias-logger": "^0.0.8",
"morgan": "1.5.2", "morgan": "1.5.2",
"pelias-config": "^0.1.4", "pelias-config": "^0.1.4",
"pelias-suggester-pipeline": "2.0.2" "pelias-suggester-pipeline": "2.0.2"

6
query/search.js

@ -1,10 +1,8 @@
var logger = require('../src/logger'), var queries = require('geopipes-elasticsearch-backend').queries,
queries = require('geopipes-elasticsearch-backend').queries,
sort = require('../query/sort'); sort = require('../query/sort');
function generate( params ){ function generate( params ){
var centroid = null; var centroid = null;
if ( params.lat && params.lon ){ if ( params.lat && params.lon ){
@ -50,4 +48,4 @@ function generate( params ){
return query; return query;
} }
module.exports = generate; module.exports = generate;

6
query/suggest.js

@ -1,6 +1,5 @@
var logger = require('../src/logger'), var get_layers = require('../helper/layers');
get_layers = require('../helper/layers');
// Build pelias suggest query // Build pelias suggest query
function generate( params, query_mixer, fuzziness ){ function generate( params, query_mixer, fuzziness ){
@ -69,9 +68,8 @@ function generate( params, query_mixer, fuzziness ){
} }
// logger.log( 'cmd', JSON.stringify( cmd.cmd, null, 2 ) );
return cmd.cmd; return cmd.cmd;
} }
module.exports = generate; module.exports = generate;

5
sanitiser/coarse.js

@ -1,6 +1,5 @@
var logger = require('../src/logger'), var _sanitize = require('../sanitiser/_sanitize'),
_sanitize = require('../sanitiser/_sanitize'),
sanitizers = { sanitizers = {
input: require('../sanitiser/_input'), input: require('../sanitiser/_input'),
size: require('../sanitiser/_size'), size: require('../sanitiser/_size'),
@ -28,4 +27,4 @@ module.exports.middleware = function( req, res, next ){
req.clean = clean; req.clean = clean;
next(); next();
}); });
}; };

5
sanitiser/doc.js

@ -1,6 +1,5 @@
var logger = require('../src/logger'), var _sanitize = require('../sanitiser/_sanitize'),
_sanitize = require('../sanitiser/_sanitize'),
sanitizers = { sanitizers = {
id: require('../sanitiser/_id'), id: require('../sanitiser/_id'),
details: require('../sanitiser/_details') details: require('../sanitiser/_details')
@ -21,4 +20,4 @@ module.exports.middleware = function( req, res, next ){
req.clean = clean; req.clean = clean;
next(); next();
}); });
}; };

3
sanitiser/search.js

@ -1,6 +1,5 @@
var logger = require('../src/logger'), var _sanitize = require('../sanitiser/_sanitize'),
_sanitize = require('../sanitiser/_sanitize'),
sanitizers = { sanitizers = {
input: require('../sanitiser/_input'), input: require('../sanitiser/_input'),
size: require('../sanitiser/_size'), size: require('../sanitiser/_size'),

5
sanitiser/suggest.js

@ -1,6 +1,5 @@
var logger = require('../src/logger'), var _sanitize = require('../sanitiser/_sanitize'),
_sanitize = require('../sanitiser/_sanitize'),
sanitizers = { sanitizers = {
input: require('../sanitiser/_input'), input: require('../sanitiser/_input'),
size: require('../sanitiser/_size'), size: require('../sanitiser/_size'),
@ -27,4 +26,4 @@ module.exports.middleware = function( req, res, next ){
req.clean = clean; req.clean = clean;
next(); next();
}); });
}; };

5
src/logger.js

@ -1,5 +0,0 @@
module.exports = {
log: console.log.bind( console ),
warn: console.warn.bind( console ),
error: console.error.bind( console )
};
Loading…
Cancel
Save