From a007af3572731cd50c41425f812bd9702c69d9f7 Mon Sep 17 00:00:00 2001 From: Severyn Kozak Date: Tue, 5 May 2015 09:51:03 -0400 Subject: [PATCH] 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. --- middleware/500.js | 4 ++-- package.json | 1 + query/search.js | 6 ++---- query/suggest.js | 6 ++---- sanitiser/coarse.js | 5 ++--- sanitiser/doc.js | 5 ++--- sanitiser/search.js | 3 +-- sanitiser/suggest.js | 5 ++--- src/logger.js | 5 ----- 9 files changed, 14 insertions(+), 26 deletions(-) delete mode 100644 src/logger.js diff --git a/middleware/500.js b/middleware/500.js index 47895552..0b957bb9 100644 --- a/middleware/500.js +++ b/middleware/500.js @@ -1,8 +1,8 @@ -var logger = require( '../src/logger' ); +var logger = require( 'pelias-logger' ).get( 'middleware-500' ); // handle application errors function middleware(err, req, res, next) { - logger.error( 'Error:', err ); + logger.error( err ); logger.error( 'Stack trace:', err.trace ); res.header('Cache-Control','no-cache'); if( res.statusCode < 400 ){ res.status(500); } diff --git a/package.json b/package.json index f64ca731..67a809a1 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "is-object": "^1.0.1", "markdown": "0.5.0", "pelias-esclient": "0.0.25", + "pelias-logger": "^0.0.8", "morgan": "1.5.2", "pelias-config": "^0.1.4", "pelias-suggester-pipeline": "2.0.2" diff --git a/query/search.js b/query/search.js index 65551cde..2c9a697e 100644 --- a/query/search.js +++ b/query/search.js @@ -1,10 +1,8 @@ -var logger = require('../src/logger'), - queries = require('geopipes-elasticsearch-backend').queries, +var queries = require('geopipes-elasticsearch-backend').queries, sort = require('../query/sort'); function generate( params ){ - var centroid = null; if ( params.lat && params.lon ){ @@ -50,4 +48,4 @@ function generate( params ){ return query; } -module.exports = generate; \ No newline at end of file +module.exports = generate; diff --git a/query/suggest.js b/query/suggest.js index 249f7c38..16cd7b28 100644 --- a/query/suggest.js +++ b/query/suggest.js @@ -1,6 +1,5 @@ -var logger = require('../src/logger'), - get_layers = require('../helper/layers'); +var get_layers = require('../helper/layers'); // Build pelias suggest query 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; } -module.exports = generate; \ No newline at end of file +module.exports = generate; diff --git a/sanitiser/coarse.js b/sanitiser/coarse.js index 2d75f68f..8bd6a940 100644 --- a/sanitiser/coarse.js +++ b/sanitiser/coarse.js @@ -1,6 +1,5 @@ -var logger = require('../src/logger'), - _sanitize = require('../sanitiser/_sanitize'), +var _sanitize = require('../sanitiser/_sanitize'), sanitizers = { input: require('../sanitiser/_input'), size: require('../sanitiser/_size'), @@ -28,4 +27,4 @@ module.exports.middleware = function( req, res, next ){ req.clean = clean; next(); }); -}; \ No newline at end of file +}; diff --git a/sanitiser/doc.js b/sanitiser/doc.js index cb3276ca..07f07aa1 100644 --- a/sanitiser/doc.js +++ b/sanitiser/doc.js @@ -1,6 +1,5 @@ -var logger = require('../src/logger'), - _sanitize = require('../sanitiser/_sanitize'), +var _sanitize = require('../sanitiser/_sanitize'), sanitizers = { id: require('../sanitiser/_id'), details: require('../sanitiser/_details') @@ -21,4 +20,4 @@ module.exports.middleware = function( req, res, next ){ req.clean = clean; next(); }); -}; \ No newline at end of file +}; diff --git a/sanitiser/search.js b/sanitiser/search.js index df6af152..d226dbd9 100644 --- a/sanitiser/search.js +++ b/sanitiser/search.js @@ -1,6 +1,5 @@ -var logger = require('../src/logger'), - _sanitize = require('../sanitiser/_sanitize'), +var _sanitize = require('../sanitiser/_sanitize'), sanitizers = { input: require('../sanitiser/_input'), size: require('../sanitiser/_size'), diff --git a/sanitiser/suggest.js b/sanitiser/suggest.js index db363ebf..3741f3c4 100644 --- a/sanitiser/suggest.js +++ b/sanitiser/suggest.js @@ -1,6 +1,5 @@ -var logger = require('../src/logger'), - _sanitize = require('../sanitiser/_sanitize'), +var _sanitize = require('../sanitiser/_sanitize'), sanitizers = { input: require('../sanitiser/_input'), size: require('../sanitiser/_size'), @@ -27,4 +26,4 @@ module.exports.middleware = function( req, res, next ){ req.clean = clean; next(); }); -}; \ No newline at end of file +}; diff --git a/src/logger.js b/src/logger.js deleted file mode 100644 index 205313c0..00000000 --- a/src/logger.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - log: console.log.bind( console ), - warn: console.warn.bind( console ), - error: console.error.bind( console ) -}; \ No newline at end of file