Misc: Get rid of format string for result logging

This commit is contained in:
Stenzek 2024-05-23 20:52:05 +10:00
parent 9f90f14c48
commit 792717e03e
No known key found for this signature in database
4 changed files with 7 additions and 12 deletions

View file

@ -351,7 +351,7 @@ void Bus::AddTTYCharacter(char ch)
{ {
if (!s_tty_line_buffer.empty()) if (!s_tty_line_buffer.empty())
{ {
Log::Writef("TTY", "", LOGLEVEL_INFO, "\033[1;34m%s\033[0m", s_tty_line_buffer.c_str()); Log::WriteFmt("TTY", "", LOGLEVEL_INFO, "\033[1;34m{}\033[0m", s_tty_line_buffer);
#ifdef _DEBUG #ifdef _DEBUG
if (CPU::IsTraceEnabled()) if (CPU::IsTraceEnabled())
CPU::WriteToExecutionLog("TTY: %s\n", s_tty_line_buffer.c_str()); CPU::WriteToExecutionLog("TTY: %s\n", s_tty_line_buffer.c_str());

View file

@ -103,15 +103,10 @@ const char* Vulkan::VkResultToString(VkResult res)
} }
} }
void Vulkan::LogVulkanResult(const char* func_name, VkResult res, const char* msg, ...) void Vulkan::LogVulkanResult(const char* func_name, VkResult res, std::string_view msg)
{ {
std::va_list ap; Log::WriteFmt("VulkanDevice", func_name, LOGLEVEL_ERROR, "{} (0x{:08X}: {})", msg, static_cast<unsigned>(res),
va_start(ap, msg); VkResultToString(res));
std::string real_msg = StringUtil::StdStringFromFormatV(msg, ap);
va_end(ap);
Log::Writef("VulkanDevice", func_name, LOGLEVEL_ERROR, "%s (%d: %s)", real_msg.c_str(), static_cast<int>(res),
VkResultToString(res));
} }
Vulkan::DescriptorSetLayoutBuilder::DescriptorSetLayoutBuilder() Vulkan::DescriptorSetLayoutBuilder::DescriptorSetLayoutBuilder()

View file

@ -16,14 +16,14 @@
#define ENABLE_VULKAN_DEBUG_OBJECTS 1 #define ENABLE_VULKAN_DEBUG_OBJECTS 1
#endif #endif
#define LOG_VULKAN_ERROR(res, ...) ::Vulkan::LogVulkanResult(__func__, res, __VA_ARGS__) #define LOG_VULKAN_ERROR(res, msg) ::Vulkan::LogVulkanResult(__func__, res, msg)
namespace Vulkan { namespace Vulkan {
// Adds a structure to a chain. // Adds a structure to a chain.
void AddPointerToChain(void* head, const void* ptr); void AddPointerToChain(void* head, const void* ptr);
const char* VkResultToString(VkResult res); const char* VkResultToString(VkResult res);
void LogVulkanResult(const char* func_name, VkResult res, const char* msg, ...); void LogVulkanResult(const char* func_name, VkResult res, std::string_view msg);
class DescriptorSetLayoutBuilder class DescriptorSetLayoutBuilder
{ {

View file

@ -1199,7 +1199,7 @@ void VulkanDevice::WaitForCommandBufferCompletion(u32 index)
} }
else if (res != VK_SUCCESS) else if (res != VK_SUCCESS)
{ {
LOG_VULKAN_ERROR(res, "vkWaitForFences() for cmdbuffer %u failed: ", index); LOG_VULKAN_ERROR(res, TinyString::from_format("vkWaitForFences() for cmdbuffer {} failed: ", index));
m_last_submit_failed.store(true, std::memory_order_release); m_last_submit_failed.store(true, std::memory_order_release);
return; return;
} }