Skip to content

Instantly share code, notes, and snippets.

@npretto
Created November 14, 2017 13:24
Show Gist options
  • Select an option

  • Save npretto/a4cd6acc0e4023a5d90873ce1ec6fecf to your computer and use it in GitHub Desktop.

Select an option

Save npretto/a4cd6acc0e4023a5d90873ce1ec6fecf to your computer and use it in GitHub Desktop.
node parse-logs.js file-di-log.txt > parsed.csv
var path = process.argv[2];
console.log(`reading file ${path}`)
console.log(`Date, Memory`)
var lineReader = require('readline').createInterface({
input: require('fs').createReadStream(path)
});
var regexp = /(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}).*Memory : (\d*)MB/g;
lineReader.on('line', function (line) {
//console.log('Line from file:', line);
m = regexp.exec(line)
if(m)
{
console.log(`${new Date(m[1])} , ${m[2]}`);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment