|
|
@ -222,33 +222,47 @@ void trace(String* string) { |
|
|
|
#undef BACKTRACE_MAX_FRAMES
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void _debug(const char* format, ...) { |
|
|
|
void _debug( |
|
|
|
const char* date, |
|
|
|
const char* time, |
|
|
|
const char* filename, |
|
|
|
const int line, |
|
|
|
const char* format, |
|
|
|
... |
|
|
|
) { |
|
|
|
ULE_TYPES_H_FTAG; |
|
|
|
if (format == null) { |
|
|
|
print("%sdebug:%s null\n", ANSI_BLUE, ANSI_RESET); |
|
|
|
print("[%s, %s] [%s:%d] %sdebug:%s null\n", date, time, filename, line, ANSI_BLUE, ANSI_RESET); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
va_list args; |
|
|
|
va_start(args, format); |
|
|
|
|
|
|
|
print("%sdebug:%s ", ANSI_BLUE, ANSI_RESET); |
|
|
|
print("[%s, %s] [%s:%d] %sdebug:%s ", date, time, filename, line, ANSI_BLUE, ANSI_RESET); |
|
|
|
vprintln(format, args); |
|
|
|
|
|
|
|
va_end(args); |
|
|
|
} |
|
|
|
|
|
|
|
void _warn(const char* format, ...) { |
|
|
|
void _warn( |
|
|
|
const char* date, |
|
|
|
const char* time, |
|
|
|
const char* filename, |
|
|
|
const int line, |
|
|
|
const char* format, |
|
|
|
... |
|
|
|
) { |
|
|
|
ULE_TYPES_H_FTAG; |
|
|
|
if (format == null) { |
|
|
|
print("%swarning:%s null\n", ANSI_YELLOW, ANSI_RESET); |
|
|
|
print("[%s, %s] [%s:%d] %swarning:%s null\n", date, time, filename, line, ANSI_YELLOW, ANSI_RESET); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
va_list args; |
|
|
|
va_start(args, format); |
|
|
|
|
|
|
|
print("%swarning:%s ", ANSI_YELLOW, ANSI_RESET); |
|
|
|
print("[%s, %s] [%s:%d] %swarning:%s ", date, time, filename, line, ANSI_YELLOW, ANSI_RESET); |
|
|
|
vprintln(format, args); |
|
|
|
|
|
|
|
va_end(args); |
|
|
@ -264,11 +278,18 @@ void setCustomDieBehavior(void (*dieBehavior)(const char* string)) { |
|
|
|
// for fatal errors which may occur at runtime, even on a release binary.
|
|
|
|
// if a fatal error should not occur at runtime on a release binary, consider preferring 'massert'
|
|
|
|
// it's unclear when you should use asserts vs. die actually. idk man, they kinda do the same thing right now
|
|
|
|
void die(const char* format, ...) { |
|
|
|
void _die( |
|
|
|
const char* date, |
|
|
|
const char* time, |
|
|
|
const char* filename, |
|
|
|
const int line, |
|
|
|
const char* format, |
|
|
|
... |
|
|
|
) { |
|
|
|
ULE_TYPES_H_FTAG; |
|
|
|
if (format == null) { |
|
|
|
if (customDie == null) { |
|
|
|
print("%serror:%s (unspecified error)\n", ANSI_RED, ANSI_RESET); |
|
|
|
print("[%s, %s] [%s:%d] %serror:%s (unspecified error)", date, time, filename, line, ANSI_RED, ANSI_RESET); |
|
|
|
trace(); |
|
|
|
exit(1); |
|
|
|
return; |
|
|
@ -285,7 +306,7 @@ void die(const char* format, ...) { |
|
|
|
va_start(args, format); |
|
|
|
|
|
|
|
if (customDie == null) { |
|
|
|
println("%serror:%s", ANSI_RED, ANSI_RESET); |
|
|
|
println("[%s, %s] [%s:%d] %serror:%s ", date, time, filename, line, ANSI_RED, ANSI_RESET); |
|
|
|
vprintln(format, args); |
|
|
|
println(); |
|
|
|
|
|
|
|