Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
iamigo committed Aug 19, 2017
1 parent aa845b4 commit 1dd0b51
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
23 changes: 13 additions & 10 deletions cache/redisCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
const redis = require('redis');
const logger = require('winston');
const rconf = require('../config').redis;
const featureToggles = require('feature-toggles');

/*
* This will add "...Async" to all node_redis functions (e.g. return
Expand Down Expand Up @@ -77,22 +78,24 @@ const client = {
};

Object.keys(client).forEach((key) => {
client[key].on('connect', () => {
logger.info(`redisClientConnection=${key} event=connect`);
});

client[key].on('error', (err) => {
logger.error(`redisClientConnection=${key} event=error`, err);
return new Error(err);
});

client[key].on('ready', () => {
logger.info(`redisClientConnection=${key} event=ready`);
});
if (featureToggles.isFeatureEnabled('enableRedisConnectionLogging')) {
client[key].on('connect', () => {
logger.info(`redisClientConnection=${key} event=connect`);
});

client[key].on('reconnecting', () => {
logger.info(`redisClientConnection=${key} event=reconnecting`);
});
client[key].on('ready', () => {
logger.info(`redisClientConnection=${key} event=ready`);
});

client[key].on('reconnecting', () => {
logger.info(`redisClientConnection=${key} event=reconnecting`);
});
}
});

module.exports = {
Expand Down
4 changes: 4 additions & 0 deletions config/toggles.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ const longTermToggles = {
enableRealtimeActivityLogs:
environmentVariableTrue(pe, 'ENABLE_REALTIME_ACTIVITY_LOGS'),

// Enable redis client connection logging.
enableRedisConnectionLogging: environmentVariableTrue(pe,
'ENABLE_REDIS_CONNECTION_LOGGING'),

// Use redis sampleStore with postgres db backup.
enableRedisSampleStore:
environmentVariableTrue(pe, 'ENABLE_REDIS_SAMPLE_STORE'),
Expand Down

0 comments on commit 1dd0b51

Please sign in to comment.