|
@@ -26,7 +26,7 @@
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#if defined(AK_OS_WINDOWS)
|
|
#if defined(AK_OS_WINDOWS)
|
|
-# include <io.h>
|
|
|
|
|
|
+# include <AK/Windows.h>
|
|
#endif
|
|
#endif
|
|
|
|
|
|
namespace AK {
|
|
namespace AK {
|
|
@@ -1141,6 +1141,10 @@ void vout(LogLevel log_level, StringView fmtstr, TypeErasedFormatParams& params,
|
|
#elif defined(AK_OS_BSD_GENERIC) || defined(AK_OS_HAIKU)
|
|
#elif defined(AK_OS_BSD_GENERIC) || defined(AK_OS_HAIKU)
|
|
auto const* progname = getprogname();
|
|
auto const* progname = getprogname();
|
|
return StringView { progname, strlen(progname) };
|
|
return StringView { progname, strlen(progname) };
|
|
|
|
+#elif defined AK_OS_WINDOWS
|
|
|
|
+ char path[MAX_PATH] = {};
|
|
|
|
+ auto length = GetModuleFileName(NULL, path, MAX_PATH);
|
|
|
|
+ return { path, length };
|
|
#else
|
|
#else
|
|
// FIXME: Implement process_name_helper() for other platforms.
|
|
// FIXME: Implement process_name_helper() for other platforms.
|
|
return StringView {};
|
|
return StringView {};
|
|
@@ -1157,7 +1161,7 @@ static StringView process_name_for_logging()
|
|
if (!process_name_retrieved) {
|
|
if (!process_name_retrieved) {
|
|
auto path = LexicalPath(process_name_helper());
|
|
auto path = LexicalPath(process_name_helper());
|
|
process_name_retrieved = true;
|
|
process_name_retrieved = true;
|
|
- (void)path.basename().copy_characters_to_buffer(process_name_buf, sizeof(process_name_buf));
|
|
|
|
|
|
+ (void)path.title().copy_characters_to_buffer(process_name_buf, sizeof(process_name_buf));
|
|
process_name = { process_name_buf, strlen(process_name_buf) };
|
|
process_name = { process_name_buf, strlen(process_name_buf) };
|
|
}
|
|
}
|
|
return process_name;
|
|
return process_name;
|
|
@@ -1183,6 +1187,13 @@ void set_rich_debug_enabled(bool value)
|
|
is_rich_debug_enabled = value;
|
|
is_rich_debug_enabled = value;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#ifdef AK_OS_WINDOWS
|
|
|
|
+# define YELLOW(str) "\33[93m" str "\33[0m"
|
|
|
|
+static int main_thread_id = GetCurrentThreadId();
|
|
|
|
+// enable ANSI escape sequences
|
|
|
|
+static int dummy = system(" ");
|
|
|
|
+#endif
|
|
|
|
+
|
|
void vdbg(StringView fmtstr, TypeErasedFormatParams& params, bool newline)
|
|
void vdbg(StringView fmtstr, TypeErasedFormatParams& params, bool newline)
|
|
{
|
|
{
|
|
if (!is_debug_enabled)
|
|
if (!is_debug_enabled)
|
|
@@ -1214,7 +1225,11 @@ void vdbg(StringView fmtstr, TypeErasedFormatParams& params, bool newline)
|
|
#else
|
|
#else
|
|
auto process_name = process_name_for_logging();
|
|
auto process_name = process_name_for_logging();
|
|
if (!process_name.is_empty()) {
|
|
if (!process_name.is_empty()) {
|
|
- builder.appendff("{}: ", process_name);
|
|
|
|
|
|
+ int tid = GetCurrentThreadId();
|
|
|
|
+ if (tid == main_thread_id)
|
|
|
|
+ builder.appendff(YELLOW("{}: "), process_name);
|
|
|
|
+ else
|
|
|
|
+ builder.appendff(YELLOW("{}:{}: "), process_name, tid);
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|