logging!!

This commit is contained in:
Yoshman29
2022-11-02 19:32:46 +01:00
parent 4ae869f17c
commit 23045f3fba
14 changed files with 219 additions and 34 deletions
+9
View File
@@ -17,6 +17,7 @@ class HScript extends Script {
var parser = new hscript.Parser();
parser.allowJSON = parser.allowMetadata = parser.allowTypes = true;
interp.errorHandler = _errorHandler;
interp.variables.set("trace", this.trace);
try {
expr = parser.parseString(code, fileName);
} catch(e) {
@@ -70,4 +71,12 @@ class HScript extends Script {
public override function set(val:String, value:Dynamic) {
interp.variables.set(val, value);
}
public override function trace(v:Dynamic) {
var posInfo = interp.posInfos();
Logs.traceColored([
Logs.logText('${fileName}:${posInfo.lineNumber}: ', GREEN),
Logs.logText(Std.string(v))
], TRACE);
}
}