Add Sweetlogger

This commit is contained in:
JonShard
2026-08-10 13:46:51 +02:00
parent bf31f85b02
commit 7648ecbac9
35 changed files with 608 additions and 223 deletions
+2 -2
View File
@@ -1419,11 +1419,11 @@ func _open_log() -> void:
path = OS.get_environment("TEMP").path_join("vryhungry_mptest_%s.log" % role)
_log_file = FileAccess.open(path, FileAccess.WRITE)
_log_path = ProjectSettings.globalize_path(path)
print("[MPTEST] step log -> %s" % _log_path)
SweetLogger.info("[MPTEST] step log -> {0}", [_log_path], "mp_test_driver.gd", "_open_log")
func _log(s: String) -> void:
print("[MPTEST %s] %s" % [_role, s])
SweetLogger.info("[MPTEST {0}] {1}", [_role, s], "mp_test_driver.gd", "_log")
if _log_file:
_log_file.store_line(s)
_log_file.flush()
+5 -5
View File
@@ -42,7 +42,7 @@ func _run() -> void:
_clear_previous_results(logs_dir)
print_rich("[b]Running the multiplayer test suite...[/b]")
print(" the editor will be unresponsive until it finishes (~2 minutes)")
SweetLogger.info("the editor will be unresponsive until it finishes (~2 minutes)", [], "run_tests_in_editor.gd", "_run")
var server_pid := _launch(exe, project_dir, ["--server"], SERVER_SCENE)
if server_pid <= 0:
@@ -61,7 +61,7 @@ func _run() -> void:
OS.delay_msec(500)
waited += 0.5
if OS.is_process_running(server_pid):
print(" timed out after %ds, stopping the instances" % TIMEOUT_SEC)
SweetLogger.warning("timed out after {0}s, stopping the instances", [TIMEOUT_SEC], "run_tests_in_editor.gd", "_run")
OS.kill(server_pid)
if OS.is_process_running(client_pid):
OS.kill(client_pid)
@@ -108,7 +108,7 @@ func _print_report(logs_dir: String) -> void:
push_error("No report at %s — the run did not finish. Check logs/mptest_server.log" % path)
return
var text := FileAccess.get_file_as_string(path)
print("")
SweetLogger.info("", [], "run_tests_in_editor.gd", "_print_report")
# Colour the summary so a failure is obvious in the Output panel.
for line in text.split("\n"):
if line.begins_with("FAIL") or line.contains("RESULT: FAILED"):
@@ -118,8 +118,8 @@ func _print_report(logs_dir: String) -> void:
elif line.begins_with("PASS"):
print_rich("[color=gray]%s[/color]" % line)
else:
print(line)
print("report: %s" % path)
SweetLogger.info("{0}", [line], "run_tests_in_editor.gd", "_print_report")
SweetLogger.info("report: {0}", [path], "run_tests_in_editor.gd", "_print_report")
func _build_gif(project_dir: String, logs_dir: String) -> void:
+2 -2
View File
@@ -3,8 +3,8 @@ extends Node
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
print(get_stations())
print(get_items())
SweetLogger.debug("stations: {0}", [get_stations()], "testworldLoad.gd", "_ready")
SweetLogger.debug("items: {0}", [get_items()], "testworldLoad.gd", "_ready")