diff --git a/code/clogger.c b/code/clogger.c index 2a62076..0d39b90 100644 --- a/code/clogger.c +++ b/code/clogger.c @@ -20,17 +20,20 @@ void CLogger::Initialize() { if (spdlog::get("rs") == nullptr) { + auto level = spdlog::level::trace; + spdlog::set_level(level); + auto console_sink = std::make_shared(); - console_sink->set_level(spdlog::level::info); + console_sink->set_level(level); console_sink->set_pattern("[%^%l%$] %v"); auto file_sink = std::make_shared(RS_LOG_FILE, true); - file_sink->set_level(spdlog::level::info); + file_sink->set_level(level); std::vector sinks{ console_sink, file_sink }; auto logger = std::make_shared("rs", sinks.begin(), sinks.end()); - logger->set_level(spdlog::level::info); - logger->flush_on(spdlog::level::info); + logger->set_level(level); + logger->flush_on(level); spdlog::register_logger(logger); } @@ -41,3 +44,12 @@ void CLogger::Shutdown() { spdlog::shutdown(); } + +void CLogger::SetLevel(spdlog::level::level_enum level) +{ + if (spdlog::get("rs") != nullptr) + { + spdlog::get("rs")->set_level(level); + spdlog::get("rs")->flush_on(level); + } +} \ No newline at end of file diff --git a/code/main.c b/code/main.c index f457e48..8129880 100644 --- a/code/main.c +++ b/code/main.c @@ -8,6 +8,7 @@ #include "comm.h" #include "interp.h" #include "db.h" +#include "./include/spdlog/spdlog.h" int main(int argc, char **argv) { @@ -15,6 +16,8 @@ int main(int argc, char **argv) int port = 0; int control; + RS.Logger.SetLevel(spdlog::level::info); + /* * Memory debugging if needed. */ @@ -51,6 +54,7 @@ int main(int argc, char **argv) } else if ((port = atoi(argv[1])) == 666) { + RS.Logger.SetLevel(spdlog::level::debug); bDebug = true; } else if (port <= 1024) diff --git a/code/recycle.c b/code/recycle.c index 6d58b11..78bae2a 100644 --- a/code/recycle.c +++ b/code/recycle.c @@ -700,8 +700,8 @@ CHAR_DATA *new_char(void) { ch = new CHAR_DATA; - if (bDebug) - RS.Logger.Debug("Char free is null. . . . . !"); + // if (bDebug) + // RS.Logger.Debug("Char free is null. . . . . !"); } else { diff --git a/code/stdlibs/clogger.h b/code/stdlibs/clogger.h index 7899790..1f2dce4 100644 --- a/code/stdlibs/clogger.h +++ b/code/stdlibs/clogger.h @@ -15,6 +15,11 @@ log.Shutdown(); */ +#ifdef SPDLOG_ACTIVE_LEVEL + #undef SPDLOG_ACTIVE_LEVEL + #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE +#endif + class CLogger { public: @@ -23,6 +28,7 @@ class CLogger void Initialize(); void Shutdown(); + void SetLevel(spdlog::level::level_enum level); template void Bug(std::string_view fmt, Args &&...args)