Compare commits

..

No commits in common. "8268a07e1b09f6952fc3981fafe72b345d19cb9b" and "3cc0801e8f4703ce4035ce4523acff7fd36a57c3" have entirely different histories.

9 changed files with 53 additions and 14 deletions

View file

@ -26,7 +26,10 @@ class LightRecipe(ConanFile):
self.requires("entt/3.15.0")
self.requires("glfw/3.4")
self.requires("glm/1.0.1")
self.requires("spdlog/1.15.3")
self.requires("spirv-cross/1.4.313.0")
self.requires("stb/cci.20240531")
self.requires("volk/1.3.296.0")
self.requires("yaml-cpp/0.8.0")
self.requires("lz4/1.10.0")

View file

@ -1,2 +1,2 @@
add_library_module(input input.cpp)
target_link_libraries(input PUBLIC glm::glm imgui logger)
target_link_libraries(input PUBLIC spdlog::spdlog glm::glm imgui logger)

View file

@ -1 +1,2 @@
add_library_module(logger logger.cpp)
target_link_libraries(logger PUBLIC spdlog::spdlog)

View file

@ -1,9 +1,15 @@
#pragma once
#include <format>
#include <print>
#include <memory>
#include <spdlog/sinks/basic_file_sink.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/spdlog.h>
/** Severity of a log message. */
/** @brief Severity of a log message.
*
* @note Values reflect spdlog::lvl
*/
enum class LogLvl : uint8_t
{
/** Lowest and most vebose log level, for tracing execution paths and events */
@ -28,7 +34,11 @@ enum class LogLvl : uint8_t
off = 6,
};
/** Simple console logger */
namespace spdlog {
class logger;
}
/** Responsible for logging */
class Logger
{
public:
@ -37,19 +47,26 @@ public:
template<typename... Args>
void static log(LogLvl lvl, std::format_string<Args...> fmt, Args &&...args)
{
std::ignore = lvl;
std::println(fmt, std::forward<Args>(args)...);
instance().spd_logger->log(
(spdlog::level::level_enum)lvl,
std::format(fmt, std::forward<Args>(args)...)
);
}
void static log(LogLvl lvl, const char *message)
{
std::ignore = lvl;
std::println("{}", message);
instance().spd_logger->log((spdlog::level::level_enum)lvl, message);
}
private:
Logger() = default;
Logger();
~Logger();
auto static instance() -> Logger &;
std::shared_ptr<spdlog::logger> spd_logger;
};
template<typename... Args>

View file

@ -1 +1,18 @@
#include <logger/logger.hpp>
Logger::Logger(): spd_logger(spdlog::stdout_color_mt("Logger"))
{
spd_logger->set_pattern("%^%v%$");
spd_logger->set_level(spdlog::level::level_enum::trace);
}
Logger::~Logger()
{
spdlog::drop_all();
}
auto Logger::instance() -> Logger &
{
static auto logger = Logger {};
return logger;
}

View file

@ -154,7 +154,7 @@ void AssetBrowserPanel::on_user_interface_update()
default: break;
}
// Label
ImGui::TextUnformatted(std::format("{}", path.filename().string()).c_str());
ImGui::TextUnformatted(fmt::format("{}", path.filename().string()).c_str());
ImGui::PopID();
}

View file

@ -1,2 +1,2 @@
add_library_module(ui ui.cpp gl/ui.cpp)
target_link_libraries(ui PUBLIC imgui renderer logger lt_debug)
target_link_libraries(ui PUBLIC spdlog::spdlog imgui renderer logger lt_debug)

View file

@ -16,7 +16,8 @@ auto Window::create(const std::function<void(Event &)> &callback) -> Scope<Windo
}
lWindow::lWindow(std::function<void(Event &)> callback)
: m_event_callback(std::move(std::move(callback)))
: m_handle(glfwCreateWindow(1u, 1u, "", nullptr, nullptr))
, m_event_callback(std::move(std::move(callback)))
{
ensure(glfwInit(), "Failed to initialize 'glfw'");
@ -25,8 +26,7 @@ lWindow::lWindow(std::function<void(Event &)> callback)
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
m_handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr);
ensure(m_handle, "Failed to create 'GLFWwindow'");
glfwSetWindowUserPointer(m_handle, &m_event_callback);

View file

@ -1,5 +1,6 @@
find_package(glfw3 REQUIRED)
find_package(glm REQUIRED)
find_package(spdlog REQUIRED)
find_package(stb REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(EnTT REQUIRED)