aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-05-11 16:07:40 +0200
committerGitHub <[email protected]>2023-05-11 16:07:40 +0200
commit2cd31bef444c1ecae9b7e4ef7ca43b9f5dd4222d (patch)
tree52858d5ec03986f6fc4f28224c64a69c57e49b7c
parentclang-format (sorry) (diff)
downloadzen-2cd31bef444c1ecae9b7e4ef7ca43b9f5dd4222d.tar.xz
zen-2cd31bef444c1ecae9b7e4ef7ca43b9f5dd4222d.zip
allow early logging (#292)
* if logging is not initialized, just log to console * changelog
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/zencore/include/zencore/logging.h4
-rw-r--r--src/zenserver/zenserver.cpp8
3 files changed, 8 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 59d1585e2..2c9aa09db 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@
- Bugfix: Close down http server gracefully when exiting even while requests are still being processed
- Bugfix: Flush snapshot for filecase on flush/exit
- Bugfix: Fix log of size found when scanning for files in filecas
+- Bugfix: Fix crash at startup if dead process handles are detected in ZenServerState
## 0.2.9
- Bugfix: Treat reading outside of block store file as a not found error. We may encounter truncated blocks due to earlier abnormal termination of zenserver or disk failures
diff --git a/src/zencore/include/zencore/logging.h b/src/zencore/include/zencore/logging.h
index c40af1310..6a8fd7254 100644
--- a/src/zencore/include/zencore/logging.h
+++ b/src/zencore/include/zencore/logging.h
@@ -31,6 +31,10 @@ extern spdlog::logger* TheDefaultLogger;
inline spdlog::logger&
Log()
{
+ if (TheDefaultLogger == nullptr)
+ {
+ return zen::logging::ConsoleLog();
+ }
return *TheDefaultLogger;
}
diff --git a/src/zenserver/zenserver.cpp b/src/zenserver/zenserver.cpp
index 826924952..f9221ed0f 100644
--- a/src/zenserver/zenserver.cpp
+++ b/src/zenserver/zenserver.cpp
@@ -1095,7 +1095,7 @@ ZenEntryPoint::Run()
{
if (ServerOptions.OwnerPid)
{
- ConsoleLog().info(
+ ZEN_INFO(
"Looks like there is already a process listening to this port {} (pid: {}), attaching owner pid {} to running instance",
ServerOptions.BasePort,
Entry->Pid,
@@ -1107,9 +1107,7 @@ ZenEntryPoint::Run()
}
else
{
- ConsoleLog().warn("Exiting since there is already a process listening to port {} (pid: {})",
- ServerOptions.BasePort,
- Entry->Pid);
+ ZEN_WARN("Exiting since there is already a process listening to port {} (pid: {})", ServerOptions.BasePort, Entry->Pid);
std::exit(1);
}
}
@@ -1131,7 +1129,7 @@ ZenEntryPoint::Run()
if (Ec)
{
- ConsoleLog().warn("ERROR: Unable to grab lock at '{}' (error: '{}')", LockFilePath, Ec.message());
+ ZEN_WARN("ERROR: Unable to grab lock at '{}' (error: '{}')", LockFilePath, Ec.message());
std::exit(99);
}