diff --git a/CMakeLists.txt b/CMakeLists.txt index 42d7516..32dcabb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,8 @@ add_library(${PROJECT_NAME} SHARED "include/export.h" + "include/engine.hpp" + "include/log.hpp" "include/window.hpp" @@ -80,7 +82,7 @@ target_include_directories(${PROJECT_NAME} PRIVATE src) # Pass some project information into the source code configure_file(config.h.in config.h) -target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) +target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) # libraries: diff --git a/include/engine.hpp b/include/engine.hpp new file mode 100644 index 0000000..42e6df4 --- /dev/null +++ b/include/engine.hpp @@ -0,0 +1,45 @@ +#pragma once + +#include + +#include "log.hpp" +#include +#include + +namespace engine { + + // To be executed in the target application, NOT engine.dll + void setupLog(const char* appName) + { + + const std::string LOG_FILENAME{ std::string(appName) + ".log"}; + +#ifdef NDEBUG + // RELEASE + const std::filesystem::path log_path{ std::filesystem::temp_directory_path() / LOG_FILENAME }; +#else + // DEBUG + const std::filesystem::path log_path{ LOG_FILENAME }; +#endif + + std::vector sinks; + + sinks.emplace_back(std::make_shared(log_path.string(), true)); + +#ifndef NDEBUG + // DEBUG + sinks.emplace_back(std::make_shared()); +#endif + + auto logger = std::make_shared("sdltest", sinks.begin(), sinks.end()); + + logger->set_level(spdlog::level::trace); + + spdlog::register_logger(logger); + spdlog::set_default_logger(logger); + + INFO("Created log with path: {}", log_path.string()); + + } + +} \ No newline at end of file