summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorworktycho <work.tycho@gmail.com>2017-04-01 17:28:42 +0200
committerLukas Pioch <lukas@zgow.de>2017-06-03 21:40:35 +0200
commit832298e7aaee884393d8f80e5a374fa652b4cb68 (patch)
tree9b5c7af3b909f4a3616cfc1b32b36722f434ae60 /src
parentFixed double chests (#3741) (diff)
downloadcuberite-832298e7aaee884393d8f80e5a374fa652b4cb68.tar
cuberite-832298e7aaee884393d8f80e5a374fa652b4cb68.tar.gz
cuberite-832298e7aaee884393d8f80e5a374fa652b4cb68.tar.bz2
cuberite-832298e7aaee884393d8f80e5a374fa652b4cb68.tar.lz
cuberite-832298e7aaee884393d8f80e5a374fa652b4cb68.tar.xz
cuberite-832298e7aaee884393d8f80e5a374fa652b4cb68.tar.zst
cuberite-832298e7aaee884393d8f80e5a374fa652b4cb68.zip
Diffstat (limited to 'src')
-rw-r--r--src/Logger.h14
-rw-r--r--src/Root.cpp17
-rw-r--r--src/main.cpp5
3 files changed, 29 insertions, 7 deletions
diff --git a/src/Logger.h b/src/Logger.h
index 649c11ded..b4bf97cd6 100644
--- a/src/Logger.h
+++ b/src/Logger.h
@@ -27,14 +27,26 @@ public:
{
public:
+ cAttachment() : m_listener(nullptr) {}
cAttachment(cAttachment && a_other)
: m_listener(a_other.m_listener)
{
+ a_other.m_listener = nullptr;
}
~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:
diff --git a/src/Root.cpp b/src/Root.cpp
index c10bd09bd..a487310a8 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -116,14 +116,19 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> a_OverridesRepo)
auto consoleLogListener = MakeConsoleListener(m_RunAsService);
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;
- LOGERROR("Failed to open log file, aborting");
- return;
+ auto fileLogListenerRet = MakeFileListener();
+ if (!fileLogListenerRet.first)
+ {
+ 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 ---");
diff --git a/src/main.cpp b/src/main.cpp
index 4ae54511b..de194dc64 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -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 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 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);
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));
}
}
+ if (noFileLogArg.getValue())
+ {
+ repo->AddValue("Server", "DisableLogFile", true);
+ }
if (commLogArg.getValue())
{
g_ShouldLogCommIn = true;