Skip to content

Commit

Permalink
added logging on connection open/close
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed Oct 3, 2012
1 parent 2c49689 commit c45f98f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/mongodb/connection/connection.js
Expand Up @@ -84,14 +84,19 @@ Connection.prototype.start = function() {
this.writeSteam.on("close", closeHandler(this));
// Start socket
this.connection.connect(this.socketOptions.port, this.socketOptions.host);
if(this.logger != null && this.logger.doDebug){
this.logger.debug("opened connection", this.socketOptions);
}
} else {
// Create new connection instance
if(!this.domainSocket) {
this.connection = net.createConnection(this.socketOptions.port, this.socketOptions.host);
} else {
this.connection = net.createConnection(this.socketOptions.host);
}

if(this.logger != null && this.logger.doDebug){
this.logger.debug("opened connection", this.socketOptions);
}
// Set options on the socket
this.connection.setTimeout(this.socketOptions.connectTimeoutMS != null ? this.socketOptions.connectTimeoutMS : this.socketOptions.timeout);
// Work around for 0.4.X
Expand Down Expand Up @@ -161,6 +166,9 @@ Connection.prototype.close = function() {
this.connection.on("error", function() {})
// destroy connection
this.connection.destroy();
if(this.logger != null && this.logger.doDebug){
this.logger.debug("closed connection", this.connection);
}
}

// Reset all handlers
Expand Down

0 comments on commit c45f98f

Please sign in to comment.