2022-01-25 04:05:30 +01:00
|
|
|
function _log_template() {
|
|
|
|
return string(current_year) + "/" + string(current_month) + "/" + string(current_day)
|
2022-01-13 05:24:03 +01:00
|
|
|
+ " " + string(current_hour) + ":" + string(current_minute) + ":" + string(current_second)
|
|
|
|
+ " > ";
|
2022-01-25 04:05:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function __log(title, str, fname = "log.txt") {
|
|
|
|
var path = DIRECTORY + fname;
|
|
|
|
var f = file_text_open_append(path);
|
|
|
|
var t = _log_template();
|
2022-01-13 05:24:03 +01:00
|
|
|
file_text_write_string(f, string(title) + t + string(str) + "\n");
|
|
|
|
file_text_close(f);
|
|
|
|
|
|
|
|
show_debug_message(str);
|
|
|
|
}
|
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
function log_message(title, str, icon = noone) {
|
2022-11-14 03:16:15 +01:00
|
|
|
__log("[MESSAGE] ", string(title) + ": " + string(str));
|
|
|
|
|
2022-12-22 03:09:55 +01:00
|
|
|
return noti_status(string(title) + ": " + string(str), icon);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function log_warning(title, str) {
|
2022-11-14 03:16:15 +01:00
|
|
|
__log("[WARNING] ", string(title) + ": " + string(str));
|
|
|
|
|
2022-12-22 03:09:55 +01:00
|
|
|
return noti_warning(string(title) + ": " + string(str));
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function log_crash(str) {
|
|
|
|
__log("[ERROR] ", string(str));
|
2022-11-14 03:16:15 +01:00
|
|
|
|
2022-12-22 03:09:55 +01:00
|
|
|
return noti_error(string(str));
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function log_newline() {
|
|
|
|
var path = DIRECTORY + "log.txt";
|
|
|
|
var f = file_text_open_append(path);
|
|
|
|
file_text_writeln(f);
|
|
|
|
file_text_close(f);
|
|
|
|
}
|
|
|
|
|
2022-01-25 04:05:30 +01:00
|
|
|
function log_clear() {
|
|
|
|
var path = DIRECTORY + "log.txt";
|
|
|
|
if(file_exists(path))
|
|
|
|
file_delete(path);
|
|
|
|
}
|
2022-12-22 03:09:55 +01:00
|
|
|
|
|
|
|
function exception_print(e) {
|
|
|
|
var str = exception_print(e) + "\n\n\n=== Stack trace ===\n";
|
|
|
|
|
|
|
|
for( var i = 0; i < array_length(e.stacktrace); i++ ) {
|
|
|
|
str += e.stacktrace[i] + "\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
/*
|
2022-01-13 05:24:03 +01:00
|
|
|
exception_unhandled_handler(function(ex) {
|
2022-01-16 05:17:35 +01:00
|
|
|
var tt = "\n-------------------------- OH NO --------------------------\n\n";
|
2022-01-13 05:24:03 +01:00
|
|
|
tt += ex.longMessage;
|
2022-01-18 05:31:19 +01:00
|
|
|
tt += "\n-------------------------- STACK TRACE --------------------------\n\n";
|
2022-01-17 08:52:51 +01:00
|
|
|
for( var i = 0; i < array_length(ex.stacktrace); i++ ) {
|
|
|
|
tt += ex.stacktrace[i] + "\n";
|
|
|
|
}
|
|
|
|
tt += "\n---------------------------- :( ----------------------------\n";
|
2022-01-13 05:24:03 +01:00
|
|
|
log_crash(tt);
|
|
|
|
log_message("SESSION", "Ended with error");
|
|
|
|
|
2022-01-17 08:52:51 +01:00
|
|
|
var tt = "\n-------------------------- OH NO --------------------------\n\n";
|
|
|
|
tt += ex.longMessage;
|
|
|
|
tt += "\n---------------------------- :( ----------------------------\n";
|
2022-01-19 03:51:53 +01:00
|
|
|
tt += "\nError message saved to clipboard";
|
2022-01-13 05:24:03 +01:00
|
|
|
tt += "\n\nVisit crash log from " + string(DIRECTORY + "log.txt") + " for more information";
|
|
|
|
show_error(tt, true);
|
2022-01-19 03:51:53 +01:00
|
|
|
clipboard_set_text(tt);
|
2022-01-13 05:24:03 +01:00
|
|
|
return 0;
|
|
|
|
});
|