class_name GameLog extends RefCounted ## Tagged logging that survives headless runs. ## ## Static rather than an autoload so it works from unit tests and from ## `--script` tool runs, where autoload identifiers are not registered at all. ## The dedicated server has no console UI, so every line carries the role that ## produced it -- that is what makes a captured server log readable later. enum Level { DEBUG, INFO, WARN, ERROR } ## Raise to WARN on a busy server; DEBUG is very chatty at 60 Hz. static var min_level: Level = Level.INFO static var role_tag: String = "?" static func _fmt(level: Level, tag: String, msg: String) -> String: return "[%s][%s][%s] %s" % [Level.keys()[level], role_tag, tag, msg] static func debug(tag: String, msg: String) -> void: if min_level <= Level.DEBUG: print(_fmt(Level.DEBUG, tag, msg)) static func info(tag: String, msg: String) -> void: if min_level <= Level.INFO: print(_fmt(Level.INFO, tag, msg)) static func warn(tag: String, msg: String) -> void: if min_level <= Level.WARN: print(_fmt(Level.WARN, tag, msg)) static func error(tag: String, msg: String) -> void: printerr(_fmt(Level.ERROR, tag, msg))