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.
This commit is contained in:
Sansan committed 2026-10-06 11:15:03 +02:00
1 parent 5cdec5cc8f
commit 5831e1e73d
20 files changed
+137 -89

No files matched your search

+7 -7
View File
@@ -20,7 +20,7 @@ var retry_seconds: float = 5.0
## Loads the songs already in the server playlist, then starts preloading new ones.
## Preloading waits for the list, because loading the list clears the playlist.
func load_song_list() -> void:
print("load_song_list")
GameLog.debug("load_song_list")
var song_list_fetched: Callable = func song_list_fetched(data) -> void:
Playlist.clear_song_list()
if typeof(data) == TYPE_ARRAY:
@@ -33,7 +33,7 @@ func load_song_list() -> void:
new_song_object.has_played = true
Playlist.add_to_playlist(new_song_object)
elif data != null:
print("Unexpected data")
GameLog.warning("Unexpected data")
Playlist.update_last_played_song()
song_list_loaded.emit()
fetch_song_if_idle()
@@ -42,7 +42,7 @@ func load_song_list() -> void:
## Starts downloading one more song, which keeps downloading until the cache is full.
func fetch_song() -> void:
print("fetch_song")
GameLog.debug("fetch_song")
Playlist.is_song_downloading = true
_download_random_song(SongObject.new())
@@ -64,7 +64,7 @@ func fill_cache() -> void:
# the server and the game keep the same songs in their playlists.
func _download_random_song(new_song_object: SongObject) -> void:
var song_downloaded: Callable = func song_downloaded(body: PackedByteArray) -> void:
print("song_downloaded")
GameLog.debug("song_downloaded")
var sound: AudioStream = AudioStreamMP3.new()
sound.data = body
new_song_object.song = sound
@@ -80,11 +80,11 @@ func _add_song_to_queue(new_song_object: SongObject) -> void:
func _fetch_song_info(new_song_object: SongObject) -> void:
var song_info_fetched: Callable = func song_info_fetched(data_received: Dictionary) -> void:
print("song_info_fetched")
GameLog.debug("song_info_fetched")
new_song_object.song_number = data_received.SongNo
new_song_object.soundtrack_title = data_received.Soundtrack
new_song_object.song_title = data_received.Song
print("new_song_object: ", new_song_object.to_string())
GameLog.debug("new_song_object: ", new_song_object.to_string())
Playlist.add_to_playlist(new_song_object)
if Playlist.should_preload_more_songs():
fetch_song()
@@ -96,5 +96,5 @@ func _fetch_song_info(new_song_object: SongObject) -> void:
func _retry_later(step: Callable) -> void:
print("Song download failed, retrying in %s seconds" % retry_seconds)
GameLog.warning("Song download failed, retrying in %s seconds" % retry_seconds)
get_tree().create_timer(retry_seconds).timeout.connect(step)