aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/main.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-08-26 14:05:15 +0200
committerGitHub Enterprise <[email protected]>2025-08-26 14:05:15 +0200
commit0cc32cae5e3fb832bbad584ce86a308dc6104c46 (patch)
tree33d81192d767864b5149aeece975b321ef04a00a /src/zenserver/main.cpp
parentimprove console output (#476) (diff)
downloadzen-0cc32cae5e3fb832bbad584ce86a308dc6104c46.tar.xz
zen-0cc32cae5e3fb832bbad584ce86a308dc6104c46.zip
rework `--quiet` zenserver option add `--noconsole` option (#477)
- Improvement: Changed zenserver `--quiet` option to suppress INFO level messages and below to surface startup and runtime errors - Feature: Added `--noconsole` option that suppresses all output to standard out, this works as the `--quiet` option used to work
Diffstat (limited to 'src/zenserver/main.cpp')
-rw-r--r--src/zenserver/main.cpp57
1 files changed, 33 insertions, 24 deletions
diff --git a/src/zenserver/main.cpp b/src/zenserver/main.cpp
index f7d69617c..d512d4894 100644
--- a/src/zenserver/main.cpp
+++ b/src/zenserver/main.cpp
@@ -139,21 +139,23 @@ ZenEntryPoint::Run()
{
if (Ec)
{
- ZEN_WARN(
- "Sponsor owner pid {} can not be checked for running state, reason: '{}'. Will not add sponsor to process "
- "listening to port {} (pid: {})",
- m_ServerOptions.OwnerPid,
- Ec.message(),
- m_ServerOptions.BasePort,
- Entry->Pid.load());
+ ZEN_WARN(ZEN_APP_NAME
+ " exiting, sponsor owner pid {} can not be checked for running state, reason: '{}'. Will not add sponsor "
+ "to process "
+ "listening to port {} (pid: {})",
+ m_ServerOptions.OwnerPid,
+ Ec.message(),
+ m_ServerOptions.BasePort,
+ Entry->Pid.load());
}
else
{
- ZEN_WARN(
- "Sponsor owner pid {} is no longer running, will not add sponsor to process listening to port {} (pid: {})",
- m_ServerOptions.OwnerPid,
- m_ServerOptions.BasePort,
- Entry->Pid.load());
+ ZEN_WARN(ZEN_APP_NAME
+ " exiting, sponsor owner pid {} is no longer running, will not add sponsor to process listening to port "
+ "{} (pid: {})",
+ m_ServerOptions.OwnerPid,
+ m_ServerOptions.BasePort,
+ Entry->Pid.load());
}
std::exit(1);
}
@@ -175,7 +177,7 @@ ZenEntryPoint::Run()
}
else
{
- ZEN_WARN("Failed to add sponsor owner pid {} to process listening to port {} (pid: {})",
+ ZEN_WARN(ZEN_APP_NAME " exiting, failed to add sponsor owner pid {} to process listening to port {} (pid: {})",
m_ServerOptions.OwnerPid,
m_ServerOptions.BasePort,
Entry->Pid.load());
@@ -184,7 +186,7 @@ ZenEntryPoint::Run()
}
else
{
- ZEN_WARN("Exiting since there is already a process listening to port {} (pid: {})",
+ ZEN_WARN(ZEN_APP_NAME " exiting, there is already a process listening to port {} (pid: {})",
m_ServerOptions.BasePort,
Entry->Pid.load());
std::exit(1);
@@ -208,14 +210,19 @@ ZenEntryPoint::Run()
if (Ec)
{
- ZEN_WARN("Unable to grab lock at '{}' (reason: '{}'), retrying", LockFilePath, Ec.message());
- Sleep(500);
+ ZEN_INFO(ZEN_APP_NAME " unable to grab lock at '{}' (reason: '{}'), retrying", LockFilePath, Ec.message());
+ Sleep(100);
m_LockFile.Create(LockFilePath, MakeLockData(false), Ec);
if (Ec)
{
- ZEN_WARN("ERROR: Unable to grab lock at '{}' (reason: '{}')", LockFilePath, Ec.message());
- std::exit(99);
+ ZEN_INFO(ZEN_APP_NAME " unable to grab lock at '{}' (reason: '{}'), retrying", LockFilePath, Ec.message());
+ Sleep(500);
+ if (Ec)
+ {
+ ZEN_WARN(ZEN_APP_NAME " exiting, unable to grab lock at '{}' (reason: '{}')", LockFilePath, Ec.message());
+ std::exit(99);
+ }
}
}
@@ -316,12 +323,14 @@ ZenEntryPoint::Run()
}
catch (const AssertException& AssertEx)
{
- ZEN_CRITICAL("Caught assert exception in main for process {}: {}", zen::GetCurrentProcessId(), AssertEx.FullDescription());
+ ZEN_CRITICAL(ZEN_APP_NAME " caught assert exception in main for process {}: {}",
+ zen::GetCurrentProcessId(),
+ AssertEx.FullDescription());
RequestApplicationExit(1);
}
catch (const std::system_error& e)
{
- ZEN_CRITICAL("Caught system error exception in main for process {}: {} ({})",
+ ZEN_CRITICAL(ZEN_APP_NAME " caught system error exception in main for process {}: {} ({})",
zen::GetCurrentProcessId(),
e.what(),
e.code().value());
@@ -329,7 +338,7 @@ ZenEntryPoint::Run()
}
catch (const std::exception& e)
{
- ZEN_CRITICAL("Caught exception in main for process {}: {}", zen::GetCurrentProcessId(), e.what());
+ ZEN_CRITICAL(ZEN_APP_NAME " caught exception in main for process {}: {}", zen::GetCurrentProcessId(), e.what());
RequestApplicationExit(1);
}
@@ -499,17 +508,17 @@ main(int argc, char* argv[])
catch (const OptionParseException& ParseEx)
{
// The parsing error already outputs all the details so no need to output the command line here
- fprintf(stderr, "ERROR: %s\n", ParseEx.what());
+ fprintf(stderr, ZEN_APP_NAME " ERROR: %s\n", ParseEx.what());
return 1;
}
catch (const AssertException& AssertEx)
{
- fprintf(stderr, "ERROR: Caught assert exception in main: '%s'", AssertEx.FullDescription().c_str());
+ fprintf(stderr, ZEN_APP_NAME " ERROR: Caught assert exception in main: '%s'", AssertEx.FullDescription().c_str());
return 1;
}
catch (const std::exception& Ex)
{
- fprintf(stderr, "ERROR: Caught exception in main: '%s'", Ex.what());
+ fprintf(stderr, ZEN_APP_NAME " ERROR: Caught exception in main: '%s'", Ex.what());
return 1;
}