closes #456, if the file path doesnt exists logger was crashing

This commit is contained in:
Baris Soner Usakli
2013-10-26 20:19:42 -04:00
parent 252187f1fe
commit 52f198481b

View File

@@ -71,8 +71,9 @@ var opts = {
Logger.open = function(value) { Logger.open = function(value) {
/* Open the streams to log to: either a path or stdout */ /* Open the streams to log to: either a path or stdout */
var stream; var stream;
if(value) if(value && fs.existsSync(value)) {
stream = fs.createWriteStream(value, {flags: 'a'}); stream = fs.createWriteStream(value, {flags: 'a'});
}
else else
stream = process.stdout; stream = process.stdout;
return stream; return stream;
@@ -113,7 +114,7 @@ var opts = {
return opts.express.ofn(req,res,next); return opts.express.ofn(req,res,next);
} }
else { else {
return next() return next();
} }
} }