atbar
Version:
Async callback manager for javascript in nodejs and browser
27 lines • 759 B
JavaScript
/*
coffee -cb /opt/node/bb/dev/node_modules/atbar/atbar.cof
coffee /opt/node/bb/dev/node_modules/atbar/tests/logger.cof
*/var atbar, fs, log;
fs = require('fs');
atbar = require('atbar');
log = function(path, msg) {
return atbar.run('trace', function() {
var fd;
fd = null;
msg = ('' + new Date).slice(0, 24) + ' ' + msg + '\n';
this._(function() {
return fs.open(path, 'a', this.$());
});
this._(function(_throw, d) {
fd = d;
return fs.write(fd, msg, null, null, this.$());
});
this._(function(_throw) {
return fs.close(fd, this.$('exit'));
});
return this._('catch', function(err) {
return console.log('log() err: ' + err);
});
});
};
log('/tmp/logtest', 'hello logging world');