Skip to content

Commit

Permalink
Merge pull request #19664 from hrydgard/log-current-thread
Browse files Browse the repository at this point in the history
Log "host" thread names when not on EmuThread
  • Loading branch information
hrydgard authored Nov 27, 2024
2 parents 5273d99 + 91c8220 commit cab1650
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Common/GPU/Vulkan/VulkanLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ static VulkanLibraryHandle VulkanLoadLibrary(std::string *errorString) {
return nullptr;
#elif PPSSPP_PLATFORM(UWP)
return nullptr;
#elif PPSSPP_PLATFORM(MACOS) && PPSSPP_ARCH(AMD64)
#elif PPSSPP_PLATFORM(MAC) && PPSSPP_ARCH(AMD64)
// Disable Vulkan on Mac/x86. Too many configurations that don't work with MoltenVK
// for whatever reason.
return nullptr;
Expand Down
21 changes: 18 additions & 3 deletions Common/Log/LogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

#include "Common/Log/StdioListener.h"
#include "Common/TimeUtil.h"
#include "Common/Thread/ThreadUtil.h"
#include "Common/File/FileUtil.h"
#include "Common/StringUtils.h"

Expand Down Expand Up @@ -254,11 +255,23 @@ void LogManager::LogLine(LogLevel level, Log type, const char *file, int line, c
file = fileshort + 1;
}

GetCurrentTimeFormatted(message.timestamp);
const char *threadName;
#if PPSSPP_PLATFORM(WINDOWS) || PPSSPP_PLATFORM(MAC)
const char *hostThreadName = GetCurrentThreadName();
if (strcmp(hostThreadName, "EmuThread") != 0 || !hleCurrentThreadName) {
// Use the host thread name.
threadName = hostThreadName;
} else {
// Use the PSP HLE thread name.
threadName = hleCurrentThreadName;
}
#else
threadName = hleCurrentThreadName;
#endif

if (hleCurrentThreadName) {
if (threadName) {
snprintf(message.header, sizeof(message.header), "%-12.12s %c[%s]: %s:%d",
hleCurrentThreadName, level_to_char[(int)level],
threadName, level_to_char[(int)level],
log.m_shortName,
file, line);
} else {
Expand All @@ -267,6 +280,8 @@ void LogManager::LogLine(LogLevel level, Log type, const char *file, int line, c
log.m_shortName);
}

GetCurrentTimeFormatted(message.timestamp);

char msgBuf[1024];
va_list args_copy;

Expand Down

0 comments on commit cab1650

Please sign in to comment.