Convert SHADE_Engine to a DLL and made all projects use a shared output and intermediate directory #14

Merged
Pycorax merged 6 commits from UseSharedOutInterDirs into main 2022-09-14 19:40:50 +08:00
3 changed files with 24 additions and 12 deletions
Showing only changes of commit 803b29146e - Show all commits

View File

@ -26,13 +26,15 @@ INT WINAPI wWinMain
)
{
const SHADE::SHLogger::Config LOGGER_CONFIG{ .directoryPath = "./logs/" };
SHADE::SHLogger::Initialise(LOGGER_CONFIG);
auto logger = SHADE::SHLogger::Initialise(LOGGER_CONFIG);
try
{
#ifndef SHEDITOR
//ShowWindow(::GetConsoleWindow(), SW_HIDE);
#endif
#endif
SHLOG_REGISTER(logger)
SHLOG_INFO("sup")

View File

@ -30,8 +30,9 @@ namespace SHADE
/*-----------------------------------------------------------------------------------*/
/* Static Data Member Definitions */
/*-----------------------------------------------------------------------------------*/
unsigned char SHLogger::configFlags = DEFAULT_CONFIG_FLAG;
SHLogger::DateFormat SHLogger::dateFormat = SHLogger::DateFormat::DD_MM_YY;
unsigned char SHLogger::configFlags = DEFAULT_CONFIG_FLAG;
SHLogger::DateFormat SHLogger::dateFormat = SHLogger::DateFormat::DD_MM_YY;
SHLogger::Logger SHLogger::logger = nullptr;
std::string SHLogger::trivialPattern;
std::string SHLogger::verbosePattern;
@ -142,7 +143,7 @@ namespace SHADE
/* Public Function Member Definitions */
/*-----------------------------------------------------------------------------------*/
void SHLogger::Initialise(const Config& config)
SHLogger::Logger SHLogger::Initialise(const Config& config)
{
SetConfig(config);
@ -176,10 +177,10 @@ namespace SHADE
FILE_SINK->set_pattern(trivialPattern + "%v");
// Create and register logger with spdlog
const auto LOGGER = std::make_shared<spdlog::logger>(SHLOGGER_NAME, sinks.begin(), sinks.end());
LOGGER->set_level(spdlog::level::trace);
LOGGER->flush_on(spdlog::level::trace);
register_logger(LOGGER);
logger = std::make_shared<spdlog::logger>(SHLOGGER_NAME, sinks.begin(), sinks.end());
logger->set_level(spdlog::level::trace);
logger->flush_on(spdlog::level::trace);
spdlog::register_logger(logger);
// Flush every 3 seconds
spdlog::flush_every(std::chrono::seconds(config.flushTime));
@ -190,6 +191,8 @@ namespace SHADE
{
std::cout << "Log initialisation failed: " << e.what() << std::endl;
}
return logger;
}
void SHLogger::Shutdown() noexcept

View File

@ -35,6 +35,8 @@ namespace SHADE
/* Type Definitions */
/*---------------------------------------------------------------------------------*/
using Logger = std::shared_ptr<spdlog::logger>;
enum class ClockFormat { _12HR, _24HR };
enum class DateFormat
@ -107,7 +109,7 @@ namespace SHADE
* @brief Creates a console and a file to log to.
* @param[in] config The configuration parameters for the logger.
*/
static void Initialise (const Config& config = Config{});
static Logger Initialise (const Config& config = Config{});
static void Shutdown () noexcept;
/**
@ -127,7 +129,9 @@ namespace SHADE
static constexpr short DEFAULT_CONSOLE_LEN = 1024;
static unsigned char configFlags; // Initialised 0 0 FuncLine# FuncFileName Date TimeFormat Time
static DateFormat dateFormat;
static DateFormat dateFormat;
static Logger logger;
static std::string trivialPattern;
static std::string verbosePattern;
@ -172,4 +176,7 @@ namespace SHADE
#define SHLOGV_CRITICAL(format, ...) SHADE::SHLogger::UseVerbosePattern(); SPDLOG_LOGGER_CRITICAL(spdlog::get(SHLOGGER_NAME), format, ## __VA_ARGS__);
// Misc Logging Macros
#define SHLOG_FLOOR() SHADE::SHLogger::UseTrivialPattern(); SPDLOG_LOGGER_INFO(spdlog::get(SHLOGGER_NAME), "--------------------------------");
#define SHLOG_FLOOR() SHADE::SHLogger::UseTrivialPattern(); SPDLOG_LOGGER_INFO(spdlog::get(SHLOGGER_NAME), "--------------------------------");
// For use outside the library to register the logger
#define SHLOG_REGISTER(logger) spdlog::register_logger(logger); spdlog::set_level(spdlog::level::level_enum::trace);