cc-haxe/src/kernel/Log.hx

52 lines
1.4 KiB
Haxe
Raw Normal View History

2021-12-20 00:55:30 +00:00
package kernel;
2022-02-20 00:30:32 +00:00
import util.Debug;
2021-12-20 00:55:30 +00:00
import kernel.ui.WindowContext;
import kernel.ui.WindowManager;
import lib.TermWriteable;
import lib.TermIO;
/**
Log messages to specified output.
**/
class Log {
private static final context:WindowContext = WindowManager.instance.createNewContext();
private static var writer:TermIO = new TermIO(context);
private static function setMainoutout(newOutput: TermWriteable) {
writer = new TermIO(newOutput);
}
public static function info(msg: Dynamic, ?pos:haxe.PosInfos){
writer.writeLn("[INFO]["+pos.className+"]: "+Std.string(msg));
2022-02-20 00:30:32 +00:00
#if webconsole
Debug.printWeb("[INFO]["+pos.className+"]: "+Std.string(msg));
#end
2021-12-20 00:55:30 +00:00
}
public static function warn(msg: Dynamic, ?pos:haxe.PosInfos){
writer.writeLn("[WARN]["+pos.className+"]: "+Std.string(msg),Yellow);
2022-02-20 00:30:32 +00:00
#if webconsole
Debug.printWeb("[WARN]["+pos.className+"]: "+Std.string(msg));
#end
2021-12-20 00:55:30 +00:00
}
public static function error(msg: Dynamic,?pos:haxe.PosInfos) {
writer.writeLn("[ERRO]["+pos.className+"]: "+Std.string(msg),Red);
2022-02-20 00:30:32 +00:00
#if webconsole
Debug.printWeb("[ERRO]["+pos.className+"]: "+Std.string(msg));
#end
2021-12-20 00:55:30 +00:00
}
public static function debug(msg: Dynamic,?pos:haxe.PosInfos) {
writer.writeLn("[DEBG]["+pos.className+"]: "+Std.string(msg),Gray);
2022-02-20 00:30:32 +00:00
#if webconsole
Debug.printWeb("[DEBG]["+pos.className+"]: "+Std.string(msg));
#end
2021-12-20 00:55:30 +00:00
}
public static function moveToOutput(addr: String) {
WindowManager.instance.focusContextToOutput(context,addr);
}
}