Skip to content

Commit

Permalink
fix(logs): adding more debug statements
Browse files Browse the repository at this point in the history
  • Loading branch information
gergelyke committed Sep 4, 2015
1 parent 7ec2256 commit 0ae1f47
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,16 @@ Collector.prototype.writeToFile = function (trace, isSync) {
var _this = this;

if (isSync) {
fs.writeFileSync(_this.logFile, JSON.stringify(trace) + ',\n', {flag: 'a'});
try {
fs.writeFileSync(_this.logFile, JSON.stringify(trace) + ',\n', {flag: 'a'});
} catch (ex) {
debug('Could not write file: ', ex);
}
} else {
fs.writeFile(_this.logFile,
JSON.stringify(trace) + ',\n', {flag: 'a'}, function (err) {
if (err) {
return console.log(err);
return debug('Could not write file: ', err);
}

delete _this.store[trace.trace];
Expand Down
10 changes: 8 additions & 2 deletions lib/reporters/trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ TraceReporter.prototype.send = function (data, callback) {
return callback(null);
})
.on('error', function (err) {
debug('There was an error when connecting to the Trace API', err);
return callback(err);
});

Expand All @@ -54,7 +55,9 @@ TraceReporter.prototype.send = function (data, callback) {
};

TraceReporter.prototype._getRetryInterval = function() {
return Math.pow(2, this.retryCount) * this.baseRetryInterval;
var retryInterval = Math.pow(2, this.retryCount) * this.baseRetryInterval;
debug('retrying with %d ms', retryInterval);
return retryInterval;
};

TraceReporter.prototype.getService = function(callback) {
Expand Down Expand Up @@ -96,7 +99,10 @@ TraceReporter.prototype.getService = function(callback) {
return callback(null, resChunk);
});
})
.on('error', callback);
.on('error', function (err) {
debug('There was an error when connecting to the Trace API', err);
callback(err);
});

req.write(JSON.stringify({
name: _this.appName
Expand Down

0 comments on commit 0ae1f47

Please sign in to comment.