瀏覽代碼

added setLogger.

Nicolas Cannasse 19 年之前
父節點
當前提交
5ee02d2c3d
共有 1 個文件被更改,包括 11 次插入0 次删除
  1. 11 0
      std/haxe/remoting/Server.hx

+ 11 - 0
std/haxe/remoting/Server.hx

@@ -28,15 +28,21 @@ class Server {
 
 
 	var objects : Hash<Dynamic>;
 	var objects : Hash<Dynamic>;
 	var prefix : String;
 	var prefix : String;
+	var log : String -> Void;
 
 
 	public function new() {
 	public function new() {
 		objects = new Hash();
 		objects = new Hash();
+		log = null;
 	}
 	}
 
 
 	public function addObject( name : String, obj : Dynamic ) {
 	public function addObject( name : String, obj : Dynamic ) {
 		objects.set(name,obj);
 		objects.set(name,obj);
 	}
 	}
 
 
+	public function setLogger( l ) {
+		log = l;
+	}
+
 	public function setPrivatePrefix( p : String ) {
 	public function setPrivatePrefix( p : String ) {
 		prefix = p;
 		prefix = p;
 	}
 	}
@@ -77,6 +83,11 @@ class Server {
 			neko.Lib.print("hxr");
 			neko.Lib.print("hxr");
 			neko.Lib.print(s.toString());
 			neko.Lib.print(s.toString());
 		} catch( e : Dynamic ) {
 		} catch( e : Dynamic ) {
+			if( log != null ) {
+				log(neko.Stack.toString(neko.Stack.exceptionStack()));
+				log(Std.string(e));
+				log("\n\n");
+			}
 			var s = new haxe.Serializer();
 			var s = new haxe.Serializer();
 			s.serializeException(e);
 			s.serializeException(e);
 			neko.Lib.print("hxr");
 			neko.Lib.print("hxr");