Skip to content

Instantly share code, notes, and snippets.

@ryanhanwu
Created November 16, 2018 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanhanwu/9171102932af928284d2ab3c7117fed7 to your computer and use it in GitHub Desktop.
Save ryanhanwu/9171102932af928284d2ab3c7117fed7 to your computer and use it in GitHub Desktop.
NodeJs Log
fs.appendFile('message.txt', 'data to append', function (err) {
if (err) throw err;
console.log('Saved!');
});
var readline = require('readline');
var fs = require('fs');
var myInterface = readline.createInterface({
input: fs.createReadStream('demofile1.html')
});
var lineno = 0;
myInterface.on('line', function (line) {
lineno++;
console.log('Line number ' + lineno + ': ' + line);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment