Skip to content

Commit

Permalink
Add PoorManLog
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Apr 12, 2024
1 parent 21d1612 commit 8d5eaef
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/hello_imgui/internal/backend_impls/abstract_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "hello_imgui/internal/menu_statusbar.h"
#include "hello_imgui/internal/platform/ini_folder_locations.h"
#include "hello_imgui/internal/inicpp.h"
#include "hello_imgui/internal/poor_man_log.h"
#include "imgui.h"

#include "hello_imgui/internal/imgui_global_context.h" // must be included before imgui_internal.h
Expand Down Expand Up @@ -441,11 +442,12 @@ void ReadDpiAwareParams(const std::string& appIniSettingLocation, DpiAwareParams
void _LogDpiParams(const HelloImGui::DpiAwareParams& dpiAwareParams)
{
auto &io = ImGui::GetIO();
printf("dpiAwareParams: dpiWindowSizeFactor=%f\n", dpiAwareParams.dpiWindowSizeFactor);
printf("dpiAwareParams: fontRenderingScale=%f\n", dpiAwareParams.fontRenderingScale);
printf("dpiAwareParams: DpiFontLoadingFactor()=%f\n", dpiAwareParams.DpiFontLoadingFactor());
printf(" ImGui FontGlobalScale: %f\n", io.FontGlobalScale);
printf(" ImGui DisplayFramebufferScale=%f, %f\n", io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y);
std::stringstream msg;
PoorManLog("dpiAwareParams: dpiWindowSizeFactor=%f\n", dpiAwareParams.dpiWindowSizeFactor);
PoorManLog("dpiAwareParams: fontRenderingScale=%f\n", dpiAwareParams.fontRenderingScale);
PoorManLog("dpiAwareParams: DpiFontLoadingFactor()=%f\n", dpiAwareParams.DpiFontLoadingFactor());
PoorManLog(" ImGui FontGlobalScale: %f\n", io.FontGlobalScale);
PoorManLog(" ImGui DisplayFramebufferScale=%f, %f\n", io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y);
}


Expand Down
31 changes: 31 additions & 0 deletions src/hello_imgui/internal/poor_man_log.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <string>
#include <cstdio>

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, ...)
{
// call _DoSnPrintf
va_list args;
va_start(args, msg);
std::string buffer = _DoSnPrintf(msg, args);
va_end(args);

#ifdef _MSC_VER
OutputDebugStringA(buffer.c_str());
#else
printf("%s", buffer.c_str());
#endif
}
}
4 changes: 4 additions & 0 deletions src/hello_imgui/internal/poor_man_log.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace HelloImGui
{
void PoorManLog(const char* msg, ...);
}

0 comments on commit 8d5eaef

Please sign in to comment.