middleware/logger/transport-redis.js
function initRedis(config, callback) {

  var self = this;

  protos.util.checkLocalPort(config.port, function(err) {

    if (err) {
      app.log("RedisTransport [%s:%s] %s", config.host, config.port, err.code);
    } else {

      // Set redis client
      self.client = redis.createClient(config.port, config.host, self.options);

      // Handle error event
      self.client.on('error', function(err) {
        callback.call(self, err);
      });

      // Authenticate if password provided
      if (typeof config.password == 'string') {
        self.client.auth(config.password, function(err, res) {
          if (err) {
            app.log("RedisTransport: [%s:%s] %s", config.host, config.port, err.code);
          } else if (typeof config.db == 'number' && config.db !== 0) {
            self.client.select(config.db, function(err, res) {
              if (err) callback.call(self, err);
              else callback.call(self, null);
            });
          } else {
            callback.call(self, null);
          }
        });
      } else if (typeof config.db == 'number' && config.db !== 0) {
        self.client.select(config.db, function(err, res) {
          callback.call(self, err);
        });
      } else {
        callback.call(self, null);
      }

    }
  });

}
function initRedis(config, callback) {

  var self = this;

  protos.util.checkLocalPort(config.port, function(err) {

    if (err) {
      app.log("RedisTransport [%s:%s] %s", config.host, config.port, err.code);
    } else {

      // Set redis client
      self.client = redis.createClient(config.port, config.host, self.options);

      // Handle error event
      self.client.on('error', function(err) {
        callback.call(self, err);
      });

      // Authenticate if password provided
      if (typeof config.password == 'string') {
        self.client.auth(config.password, function(err, res) {
          if (err) {
            app.log("RedisTransport: [%s:%s] %s", config.host, config.port, err.code);
          } else if (typeof config.db == 'number' && config.db !== 0) {
            self.client.select(config.db, function(err, res) {
              if (err) callback.call(self, err);
              else callback.call(self, null);
            });
          } else {
            callback.call(self, null);
          }
        });
      } else if (typeof config.db == 'number' && config.db !== 0) {
        self.client.select(config.db, function(err, res) {
          callback.call(self, err);
        });
      } else {
        callback.call(self, null);
      }

    }
  });

}
function initRedis ( config , callback ) { var self = this ; protos . util . checkLocalPort ( config . port , function ( err ) { if ( err ) { app . log ( "RedisTransport [%s:%s] %s" , config . host , config . port , err . code ) ; } else { // Set redis client self . client = redis . createClient ( config . port , config . host , self . options ) ; // Handle error event self . client . on ( 'error' , function ( err ) { callback . call ( self , err ) ; } ) ; // Authenticate if password provided if ( typeof config . password == 'string' ) { self . client . auth ( config . password , function ( err , res ) { if ( err ) { app . log ( "RedisTransport: [%s:%s] %s" , config . host , config . port , err . code ) ; } else if ( typeof config . db == 'number' && config . db !== 0 ) { self . client . select ( config . db , function ( err , res ) { if ( err ) callback . call ( self , err ) ; else callback . call ( self , null ) ; } ) ; } else { callback . call ( self , null ) ; } } ) ; } else if ( typeof config . db == 'number' && config . db !== 0 ) { self . client . select ( config . db , function ( err , res ) { callback . call ( self , err ) ; } ) ; } else { callback . call ( self , null ) ; } } } ) ; }
Initializes the redis client

@param {object} config
@param {function} callback
@private
Initializes the redis client