summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/io/logger.cpp12
-rw-r--r--drivers/unix/os_unix.cpp26
-rw-r--r--platform/osx/os_osx.mm35
-rw-r--r--platform/windows/windows_terminal_logger.cpp68
4 files changed, 59 insertions, 82 deletions
diff --git a/core/io/logger.cpp b/core/io/logger.cpp
index c3ea0d024e..4d732332d5 100644
--- a/core/io/logger.cpp
+++ b/core/io/logger.cpp
@@ -58,12 +58,12 @@ void Logger::log_error(const char *p_function, const char *p_file, int p_line, c
return;
}
- const char *err_type = "**ERROR**";
+ const char *err_type = "ERROR";
switch (p_type) {
- case ERR_ERROR: err_type = "**ERROR**"; break;
- case ERR_WARNING: err_type = "**WARNING**"; break;
- case ERR_SCRIPT: err_type = "**SCRIPT ERROR**"; break;
- case ERR_SHADER: err_type = "**SHADER ERROR**"; break;
+ case ERR_ERROR: err_type = "ERROR"; break;
+ case ERR_WARNING: err_type = "WARNING"; break;
+ case ERR_SCRIPT: err_type = "SCRIPT ERROR"; break;
+ case ERR_SHADER: err_type = "SHADER ERROR"; break;
default: ERR_PRINT("Unknown error type"); break;
}
@@ -74,7 +74,7 @@ void Logger::log_error(const char *p_function, const char *p_file, int p_line, c
err_details = p_code;
logf_error("%s: %s\n", err_type, err_details);
- logf_error(" At: %s:%i:%s() - %s\n", p_file, p_line, p_function, p_code);
+ logf_error(" at: %s (%s:%i) - %s\n", p_function, p_file, p_line, p_code);
}
void Logger::logf(const char *p_format, ...) {
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index c5eb343cc8..2d8d37b2f1 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -559,34 +559,34 @@ void UnixTerminalLogger::log_error(const char *p_function, const char *p_file, i
// This prevents Godot from writing ANSI escape codes when redirecting
// stdout and stderr to a file.
const bool tty = isatty(fileno(stdout));
- const char *red = tty ? "\E[0;31m" : "";
+ const char *gray = tty ? "\E[0;90m" : "";
+ const char *red = tty ? "\E[0;91m" : "";
const char *red_bold = tty ? "\E[1;31m" : "";
- const char *yellow = tty ? "\E[0;33m" : "";
+ const char *yellow = tty ? "\E[0;93m" : "";
const char *yellow_bold = tty ? "\E[1;33m" : "";
- const char *magenta = tty ? "\E[0;35m" : "";
+ const char *magenta = tty ? "\E[0;95m" : "";
const char *magenta_bold = tty ? "\E[1;35m" : "";
- const char *cyan = tty ? "\E[0;36m" : "";
+ const char *cyan = tty ? "\E[0;96m" : "";
const char *cyan_bold = tty ? "\E[1;36m" : "";
const char *reset = tty ? "\E[0m" : "";
- const char *bold = tty ? "\E[1m" : "";
switch (p_type) {
case ERR_WARNING:
- logf_error("%sWARNING: %s: %s%s%s\n", yellow_bold, p_function, reset, bold, err_details);
- logf_error("%s At: %s:%i.%s\n", yellow, p_file, p_line, reset);
+ logf_error("%sWARNING:%s %s\n", yellow_bold, yellow, err_details);
+ logf_error("%s at: %s (%s:%i)%s\n", gray, p_function, p_file, p_line, reset);
break;
case ERR_SCRIPT:
- logf_error("%sSCRIPT ERROR: %s: %s%s%s\n", magenta_bold, p_function, reset, bold, err_details);
- logf_error("%s At: %s:%i.%s\n", magenta, p_file, p_line, reset);
+ logf_error("%sSCRIPT ERROR:%s %s\n", magenta_bold, magenta, err_details);
+ logf_error("%s at: %s (%s:%i)%s\n", gray, p_function, p_file, p_line, reset);
break;
case ERR_SHADER:
- logf_error("%sSHADER ERROR: %s: %s%s%s\n", cyan_bold, p_function, reset, bold, err_details);
- logf_error("%s At: %s:%i.%s\n", cyan, p_file, p_line, reset);
+ logf_error("%sSHADER ERROR:%s %s\n", cyan_bold, cyan, err_details);
+ logf_error("%s at: %s (%s:%i)%s\n", gray, p_function, p_file, p_line, reset);
break;
case ERR_ERROR:
default:
- logf_error("%sERROR: %s: %s%s%s\n", red_bold, p_function, reset, bold, err_details);
- logf_error("%s At: %s:%i.%s\n", red, p_file, p_line, reset);
+ logf_error("%sERROR:%s %s\n", red_bold, red, err_details);
+ logf_error("%s at: %s (%s:%i)%s\n", gray, p_function, p_file, p_line, reset);
break;
}
}
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index bc77ac3cfd..314f369dc6 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -1724,42 +1724,39 @@ public:
case ERR_WARNING:
if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_12) {
os_log_info(OS_LOG_DEFAULT,
- "WARNING: %{public}s: %{public}s\nAt: %{public}s:%i.",
- p_function, err_details, p_file, p_line);
+ "WARNING: %{public}s\nat: %{public}s (%{public}s:%i)",
+ err_details, p_function, p_file, p_line);
}
- logf_error("\E[1;33mWARNING: %s: \E[0m\E[1m%s\n", p_function,
- err_details);
- logf_error("\E[0;33m At: %s:%i.\E[0m\n", p_file, p_line);
+ logf_error("\E[1;33mWARNING:\E[0;93m %s\n", err_details);
+ logf_error("\E[0;90m at: %s (%s:%i)\E[0m\n", p_function, p_file, p_line);
break;
case ERR_SCRIPT:
if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_12) {
os_log_error(OS_LOG_DEFAULT,
- "SCRIPT ERROR: %{public}s: %{public}s\nAt: %{public}s:%i.",
- p_function, err_details, p_file, p_line);
+ "SCRIPT ERROR: %{public}s\nat: %{public}s (%{public}s:%i)",
+ err_details, p_function, p_file, p_line);
}
- logf_error("\E[1;35mSCRIPT ERROR: %s: \E[0m\E[1m%s\n", p_function,
- err_details);
- logf_error("\E[0;35m At: %s:%i.\E[0m\n", p_file, p_line);
+ logf_error("\E[1;35mSCRIPT ERROR:\E[0;95m %s\n", err_details);
+ logf_error("\E[0;90m at: %s (%s:%i)\E[0m\n", p_function, p_file, p_line);
break;
case ERR_SHADER:
if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_12) {
os_log_error(OS_LOG_DEFAULT,
- "SHADER ERROR: %{public}s: %{public}s\nAt: %{public}s:%i.",
- p_function, err_details, p_file, p_line);
+ "SHADER ERROR: %{public}s\nat: %{public}s (%{public}s:%i)",
+ err_details, p_function, p_file, p_line);
}
- logf_error("\E[1;36mSHADER ERROR: %s: \E[0m\E[1m%s\n", p_function,
- err_details);
- logf_error("\E[0;36m At: %s:%i.\E[0m\n", p_file, p_line);
+ logf_error("\E[1;36mSHADER ERROR:\E[0;96m %s\n", err_details);
+ logf_error("\E[0;90m at: %s (%s:%i)\E[0m\n", p_function, p_file, p_line);
break;
case ERR_ERROR:
default:
if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_12) {
os_log_error(OS_LOG_DEFAULT,
- "ERROR: %{public}s: %{public}s\nAt: %{public}s:%i.",
- p_function, err_details, p_file, p_line);
+ "ERROR: %{public}s\nat: %{public}s (%{public}s:%i)",
+ err_details, p_function, p_file, p_line);
}
- logf_error("\E[1;31mERROR: %s: \E[0m\E[1m%s\n", p_function, err_details);
- logf_error("\E[0;31m At: %s:%i.\E[0m\n", p_file, p_line);
+ logf_error("\E[1;31mERROR:\E[0;91m %s\n", err_details);
+ logf_error("\E[0;90m at: %s (%s:%i)\E[0m\n", p_function, p_file, p_line);
break;
}
}
diff --git a/platform/windows/windows_terminal_logger.cpp b/platform/windows/windows_terminal_logger.cpp
index 8eb6adc27b..520b654b94 100644
--- a/platform/windows/windows_terminal_logger.cpp
+++ b/platform/windows/windows_terminal_logger.cpp
@@ -85,7 +85,6 @@ void WindowsTerminalLogger::log_error(const char *p_function, const char *p_file
CONSOLE_SCREEN_BUFFER_INFO sbi; //original
GetConsoleScreenBufferInfo(hCon, &sbi);
- WORD current_fg = sbi.wAttributes & (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
WORD current_bg = sbi.wAttributes & (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY);
uint32_t basecol = 0;
@@ -98,53 +97,34 @@ void WindowsTerminalLogger::log_error(const char *p_function, const char *p_file
basecol |= current_bg;
- if (p_rationale && p_rationale[0]) {
-
- SetConsoleTextAttribute(hCon, basecol | FOREGROUND_INTENSITY);
- switch (p_type) {
- case ERR_ERROR: logf("ERROR: "); break;
- case ERR_WARNING: logf("WARNING: "); break;
- case ERR_SCRIPT: logf("SCRIPT ERROR: "); break;
- case ERR_SHADER: logf("SHADER ERROR: "); break;
- }
-
- SetConsoleTextAttribute(hCon, current_fg | current_bg | FOREGROUND_INTENSITY);
- logf("%s\n", p_rationale);
+ SetConsoleTextAttribute(hCon, basecol | FOREGROUND_INTENSITY);
+ switch (p_type) {
+ case ERR_ERROR: logf("ERROR:"); break;
+ case ERR_WARNING: logf("WARNING:"); break;
+ case ERR_SCRIPT: logf("SCRIPT ERROR:"); break;
+ case ERR_SHADER: logf("SHADER ERROR:"); break;
+ }
- SetConsoleTextAttribute(hCon, basecol);
- switch (p_type) {
- case ERR_ERROR: logf(" At: "); break;
- case ERR_WARNING: logf(" At: "); break;
- case ERR_SCRIPT: logf(" At: "); break;
- case ERR_SHADER: logf(" At: "); break;
- }
+ SetConsoleTextAttribute(hCon, basecol);
+ if (p_rationale && p_rationale[0]) {
+ logf(" %s\n", p_rationale);
+ } else {
+ logf(" %s\n", p_code);
+ }
- SetConsoleTextAttribute(hCon, current_fg | current_bg);
- logf("%s:%i\n", p_file, p_line);
+ // `FOREGROUND_INTENSITY` alone results in gray text.
+ SetConsoleTextAttribute(hCon, FOREGROUND_INTENSITY);
+ switch (p_type) {
+ case ERR_ERROR: logf(" at: "); break;
+ case ERR_WARNING: logf(" at: "); break;
+ case ERR_SCRIPT: logf(" at: "); break;
+ case ERR_SHADER: logf(" at: "); break;
+ }
+ if (p_rationale && p_rationale[0]) {
+ logf("(%s:%i)\n", p_file, p_line);
} else {
-
- SetConsoleTextAttribute(hCon, basecol | FOREGROUND_INTENSITY);
- switch (p_type) {
- case ERR_ERROR: logf("ERROR: %s: ", p_function); break;
- case ERR_WARNING: logf("WARNING: %s: ", p_function); break;
- case ERR_SCRIPT: logf("SCRIPT ERROR: %s: ", p_function); break;
- case ERR_SHADER: logf("SCRIPT ERROR: %s: ", p_function); break;
- }
-
- SetConsoleTextAttribute(hCon, current_fg | current_bg | FOREGROUND_INTENSITY);
- logf("%s\n", p_code);
-
- SetConsoleTextAttribute(hCon, basecol);
- switch (p_type) {
- case ERR_ERROR: logf(" At: "); break;
- case ERR_WARNING: logf(" At: "); break;
- case ERR_SCRIPT: logf(" At: "); break;
- case ERR_SHADER: logf(" At: "); break;
- }
-
- SetConsoleTextAttribute(hCon, current_fg | current_bg);
- logf("%s:%i\n", p_file, p_line);
+ logf("%s (%s:%i)\n", p_function, p_file, p_line);
}
SetConsoleTextAttribute(hCon, sbi.wAttributes);