I tend to have a "quicklog" method for a few of the languages I'm working in to do logging when stdout/stderr isn't necessarily available (GUI app) or convenient (lots of other output on stdout, etc.). My usage with nodejs was while working on the node REPL. Log output to stdout interfered with the REPL.
1 2 3 4 5 6 7 8 | function quicklog(s) {
var logpath = "/tmp/quick.log";
var fs = require('fs');
s = s.toString().replace(/\r\n|\r/g, '\n'); // hack
var fd = fs.openSync(logpath, 'a+', 0666);
fs.writeSync(fd, s + '\n');
fs.closeSync(fd);
}
|