kopia lustrzana https://github.com/miklobit/TiddlyWiki5
Add optional debug logging to the server command
rodzic
c29f5a1b61
commit
1ce9973bed
|
@ -19,6 +19,7 @@ The parameters are:
|
|||
* ''password'' - optional password for basic authentication
|
||||
* ''host'' - optional hostname to serve from (defaults to "127.0.0.1" aka "localhost")
|
||||
* ''pathprefix'' - optional prefix for paths
|
||||
* ''debuglevel'' - optional debug level; set to "debug" to view request details (defaults to "none")
|
||||
|
||||
If the password parameter is specified then the browser will prompt the user for the username and password. Note that the password is transmitted in plain text so this implementation isn't suitable for general use.
|
||||
|
||||
|
|
|
@ -98,6 +98,11 @@ SimpleServer.prototype.requestHandler = function(request,response) {
|
|||
state.wiki = self.wiki;
|
||||
state.server = self;
|
||||
state.urlInfo = url.parse(request.url);
|
||||
// Optionally output debug info
|
||||
if(self.get("debugLevel") !== "none") {
|
||||
console.log("Request path:",JSON.stringify(state.urlInfo));
|
||||
console.log("Request headers:",JSON.stringify(request.headers));
|
||||
}
|
||||
// Find the route that matches this path
|
||||
var route = self.findMatchingRoute(request,state);
|
||||
// Check for the username and password if we've got one
|
||||
|
@ -290,7 +295,8 @@ Command.prototype.execute = function() {
|
|||
username = this.params[4],
|
||||
password = this.params[5],
|
||||
host = this.params[6] || "127.0.0.1",
|
||||
pathprefix = this.params[7];
|
||||
pathprefix = this.params[7],
|
||||
debugLevel = this.params[8] || "none";
|
||||
if(parseInt(port,10).toString() !== port) {
|
||||
port = process.env[port] || 8080;
|
||||
}
|
||||
|
@ -300,7 +306,8 @@ Command.prototype.execute = function() {
|
|||
serveType: serveType,
|
||||
username: username,
|
||||
password: password,
|
||||
pathprefix: pathprefix
|
||||
pathprefix: pathprefix,
|
||||
debugLevel: debugLevel
|
||||
});
|
||||
var nodeServer = this.server.listen(port,host);
|
||||
$tw.utils.log("Serving on " + host + ":" + port,"brown/orange");
|
||||
|
|
Ładowanie…
Reference in New Issue