Created
November 14, 2017 13:24
-
-
Save npretto/a4cd6acc0e4023a5d90873ce1ec6fecf to your computer and use it in GitHub Desktop.
node parse-logs.js file-di-log.txt > parsed.csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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