Skip to content

Commit

Permalink
Don't use logger.error() method for any kind of logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dgaubert committed May 12, 2020
1 parent cd651fd commit 5c16e21
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)));
}
};

/**
Expand All @@ -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;
Expand All @@ -144,6 +143,7 @@ function makePool (redisPool, database) {
if (err) {
return resolve(err);
}

return resolve(client);
}
});
Expand Down

0 comments on commit 5c16e21

Please sign in to comment.