44 lines
1.1 KiB
Haxe
Executable File
44 lines
1.1 KiB
Haxe
Executable File
package haxework.log;
|
|
|
|
import haxework.log.BaseLogger;
|
|
#if flash
|
|
import flash.net.Socket;
|
|
import flash.events.IOErrorEvent;
|
|
import flash.events.SecurityErrorEvent;
|
|
#else
|
|
import sys.net.Host;
|
|
import sys.net.Socket;
|
|
#end
|
|
|
|
class SocketLogger extends BaseLogger {
|
|
|
|
private var socket:Socket;
|
|
|
|
public function new() {
|
|
super();
|
|
socket = new Socket();
|
|
#if flash
|
|
socket.addEventListener(IOErrorEvent.IO_ERROR, function(error):Void {
|
|
L.e("SocketLogger", "", error);
|
|
});
|
|
socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, function(error):Void {
|
|
L.e("SocketLogger", "", error);
|
|
});
|
|
socket.connect(CompilationOption.get("debug.address"), Std.parseInt(CompilationOption.get("debug.port")));
|
|
#else
|
|
socket.connect(new Host(CompilationOption.get("debug.address")), Std.parseInt(CompilationOption.get("debug.port")));
|
|
#end
|
|
}
|
|
|
|
override private function write(text:String, ?p:haxe.PosInfos):Void {
|
|
try {
|
|
var s:String = p.fileName + ":" + p.lineNumber + ":" + text + "\n";
|
|
#if flash
|
|
socket.writeUTF(s);
|
|
socket.flush();
|
|
#else
|
|
socket.write(s);
|
|
#end
|
|
} catch (error:Dynamic) {}
|
|
}
|
|
} |