some decouplings (#2)
* logger business * code review * rm c-style array * extract image rendering to view * missing view files * init view abstractions * leverage concepts and provide a templateized Enumerate function * RVO * get rid of some warnings * logger business * code review * rm c-style array * extract image rendering to view * missing view files * init view abstractions * leverage concepts and provide a templateized Enumerate function * RVO * get rid of some warnings * logger business * code review * rm c-style array * init view abstractions * leverage concepts and provide a templateized Enumerate function * RVO * get rid of some warnings * logger business * code review * rm c-style array * init view abstractions * leverage concepts and provide a templateized Enumerate function * RVO * get rid of some warnings * Factor out AppGLFW base class The intention here is to get rid of scaffolding in the consumer application class and allow to focus on the "important bits". * Some cleanup * dump unnecessary dependency * link stuff where needed & use only what's needed * remove deprecation warnings * add gallery toggle * make some includes private * add presets * remove dir locals, use presets instead `projectile-configure-project' in conjunction with CMakePresets.json will allow to configure the project. `projectile-compile-project' does sth similar for the compile command. This is equivalent to something like ~cmake --preset clang-debug && cmake --build build --preset clang-debug~ * use presets in pipeline --------- Co-authored-by: m-aXimilian <keuffnermax@gmail.com>
This commit is contained in:
@@ -14,11 +14,11 @@ enum class LogLevel
|
||||
class ILog
|
||||
{
|
||||
public:
|
||||
virtual void Info(const std::string& msg) = 0;
|
||||
virtual void Debug(const std::string& msg) = 0;
|
||||
virtual void Warn(const std::string& msg) = 0;
|
||||
virtual void Error(const std::string& msg) = 0;
|
||||
virtual void ChangeLevel(LogLevel lvl) = 0;
|
||||
virtual void Info(const std::string& msg) const = 0;
|
||||
virtual void Debug(const std::string& msg) const = 0;
|
||||
virtual void Warn(const std::string& msg) const = 0;
|
||||
virtual void Error(const std::string& msg) const = 0;
|
||||
virtual void ChangeLevel(LogLevel lvl) const = 0;
|
||||
|
||||
virtual ~ILog() {}
|
||||
};
|
||||
|
||||
+30
-17
@@ -1,12 +1,13 @@
|
||||
#include "SpdLogger.hpp"
|
||||
|
||||
#include <spdlog/common.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <spdlog/sinks/basic_file_sink.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "ILog.hpp"
|
||||
|
||||
#include "ILog.hpp"
|
||||
|
||||
using namespace pixelarium::utils::log;
|
||||
|
||||
@@ -18,22 +19,32 @@ SpdLogger::SpdLogger(const std::string& file_sink, const std::string& name)
|
||||
logger_->info("Logger initiated");
|
||||
}
|
||||
|
||||
void SpdLogger::Info(const std::string& msg)
|
||||
{
|
||||
this->logger_->info(msg);
|
||||
}
|
||||
void SpdLogger::Debug(const std::string& msg)
|
||||
{
|
||||
this->logger_->debug(msg);
|
||||
}
|
||||
void SpdLogger::Warn(const std::string& msg)
|
||||
{
|
||||
this->logger_->warn(msg);
|
||||
}
|
||||
void SpdLogger::Error(const std::string& msg) { this->logger_->error(msg); }
|
||||
void SpdLogger::Info(const std::string& msg) const { this->logger_->info(msg); }
|
||||
void SpdLogger::Debug(const std::string& msg) const { this->logger_->debug(msg); }
|
||||
void SpdLogger::Warn(const std::string& msg) const { this->logger_->warn(msg); }
|
||||
void SpdLogger::Error(const std::string& msg) const { this->logger_->error(msg); }
|
||||
|
||||
void SpdLogger::ChangeLevel(LogLevel lvl)
|
||||
void SpdLogger::ChangeLevel(LogLevel lvl) const
|
||||
{
|
||||
constexpr auto LogLevelToString = [](LogLevel l) -> const char*
|
||||
{
|
||||
switch (l)
|
||||
{
|
||||
case LogLevel::Trace:
|
||||
return "Trace";
|
||||
case LogLevel::Debug:
|
||||
return "Debug";
|
||||
case LogLevel::Info:
|
||||
return "Info";
|
||||
case LogLevel::Warn:
|
||||
return "Warn";
|
||||
case LogLevel::Error:
|
||||
return "Error";
|
||||
default:
|
||||
return "Not Found";
|
||||
}
|
||||
};
|
||||
|
||||
switch (lvl)
|
||||
{
|
||||
case LogLevel::Trace:
|
||||
@@ -58,5 +69,7 @@ void SpdLogger::ChangeLevel(LogLevel lvl)
|
||||
spdlog::flush_on(spdlog::level::debug);
|
||||
}
|
||||
|
||||
this->logger_->debug("Changed log level;");
|
||||
// you will only get this message for log levels <= info! I.e., not for error or warning.
|
||||
this->logger_->info(
|
||||
std::format("{}: Changed log level to {}({})", __FUNCTION__, LogLevelToString(lvl), static_cast<int>(lvl)));
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@ class SpdLogger : public ILog
|
||||
public:
|
||||
explicit SpdLogger(const std::string& file_sink, const std::string& name);
|
||||
|
||||
void Info(const std::string& msg) override;
|
||||
void Debug(const std::string& msg) override;
|
||||
void Warn(const std::string& msg) override;
|
||||
void Error(const std::string& msg) override;
|
||||
void ChangeLevel(LogLevel lvl) override;
|
||||
void Info(const std::string& msg) const override;
|
||||
void Debug(const std::string& msg) const override;
|
||||
void Warn(const std::string& msg) const override;
|
||||
void Error(const std::string& msg) const override;
|
||||
void ChangeLevel(LogLevel lvl) const override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<spdlog::logger> logger_;
|
||||
|
||||
Reference in New Issue
Block a user