Add command line argument for disabling the logfile
This commit is contained in:
parent
36be4a89f8
commit
832298e7aa
14
src/Logger.h
14
src/Logger.h
|
@ -27,14 +27,26 @@ public:
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
cAttachment() : m_listener(nullptr) {}
|
||||||
cAttachment(cAttachment && a_other)
|
cAttachment(cAttachment && a_other)
|
||||||
: m_listener(a_other.m_listener)
|
: m_listener(a_other.m_listener)
|
||||||
{
|
{
|
||||||
|
a_other.m_listener = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
~cAttachment()
|
~cAttachment()
|
||||||
{
|
{
|
||||||
cLogger::GetInstance().DetachListener(m_listener);
|
if (m_listener != nullptr)
|
||||||
|
{
|
||||||
|
cLogger::GetInstance().DetachListener(m_listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cAttachment & operator=(cAttachment && a_other)
|
||||||
|
{
|
||||||
|
m_listener = a_other.m_listener;
|
||||||
|
a_other.m_listener = nullptr;
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
17
src/Root.cpp
17
src/Root.cpp
|
@ -116,14 +116,19 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> a_OverridesRepo)
|
||||||
|
|
||||||
auto consoleLogListener = MakeConsoleListener(m_RunAsService);
|
auto consoleLogListener = MakeConsoleListener(m_RunAsService);
|
||||||
auto consoleAttachment = cLogger::GetInstance().AttachListener(std::move(consoleLogListener));
|
auto consoleAttachment = cLogger::GetInstance().AttachListener(std::move(consoleLogListener));
|
||||||
auto fileLogListenerRet = MakeFileListener();
|
|
||||||
if (!fileLogListenerRet.first)
|
cLogger::cAttachment fileAttachment;
|
||||||
|
if (!a_OverridesRepo->HasValue("Server","DisableLogFile"))
|
||||||
{
|
{
|
||||||
m_TerminateEventRaised = true;
|
auto fileLogListenerRet = MakeFileListener();
|
||||||
LOGERROR("Failed to open log file, aborting");
|
if (!fileLogListenerRet.first)
|
||||||
return;
|
{
|
||||||
|
m_TerminateEventRaised = true;
|
||||||
|
LOGERROR("Failed to open log file, aborting");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fileAttachment = cLogger::GetInstance().AttachListener(std::move(fileLogListenerRet.second));
|
||||||
}
|
}
|
||||||
auto fileAttachment = cLogger::GetInstance().AttachListener(std::move(fileLogListenerRet.second));
|
|
||||||
|
|
||||||
LOG("--- Started Log ---");
|
LOG("--- Started Log ---");
|
||||||
|
|
||||||
|
|
|
@ -391,6 +391,7 @@ static std::unique_ptr<cMemorySettingsRepository> ParseArguments(int argc, char
|
||||||
TCLAP::SwitchArg crashDumpFull ("", "crash-dump-full", "Crashdumps created by the server will contain full server memory", cmd);
|
TCLAP::SwitchArg crashDumpFull ("", "crash-dump-full", "Crashdumps created by the server will contain full server memory", cmd);
|
||||||
TCLAP::SwitchArg crashDumpGlobals("", "crash-dump-globals", "Crashdumps created by the server will contain the global variables' values", cmd);
|
TCLAP::SwitchArg crashDumpGlobals("", "crash-dump-globals", "Crashdumps created by the server will contain the global variables' values", cmd);
|
||||||
TCLAP::SwitchArg noBufArg ("", "no-output-buffering", "Disable output buffering", cmd);
|
TCLAP::SwitchArg noBufArg ("", "no-output-buffering", "Disable output buffering", cmd);
|
||||||
|
TCLAP::SwitchArg noFileLogArg ("", "no-log-file", "Disable logging to file", cmd);
|
||||||
TCLAP::SwitchArg runAsServiceArg ("d", "service", "Run as a service on Windows, or daemon on UNIX like systems", cmd);
|
TCLAP::SwitchArg runAsServiceArg ("d", "service", "Run as a service on Windows, or daemon on UNIX like systems", cmd);
|
||||||
cmd.parse(argc, argv);
|
cmd.parse(argc, argv);
|
||||||
|
|
||||||
|
@ -413,6 +414,10 @@ static std::unique_ptr<cMemorySettingsRepository> ParseArguments(int argc, char
|
||||||
repo->AddValue("Server", "Ports", std::to_string(port));
|
repo->AddValue("Server", "Ports", std::to_string(port));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (noFileLogArg.getValue())
|
||||||
|
{
|
||||||
|
repo->AddValue("Server", "DisableLogFile", true);
|
||||||
|
}
|
||||||
if (commLogArg.getValue())
|
if (commLogArg.getValue())
|
||||||
{
|
{
|
||||||
g_ShouldLogCommIn = true;
|
g_ShouldLogCommIn = true;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user