fixes #18, '--log-format none' now works correctly

This commit is contained in:
Lloyd Brookes
2015-08-25 22:16:19 +01:00
parent 0f3b7a9e7f
commit ae592246b4

View File

@ -110,7 +110,7 @@ function launchServer(){
next(); next();
}); });
app.use(getLogger()); if (wsOptions.server["log-format"] !== "none") app.use(getLogger());
/* --compress enables compression */ /* --compress enables compression */
if (wsOptions.server.compress) app.use(compress()); if (wsOptions.server.compress) app.use(compress());
@ -138,22 +138,18 @@ function getLogger(){
/* log using --log-format (if supplied) */ /* log using --log-format (if supplied) */
var logFormat = wsOptions.server["log-format"]; var logFormat = wsOptions.server["log-format"];
if(logFormat) { if(logFormat) {
if (logFormat === "none"){ if (logFormat === "logstalgia"){
// do nothing, no logging required /* customised logger :date token, purely to satisfy Logstalgia. */
} else { morgan.token("date", function(){
if (logFormat === "logstalgia"){ var d = new Date();
/* customised logger :date token, purely to satisfy Logstalgia. */ return (d.getDate() + "/" + d.getUTCMonth() + "/" + d.getFullYear() + ":" + d.toTimeString())
morgan.token("date", function(){ .replace("GMT", "").replace(" (BST)", "");
var d = new Date(); });
return (d.getDate() + "/" + d.getUTCMonth() + "/" + d.getFullYear() + ":" + d.toTimeString()) logFormat = "combined";
.replace("GMT", "").replace(" (BST)", "");
});
logFormat = "combined";
}
return morgan(logFormat);
} }
return morgan(logFormat);
/* if no `--log-format` was specified, pipe the default format output /* if no `--log-format` was specified, pipe the default format output
into `log-stats`, which prints statistics to the console */ into `log-stats`, which prints statistics to the console */
} else { } else {