Changed DebugLevel, default 500 page

This commit is contained in:
斟酌 鵬兄 2015-02-12 16:00:45 +08:00
parent 24ddf7a4b8
commit e570b4367b
3 changed files with 14 additions and 7 deletions

View File

@ -57,22 +57,22 @@ function Dragonfly( logHandler )
this.Info( "Dragonfly ready.", Dragonfly.Visibility.VISIBLE ); this.Info( "Dragonfly ready.", Dragonfly.Visibility.VISIBLE );
} }
Dragonfly.prototype.Info = function( mesg, visibility ) Dragonfly.prototype.Debug = function( mesg, visibility )
{ {
this.Log( mesg, Dragonfly.Spheres.THERMO, visibility ); this.Log( mesg, Dragonfly.Spheres.THERMO, visibility );
}; };
Dragonfly.prototype.Warning = function( mesg, visibility ) Dragonfly.prototype.Info = function( mesg, visibility )
{ {
this.Log( mesg, Dragonfly.Spheres.STRATO, visibility ); this.Log( mesg, Dragonfly.Spheres.STRATO, visibility );
}; };
Dragonfly.prototype.Error = function( mesg, visibility ) Dragonfly.prototype.Warning = function( mesg, visibility )
{ {
this.Log( mesg, Dragonfly.Spheres.HYDRO, visibility ); this.Log( mesg, Dragonfly.Spheres.HYDRO, visibility );
}; };
Dragonfly.prototype.Debug = function( mesg, visibility ) Dragonfly.prototype.Error = function( mesg, visibility )
{ {
this.Log( mesg, Dragonfly.Spheres.LITHO, visibility ); this.Log( mesg, Dragonfly.Spheres.LITHO, visibility );
}; };

View File

@ -108,7 +108,7 @@ Router.prototype.setRoute = function( _route, _match )
// Re-route function // Re-route function
, reRoute: function( target, direct ) , reRoute: function( target, direct )
{ {
Dragonfly.Log( Dragonfly.Debug(
"Reroute: " + target "Reroute: " + target
+ ( direct ? ", Direct" : "" ) + ( direct ? ", Direct" : "" )
); );

View File

@ -12,6 +12,7 @@ var Framework = function( garden )
var Router = require( "./Router" ); var Router = require( "./Router" );
this.router = new Router( garden ); this.router = new Router( garden );
this.router.addRoute( "404", false, "404" ); this.router.addRoute( "404", false, "404" );
this.router.addRoute( "500", false, "500" );
this.router.addListener( "Route", this.parseResult.bind( this ) ); this.router.addListener( "Route", this.parseResult.bind( this ) );
this.handlers = { this.handlers = {
@ -21,6 +22,12 @@ var Framework = function( garden )
this.result = "404 Not Found"; this.result = "404 Not Found";
this.plantResult(); this.plantResult();
}.bind( this ) }.bind( this )
, "500": function()
{
this.HTTP.response.statusCode = 500;
this.result = "500 Internal Server Error";
this.plantResult();
}.bind( this )
} }
}; };
@ -65,7 +72,7 @@ Framework.prototype.parseResult = function()
var method = this.router.route(); var method = this.router.route();
if( method ) if( method )
{ {
Dragonfly.Log( "Call " + method, Dragonfly.Spheres.THERMO ); Dragonfly.Debug( "Call " + method, Dragonfly.Spheres.THERMO );
if( this.handlers[ method ] ) if( this.handlers[ method ] )
{ {
@ -75,7 +82,7 @@ Framework.prototype.parseResult = function()
} }
else if( method === false ) else if( method === false )
{ {
Dragonfly.Log( "No route is defined to handle this URI", Dragonfly.Spheres.THERMO ); Dragonfly.Debug( "No route is defined to handle this URI", Dragonfly.Spheres.THERMO );
this.router.routeObj.reRoute( "404", true ); this.router.routeObj.reRoute( "404", true );
return; return;
} }