index.js
function(callback) {

  log('Connecting...');
  MongoClient.connect(dbUrl, dbOptions, function(err, dbConn) {
    
    if(err) {
      log('Cannot connect: ' + err);
      callback(err);
      return;
    } 
    
    log('Connected!');
    isConnected = true;
    db = dbConn;

    // http://stackoverflow.com/a/18715857/446681
    db.on('close', function() {
      log('Connection was closed!!!');
      isConnected = false;
    });

    log('Executing...');
    callback(null, db);
  
  });

}
function(callback) {

  log('Connecting...');
  MongoClient.connect(dbUrl, dbOptions, function(err, dbConn) {
    
    if(err) {
      log('Cannot connect: ' + err);
      callback(err);
      return;
    } 
    
    log('Connected!');
    isConnected = true;
    db = dbConn;

    // http://stackoverflow.com/a/18715857/446681
    db.on('close', function() {
      log('Connection was closed!!!');
      isConnected = false;
    });

    log('Executing...');
    callback(null, db);
  
  });

}
function ( callback ) { log ( 'Connecting...' ) ; MongoClient . connect ( dbUrl , dbOptions , function ( err , dbConn ) { if ( err ) { log ( 'Cannot connect: ' + err ) ; callback ( err ) ; return ; } log ( 'Connected!' ) ; isConnected = true ; db = dbConn ; // http://stackoverflow.com/a/18715857/446681 db . on ( 'close' , function ( ) { log ( 'Connection was closed!!!' ) ; isConnected = false ; } ) ; log ( 'Executing...' ) ; callback ( null , db ) ; } ) ; }
by default don't log
by default don t log