Skip to content

Commit

Permalink
add some debugging, hide it behind an option
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpvar committed Feb 5, 2013
1 parent 2c6ef75 commit c4f87b3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions index.js
Expand Up @@ -3,7 +3,8 @@ var sproc = require('sproc'),
path = require('path'),
split = require('split'),
EventEmitter = require('events').EventEmitter,
net = require('net');
net = require('net'),
log;

function Device(host, info) {
this.host = host;
Expand All @@ -12,17 +13,19 @@ function Device(host, info) {
}

Device.prototype.connect = function(fn) {
console.log('creating connection to', this.host, this.port);
log && log('creating connection to', this.host, this.port);
var client = net.createConnection({
host: this.host,
port: this.port
});

client.on('connect', function() {
log && log('connected to', this.host, this.port);
fn(null, client);
});

client.on('error', function(e) {
log && log('error', e);
fn(e);
});
};
Expand All @@ -34,12 +37,16 @@ module.exports = function(options, fn) {
options = {};
}

sproc(defaults(options, {
defaults(options, {
host: 'localhost',
port: 4672,
script: path.join(__dirname, 'daemon', 'main.js'),
log: console.log
}), function(err, stream) {
log: null
});

log = options.log;

sproc(options, function(err, stream) {

if (err) {
return fn(err);
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "serialport-manager",
"version": "0.2.1",
"version": "0.2.2",
"description": "single process manager of transient serialport connections",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit c4f87b3

Please sign in to comment.