From 177a20111f69c78d127a452b8ca57119c84bbd55 Mon Sep 17 00:00:00 2001 From: Miha Date: Sun, 16 Feb 2014 20:59:20 +0100 Subject: [PATCH 1/2] added stdout/stderr output binding --- .../slf4hx/bindings/StandardStreamBinding.hx | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 com/furusystems/slf4hx/bindings/StandardStreamBinding.hx 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 From 453dd18c195955c9ba78d045a09b5a22f37f7c2c Mon Sep 17 00:00:00 2001 From: Miha Lunar Date: Sat, 5 Apr 2014 18:22:42 +0200 Subject: [PATCH 2/2] added socket.io binding --- .../slf4hx/bindings/SocketIOBinding.hx | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 com/furusystems/slf4hx/bindings/SocketIOBinding.hx 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