Skip to content

Commit

Permalink
Fix logging of key frequencies to stdout.
Browse files Browse the repository at this point in the history
The current code writes by default to a file called "stdout" instead of the
stdout filedescriptor.
  • Loading branch information
juliusv committed Oct 10, 2012
1 parent dd21c20 commit 008c7a7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions stats.js
Expand Up @@ -301,7 +301,7 @@ config.configFile(process.argv[2], function (config, oldConfig) {

if (keyFlushInterval > 0) {
var keyFlushPercent = Number((config.keyFlush && config.keyFlush.percent) || 100);
var keyFlushLog = (config.keyFlush && config.keyFlush.log) || "stdout";
var keyFlushLog = config.keyFlush && config.keyFlush.log;

keyFlushInt = setInterval(function () {
var key;
Expand All @@ -321,9 +321,13 @@ config.configFile(process.argv[2], function (config, oldConfig) {
logMessage += timeString + " count=" + sortedKeys[i][1] + " key=" + sortedKeys[i][0] + "\n";
}

var logFile = fs.createWriteStream(keyFlushLog, {flags: 'a+'});
logFile.write(logMessage);
logFile.end();
if (keyFlushLog) {
var logFile = fs.createWriteStream(keyFlushLog, {flags: 'a+'});
logFile.write(logMessage);
logFile.end();
} else {
process.stdout.write(logMessage);
}

// clear the counter
keyCounter = {};
Expand Down

0 comments on commit 008c7a7

Please sign in to comment.