Core: Unify display of error type prefixes
This commit is contained in:
@ -46,47 +46,38 @@ void MacOSTerminalLogger::log_error(const char *p_function, const char *p_file,
|
||||
err_details = p_code;
|
||||
}
|
||||
|
||||
const char *indent = "";
|
||||
const char *bold_color;
|
||||
const char *normal_color;
|
||||
switch (p_type) {
|
||||
case ERR_WARNING:
|
||||
indent = " ";
|
||||
os_log_error(OS_LOG_DEFAULT,
|
||||
"WARNING: %{public}s\nat: %{public}s (%{public}s:%i)",
|
||||
err_details, p_function, p_file, p_line);
|
||||
logf_error("\E[1;33mWARNING:\E[0;93m %s\n", err_details);
|
||||
logf_error("\E[0;90m%sat: %s (%s:%i)\E[0m\n", indent, p_function, p_file, p_line);
|
||||
bold_color = "\E[1;33m";
|
||||
normal_color = "\E[0;93m";
|
||||
break;
|
||||
case ERR_SCRIPT:
|
||||
indent = " ";
|
||||
os_log_error(OS_LOG_DEFAULT,
|
||||
"SCRIPT ERROR: %{public}s\nat: %{public}s (%{public}s:%i)",
|
||||
err_details, p_function, p_file, p_line);
|
||||
logf_error("\E[1;35mSCRIPT ERROR:\E[0;95m %s\n", err_details);
|
||||
logf_error("\E[0;90m%sat: %s (%s:%i)\E[0m\n", indent, p_function, p_file, p_line);
|
||||
bold_color = "\E[1;35m";
|
||||
normal_color = "\E[0;95m";
|
||||
break;
|
||||
case ERR_SHADER:
|
||||
indent = " ";
|
||||
os_log_error(OS_LOG_DEFAULT,
|
||||
"SHADER ERROR: %{public}s\nat: %{public}s (%{public}s:%i)",
|
||||
err_details, p_function, p_file, p_line);
|
||||
logf_error("\E[1;36mSHADER ERROR:\E[0;96m %s\n", err_details);
|
||||
logf_error("\E[0;90m%sat: %s (%s:%i)\E[0m\n", indent, p_function, p_file, p_line);
|
||||
bold_color = "\E[1;36m";
|
||||
normal_color = "\E[0;96m";
|
||||
break;
|
||||
case ERR_ERROR:
|
||||
default:
|
||||
indent = " ";
|
||||
os_log_error(OS_LOG_DEFAULT,
|
||||
"ERROR: %{public}s\nat: %{public}s (%{public}s:%i)",
|
||||
err_details, p_function, p_file, p_line);
|
||||
logf_error("\E[1;31mERROR:\E[0;91m %s\n", err_details);
|
||||
logf_error("\E[0;90m%sat: %s (%s:%i)\E[0m\n", indent, p_function, p_file, p_line);
|
||||
bold_color = "\E[1;31m";
|
||||
normal_color = "\E[0;91m";
|
||||
break;
|
||||
}
|
||||
|
||||
os_log_error(OS_LOG_DEFAULT,
|
||||
"%{public}s: %{public}s\nat: %{public}s (%{public}s:%i)",
|
||||
error_type_string(p_type), err_details, p_function, p_file, p_line);
|
||||
logf_error("%s%s:%s %s\n", bold_color, error_type_string(p_type), normal_color, err_details);
|
||||
logf_error("\E[0;90m%sat: %s (%s:%i)\E[0m\n", error_type_indent(p_type), p_function, p_file, p_line);
|
||||
|
||||
for (const Ref<ScriptBacktrace> &backtrace : p_script_backtraces) {
|
||||
if (!backtrace->is_empty()) {
|
||||
os_log_error(OS_LOG_DEFAULT, "%{public}s", backtrace->format().utf8().get_data());
|
||||
logf_error("\E[0;90m%s\E[0m\n", backtrace->format(strlen(indent)).utf8().get_data());
|
||||
logf_error("\E[0;90m%s\E[0m\n", backtrace->format(strlen(error_type_indent(p_type))).utf8().get_data());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,9 +90,6 @@ void WindowsTerminalLogger::log_error(const char *p_function, const char *p_file
|
||||
|
||||
uint32_t basecol = 0;
|
||||
switch (p_type) {
|
||||
case ERR_ERROR:
|
||||
basecol = FOREGROUND_RED;
|
||||
break;
|
||||
case ERR_WARNING:
|
||||
basecol = FOREGROUND_RED | FOREGROUND_GREEN;
|
||||
break;
|
||||
@ -102,30 +99,16 @@ void WindowsTerminalLogger::log_error(const char *p_function, const char *p_file
|
||||
case ERR_SHADER:
|
||||
basecol = FOREGROUND_GREEN | FOREGROUND_BLUE;
|
||||
break;
|
||||
case ERR_ERROR:
|
||||
default:
|
||||
basecol = FOREGROUND_RED;
|
||||
break;
|
||||
}
|
||||
|
||||
basecol |= current_bg;
|
||||
|
||||
SetConsoleTextAttribute(hCon, basecol | FOREGROUND_INTENSITY);
|
||||
const char *indent = "";
|
||||
switch (p_type) {
|
||||
case ERR_ERROR:
|
||||
indent = " ";
|
||||
logf_error("ERROR:");
|
||||
break;
|
||||
case ERR_WARNING:
|
||||
indent = " ";
|
||||
logf_error("WARNING:");
|
||||
break;
|
||||
case ERR_SCRIPT:
|
||||
indent = " ";
|
||||
logf_error("SCRIPT ERROR:");
|
||||
break;
|
||||
case ERR_SHADER:
|
||||
indent = " ";
|
||||
logf_error("SHADER ERROR:");
|
||||
break;
|
||||
}
|
||||
logf_error("%s:", error_type_string(p_type));
|
||||
|
||||
SetConsoleTextAttribute(hCon, basecol);
|
||||
if (p_rationale && p_rationale[0]) {
|
||||
@ -137,14 +120,14 @@ void WindowsTerminalLogger::log_error(const char *p_function, const char *p_file
|
||||
// `FOREGROUND_INTENSITY` alone results in gray text.
|
||||
SetConsoleTextAttribute(hCon, FOREGROUND_INTENSITY);
|
||||
if (p_rationale && p_rationale[0]) {
|
||||
logf_error("%sat: (%s:%i)\n", indent, p_file, p_line);
|
||||
logf_error("%sat: (%s:%i)\n", error_type_indent(p_type), p_file, p_line);
|
||||
} else {
|
||||
logf_error("%sat: %s (%s:%i)\n", indent, p_function, p_file, p_line);
|
||||
logf_error("%sat: %s (%s:%i)\n", error_type_indent(p_type), p_function, p_file, p_line);
|
||||
}
|
||||
|
||||
for (const Ref<ScriptBacktrace> &backtrace : p_script_backtraces) {
|
||||
if (!backtrace->is_empty()) {
|
||||
logf_error("%s\n", backtrace->format(strlen(indent)).utf8().get_data());
|
||||
logf_error("%s\n", backtrace->format(strlen(error_type_indent(p_type))).utf8().get_data());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user