a LOT of minor stuff

This commit is contained in:
2022-03-05 02:41:30 +01:00
parent ce45bf2726
commit df77704d1c
12 changed files with 90 additions and 56 deletions

View File

@@ -2,12 +2,13 @@ package kernel;
import kernel.ui.WindowContext;
import kernel.ui.WindowManager;
import lib.TermWriteable;
import kernel.ui.TermWriteable;
import lib.TermIO;
#if webconsole
import kernel.net.Net;
import util.Debug;
#end
/**
Log messages to specified output.
**/
@@ -29,34 +30,49 @@ class Log {
}
public static function info(msg:Dynamic, ?pos:haxe.PosInfos) {
writer.writeLn("[INFO][" + pos.className + "]: " + Std.string(msg));
writer.writeLn(logLine("INFO",pos,msg));
#if webconsole
Debug.printWeb("[INFO][" + pos.className + "]: " + Std.string(msg));
Debug.printWeb(logLine("INFO",pos,msg));
#end
}
public static function warn(msg:Dynamic, ?pos:haxe.PosInfos) {
writer.writeLn("[WARN][" + pos.className + "]: " + Std.string(msg), Yellow);
writer.writeLn(logLine("WARN",pos,msg), Yellow);
#if webconsole
Debug.printWeb("[WARN][" + pos.className + "]: " + Std.string(msg));
Debug.printWeb(logLine("WARN",pos,msg));
#end
}
public static function error(msg:Dynamic, ?pos:haxe.PosInfos) {
writer.writeLn("[ERRO][" + pos.className + "]: " + Std.string(msg), Red);
writer.writeLn(logLine("ERRO",pos,msg), Red);
#if webconsole
Debug.printWeb("[ERRO][" + pos.className + "]: " + Std.string(msg));
Debug.printWeb(logLine("ERRO",pos,msg));
#end
}
public static function debug(msg:Dynamic, ?pos:haxe.PosInfos) {
writer.writeLn("[DEBG][" + pos.className + "]: " + Std.string(msg), Gray);
writer.writeLn(logLine("DEBG",pos,msg), Gray);
#if webconsole
Debug.printWeb("[DEBG][" + pos.className + "]: " + Std.string(msg));
Debug.printWeb(logLine("DEBG",pos,msg));
#end
}
public static function silly(msg:Dynamic, ?pos:haxe.PosInfos) {
writer.writeLn(logLine("SILY",pos,msg), LightGrey);
#if webconsole
Debug.printWeb(logLine("SILY",pos,msg));
#end
}
public static function moveToOutput(addr:String) {
WindowManager.instance.focusContextToOutput(context, addr);
}
private static function logLine(tag: String,pos: haxe.PosInfos,msg: Dynamic): String {
#if debug
return '[$tag][${pos.className}:${pos.lineNumber}]: ${Std.string(msg)}';
#else
return '[$tag]: ${Std.string(msg)}';
#end
}
}