logger business

This commit is contained in:
m-aXimilian
2025-06-14 16:39:39 +02:00
committed by Kueffner, Maximilian
parent 566dd112ff
commit 25b0ef0ff5
4 changed files with 50 additions and 19 deletions
+22 -5
View File
@@ -10,6 +10,7 @@
#include "portable-file-dialogs.h"
#include "rendering/CvMatRender.hpp"
#include "uiresources.h"
#include "utilities/ILog.hpp"
using namespace pixelarium::imaging;
@@ -134,7 +135,8 @@ int pixelarium::ui::AppGLFW::Run()
ImGui::DockSpaceOverViewport(ImGui::GetID("Backspace"));
this->MenuBar();
if (demop_)
ImGui::ShowDemoWindow(&this->demop_);
if (this->imagep_)
{
// auto render = render::CvMatRender(this->_img);
@@ -200,6 +202,24 @@ void pixelarium::ui::AppGLFW::MenuBar()
// main menu
if (ImGui::BeginMenu(MAINMENUNAME))
{
if (ImGui::BeginCombo(LOGLEVELSELECT, LOGLEVELS[log_level_]))
{
for (int n = 0; n < IM_ARRAYSIZE(LOGLEVELS); n++)
{
bool is_selected = (LOGLEVELS[log_level_] == LOGLEVELS[n]);
if (ImGui::Selectable(LOGLEVELS[n], is_selected))
{
log_level_ = n;
this->logger_.ChangeLevel(static_cast<utils::log::LogLevel>(1 << log_level_));
}
if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
ImGui::MenuItem(SHOWIMGUIDEMOS, NULL, &this->demop_);
ImGui::EndMenu();
}
@@ -223,10 +243,7 @@ void pixelarium::ui::AppGLFW::LoadImageProt()
auto res{pfd::open_file("Load Inputs", pfd::path::home(), {"All Files", "*"}, pfd::opt::multiselect).result()};
for (auto& p : res)
{
if (this->logger_)
{
this->logger_->Debug(std::format("{}: Creating image {}", __FUNCTION__, p));
}
this->logger_.Debug(std::format("{}: Creating image {}", __FUNCTION__, p));
this->img_ = std::make_shared<PixelariumImage>(p);
this->render_ = pixelarium::render::CvMatRender(this->img_);
+10 -11
View File
@@ -29,19 +29,16 @@ enum LogLevelSelection
class AppGLFW
{
public:
AppGLFW() { this->InitMainWindow(); }
AppGLFW(std::unique_ptr<utils::log::ILog>& log) : AppGLFW()
explicit AppGLFW(std::unique_ptr<utils::log::ILog>& log) : logger_(*log)
{
logger_ = log.get();
if (logger_)
{
logger_->Debug(std::format("{}: Initiating a new window", __FUNCTION__).c_str());
logger_.Debug(std::format("{}: Initiating a new window", __FUNCTION__).c_str());
if (pool_)
{
logger_->Debug(std::format("{}: We have an image resource pool!", __FUNCTION__).c_str());
}
if (pool_)
{
logger_.Debug(std::format("{}: We have an image resource pool!", __FUNCTION__).c_str());
}
this->InitMainWindow();
}
AppGLFW(std::unique_ptr<utils::log::ILog>& log, std::unique_ptr<pixelarium::resources::ImageResourcePool>& pool)
: AppGLFW(log)
@@ -57,13 +54,15 @@ class AppGLFW
private:
// LogLevelSelection log_level_ = static_cast<LogLevelSelection>(0);
utils::log::ILog* logger_;
utils::log::ILog& logger_;
resources::ImageResourcePool* pool_;
GLFWwindow* window = nullptr;
ImGuiWindowFlags window_flags_ = 0;
std::shared_ptr<pixelarium::imaging::PixelariumImage> img_;
pixelarium::render::CvMatRender render_;
bool imagep_{false};
bool demop_{false};
int log_level_{0};
ImVec2 curr_dim_;
};
+8 -2
View File
@@ -1,8 +1,14 @@
#pragma once
/*-- Gets filled in during the cmake configuration step --*/
#cmakedefine PIXELARIUM_TITLE "@PIXELARIUM_TITLE@"
#define MAINMENUNAME "Menu"
#define FILEMENUNAME "File"
#define FILEMENUNAME "File"
#define LOGLEVELSELECT "Log Level"
#define SHOWIMGUIDEMOS "ImGui Demos"
namespace
{
const char* LOGLEVELS[] = {"Trace", "Debug", "Info", "Warning", "Error"};
}