aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil/logging.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenutil/logging.cpp')
-rw-r--r--src/zenutil/logging.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/zenutil/logging.cpp b/src/zenutil/logging.cpp
index 4d8dcbca6..512c7901c 100644
--- a/src/zenutil/logging.cpp
+++ b/src/zenutil/logging.cpp
@@ -7,6 +7,7 @@ ZEN_THIRD_PARTY_INCLUDES_START
#include <spdlog/async_logger.h>
#include <spdlog/sinks/ansicolor_sink.h>
#include <spdlog/sinks/msvc_sink.h>
+#include <spdlog/spdlog.h>
ZEN_THIRD_PARTY_INCLUDES_END
#include <zencore/compactbinary.h>
@@ -58,10 +59,10 @@ BeginInitializeLogging(const LoggingOptions& LogOptions)
{
const int QueueSize = 8192;
const int ThreadCount = 1;
- spdlog::init_thread_pool(QueueSize, ThreadCount);
+ spdlog::init_thread_pool(QueueSize, ThreadCount, [&] { SetCurrentThreadName("spdlog_async"); });
- auto AsyncLogger = spdlog::create_async<spdlog::sinks::ansicolor_stdout_sink_mt>("main");
- zen::logging::SetDefault(AsyncLogger);
+ auto AsyncSink = spdlog::create_async<spdlog::sinks::ansicolor_stdout_sink_mt>("main");
+ zen::logging::SetDefault("main");
}
// Sinks
@@ -87,8 +88,8 @@ BeginInitializeLogging(const LoggingOptions& LogOptions)
// Default
- auto& DefaultLogger = zen::logging::Default();
- auto& Sinks = DefaultLogger.sinks();
+ LoggerRef DefaultLogger = zen::logging::Default();
+ auto& Sinks = DefaultLogger.SpdLogger->sinks();
Sinks.clear();
@@ -124,11 +125,11 @@ BeginInitializeLogging(const LoggingOptions& LogOptions)
return;
}
// Bypass zen logging wrapping to reduce potential other error sources
- if (auto ErrLogger = zen::logging::ErrorLog(); ErrLogger != nullptr)
+ if (auto ErrLogger = zen::logging::ErrorLog())
{
try
{
- ErrLogger->log(spdlog::level::err, msg);
+ ErrLogger.SpdLogger->log(spdlog::level::err, msg);
}
catch (const std::exception&)
{
@@ -137,7 +138,7 @@ BeginInitializeLogging(const LoggingOptions& LogOptions)
}
try
{
- Log().error(msg);
+ Log().SpdLogger->error(msg);
}
catch (const std::exception&)
{
@@ -192,8 +193,8 @@ ShutdownLogging()
{
g_FileSink.reset();
- auto& DefaultLogger = zen::logging::Default();
- DefaultLogger.info("log ending at {}", zen::DateTime::Now().ToIso8601());
+ auto DefaultLogger = zen::logging::Default();
+ ZEN_LOG_INFO(DefaultLogger, "log ending at {}", zen::DateTime::Now().ToIso8601());
zen::logging::ShutdownLogging();
}