Files
MusicPlayer/game_log.gd
T
Sansan 5831e1e73d Log through a GameLog autoload instead of print()
GameLog.debug() prints only in debug builds, and GameLog.warning() reports
problems such as unexpected server data or failed downloads.
2026-10-06 11:15:03 +02:00

22 lines
781 B
GDScript

extends Node
## Writes messages about what the game is doing, for finding problems.
##
## Registered as the [code]GameLog[/code] autoload. Use [method debug] instead of
## [code]print()[/code]: the messages show in debug builds and the editor, and are left
## out of released games. Problems the player may notice go through [method warning].
## Prints [param parts] joined together, like [code]print()[/code], in debug builds only.
func debug(...parts: Array) -> void:
if OS.is_debug_build():
print(_join(parts))
## Reports a problem in the editor's debugger and the console, in every build.
func warning(...parts: Array) -> void:
push_warning(_join(parts))
func _join(parts: Array) -> String:
return "".join(parts.map(func(part: Variant) -> String: return str(part)))