diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/zenserver/diag/logging.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/zenserver/diag/logging.cpp b/src/zenserver/diag/logging.cpp index 13270b41d..0f15253cc 100644 --- a/src/zenserver/diag/logging.cpp +++ b/src/zenserver/diag/logging.cpp @@ -446,6 +446,35 @@ InitializeLogging(const ZenServerOptions& GlobalOptions) FileSink->set_pattern("[%C-%m-%d.%e %T] [%n] [%l] %v"); } + spdlog::set_error_handler([](const std::string& msg) { + if (msg == std::bad_alloc().what()) + { + // Don't report out of memory in spdlog as we usually log in response to errors which will cause another OOM crashing the + // program + return; + } + // Bypass zen logging wrapping to reduce potential other error sources + if (auto ErrLogger = zen::logging::ErrorLog(); ErrLogger != nullptr) + { + try + { + ErrLogger->log(spdlog::level::err, msg); + } + catch (const std::exception&) + { + // Just ignore any errors when in error handler + } + } + try + { + Log().error(msg); + } + catch (const std::exception&) + { + // Just ignore any errors when in error handler + } + }); + const std::string StartLogTime = zen::DateTime::Now().ToIso8601(); const zen::Oid ServerSessionId = zen::GetSessionId(); |