Add close() check

This commit is contained in:
calzoneman 2013-07-29 18:16:11 -04:00
parent 93dd730bde
commit 4c7da26f13

View file

@ -27,7 +27,7 @@ var Logger = function(filename) {
Logger.prototype.log = function () { Logger.prototype.log = function () {
if(this.dead) { if(this.dead) {
Logger.errlog.log("WARNING: Attempted write to dead logger: ", this.filename); errlog.log("WARNING: Attempted write to dead logger: ", this.filename);
return; return;
} }
var msg = ""; var msg = "";
@ -38,6 +38,10 @@ Logger.prototype.log = function () {
} }
Logger.prototype.close = function () { Logger.prototype.close = function () {
if(this.dead) {
errlog.log("WARNING: Attempted closure on dead logger: ", this.filename);
return;
}
this.writer.end("", null, function () { this.writer.end("", null, function () {
this.dead = true; this.dead = true;
}); });