From 5c16e2136aa5c007cf327a2e14c8dccc9ee804bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Tue, 12 May 2020 20:02:25 +0200 Subject: [PATCH] Don't use logger.error() method for any kind of logging --- index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index d963108..f5deba2 100644 --- a/index.js +++ b/index.js @@ -63,7 +63,7 @@ module.exports = class RedisPool extends EventEmitter { const elapsedTime = Date.now() - startTime; if (this.options.slowPool.log && elapsedTime > this.options.slowPool.elapsedThreshold) { - this._log({ db: database, action: 'acquire', elapsed: elapsedTime, waiting: pool.pending }); + this.logger.info({ name: this.options.name, db: database, action: 'acquire', elapsed: elapsedTime, waiting: pool.pending }); } return client; @@ -110,10 +110,6 @@ module.exports = class RedisPool extends EventEmitter { _getStatusDelay() { return (this.options.emitter && this.options.emitter.statusInterval) || DEFAULT_STATUS_INTERVAL; } - - _log(info) { - this.logger.error(JSON.stringify(Object.assign({ name: this.options.name }, info))); - } }; /** @@ -135,7 +131,10 @@ function makePool (redisPool, database) { }); client.on('error', (err) => { - redisPool._log({ db: database, action: 'error', err: err.message }); + err.name = redisPool.options.name; + err.db = database; + err.action = 'create'; + redisPool.logger.error(err); if (!settled) { settled = true; @@ -144,6 +143,7 @@ function makePool (redisPool, database) { if (err) { return resolve(err); } + return resolve(client); } });