Skip to content

Commit

Permalink
efficient client-side file logging
Browse files Browse the repository at this point in the history
  • Loading branch information
evolutionleo committed Mar 6, 2023
1 parent d3ee69b commit 2f3220f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Client/scripts/NetworkingEvents/NetworkingEvents.gml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function onDisconnect() {
}

function onIncompatible(server_game_version) {
show_message(stf("Incompatible client version - %! (Server version is %)", GAME_VERSION, server_game_version))
show_message(str_format("Incompatible client version - %! (Server version is %)", GAME_VERSION, server_game_version))
game_end()
}

Expand Down
17 changes: 6 additions & 11 deletions Client/scripts/Trace/Trace.gml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// some useful utility functions


///@function trace(... )
function trace(r) {
r = string(r)
Expand All @@ -15,14 +14,13 @@ function trace(r) {
}
}
show_debug_message(r)
// slow af
//debug_log(r)
}


#macro stf str_format
#macro printf trace
#macro console_log trace
global.__recently_logged = ""
time_source_create(time_source_global, 10, time_source_units_frames, function() {
debug_log(global.__recently_logged)
global.__recently_logged = ""
}, [], -1)

///@param str
function str_format(str)
Expand All @@ -41,10 +39,7 @@ function str_format(str)
return str
}

function debug_log(str, file) {
if is_undefined(file)
file = "log.txt"

function debug_log(str, file = "client_log.txt") {
global.logfile = file_text_open_append(working_directory+file)
var prefix = "[" + window_get_caption() + "]" + "[" + date_datetime_string(date_current_datetime()) + "]"
str = prefix + str
Expand Down

0 comments on commit 2f3220f

Please sign in to comment.