diff --git a/com/furusystems/slf4hx/bindings/SocketIOBinding.hx b/com/furusystems/slf4hx/bindings/SocketIOBinding.hx new file mode 100644 index 0000000..d2e979e --- /dev/null +++ b/com/furusystems/slf4hx/bindings/SocketIOBinding.hx @@ -0,0 +1,36 @@ +package com.furusystems.slf4hx.bindings; +import com.furusystems.slf4hx.constants.Levels; +import haxe.Log; +import haxe.PosInfos; +import js.npm.socketio.Manager; + +/** + * ... + * @author Miha Lunar + */ + +class SocketIOBinding implements ILogBinding { + + var manager:Manager; + + public function new(manager) { + this.manager = manager; + } + + public function print(owner:Dynamic, level:String, str:String) { + var id = Levels.getID(level); + var log = manager.log; + var s = str; + //var s = owner+" "+str; + if (id >= Levels.ERROR) { + log.error(s); + } else if (id == Levels.WARN) { + log.warn(s); + } else if (id == Levels.INFO) { + log.info(s); + } else { + log.debug(s); + } + } + +} \ No newline at end of file diff --git a/com/furusystems/slf4hx/bindings/StandardStreamBinding.hx b/com/furusystems/slf4hx/bindings/StandardStreamBinding.hx new file mode 100644 index 0000000..8740cc2 --- /dev/null +++ b/com/furusystems/slf4hx/bindings/StandardStreamBinding.hx @@ -0,0 +1,27 @@ +package com.furusystems.slf4hx.bindings; +import com.furusystems.slf4hx.constants.Levels; +import haxe.Log; +import haxe.PosInfos; + +/** + * ... + * @author Miha Lunar + */ + +class StandardStreamBinding implements ILogBinding +{ + + public function new() {} + + /* INTERFACE slf4hx.bindings.ILogBinding */ + private static var _lineNumber:Int = 0; + public function print(owner:Dynamic, level:String, str:String):Void + { + if (Levels.getID(level) >= Levels.ERROR) { + Sys.stderr().writeString(level+"\t"+str+"\n"); + } else { + Sys.stdout().writeString(level+"\t"+str+"\n"); + } + } + +} \ No newline at end of file