Skip to content

Commit

Permalink
fix poor_man_log
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Apr 12, 2024
1 parent e0d7bbb commit 0da5f1f
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions src/hello_imgui/internal/poor_man_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,26 @@
#include <cstdio>
#include <cstdarg>

#ifdef _MSC_VER
#include <Windows.h>
#endif


namespace HelloImGui
{
std::string _DoSnPrintf(const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
char buffer[2000];
vsnprintf(buffer, sizeof(buffer), fmt, args);
va_end(args);
return std::string(buffer);
}

void PoorManLog(const char* msg, ...)
{
va_list args;
va_start(args, msg);
char buffer[2000];
vsnprintf(buffer, sizeof(buffer), msg, args);
va_end(args);

void PoorManLog(const char* msg, ...)
{
// call _DoSnPrintf
va_list args;
va_start(args, msg);
std::string buffer = _DoSnPrintf(msg, args);
va_end(args);
#ifdef _MSC_VER
OutputDebugString(buffer);
#else
printf("%s", buffer);
#endif
}

#ifdef _MSC_VER
OutputDebugStringA(buffer.c_str());
#else
printf("%s", buffer.c_str());
#endif
}
}

0 comments on commit 0da5f1f

Please sign in to comment.