mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:23:52 +00:00
[Server] Add "--no-logs" option
This commit is contained in:
parent
dbb636ac90
commit
b3b7003313
1 changed files with 20 additions and 11 deletions
|
@ -159,8 +159,9 @@ boost::program_options::variables_map launchOptions(int argc, char *argv[], File
|
||||||
bpo::options_description desc;
|
bpo::options_description desc;
|
||||||
|
|
||||||
desc.add_options()
|
desc.add_options()
|
||||||
("resources", bpo::value<Files::EscapeHashString>()->default_value("resources"),
|
("resources", bpo::value<Files::EscapeHashString>()->default_value("resources"), "set resources directory")
|
||||||
"set resources directory");
|
("no-logs", bpo::value<bool>()->implicit_value(true)->default_value(false),
|
||||||
|
"Do not write logs. Useful for daemonizing.");
|
||||||
|
|
||||||
cfgMgr.readConfiguration(variables, desc, true);
|
cfgMgr.readConfiguration(variables, desc, true);
|
||||||
|
|
||||||
|
@ -202,14 +203,19 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
boost::filesystem::ofstream logfile;
|
boost::filesystem::ofstream logfile;
|
||||||
|
|
||||||
|
if (!variables["no-logs"].as<bool>())
|
||||||
|
{
|
||||||
// Redirect cout and cerr to tes3mp server log
|
// Redirect cout and cerr to tes3mp server log
|
||||||
logfile.open (boost::filesystem::path(cfgMgr.getLogPath() / "/tes3mp-server-" += Log::getFilenameTimestamp() += ".log"));
|
|
||||||
|
|
||||||
coutsb.open (Tee(logfile, oldcout));
|
logfile.open(boost::filesystem::path(
|
||||||
cerrsb.open (Tee(logfile, oldcerr));
|
cfgMgr.getLogPath() / "/tes3mp-server-" += Log::getFilenameTimestamp() += ".log"));
|
||||||
|
|
||||||
std::cout.rdbuf (&coutsb);
|
coutsb.open(Tee(logfile, oldcout));
|
||||||
std::cerr.rdbuf (&cerrsb);
|
cerrsb.open(Tee(logfile, oldcerr));
|
||||||
|
|
||||||
|
std::cout.rdbuf(&coutsb);
|
||||||
|
std::cerr.rdbuf(&cerrsb);
|
||||||
|
}
|
||||||
|
|
||||||
LOG_INIT(logLevel);
|
LOG_INIT(logLevel);
|
||||||
|
|
||||||
|
@ -295,9 +301,12 @@ int main(int argc, char *argv[])
|
||||||
if (code == 0)
|
if (code == 0)
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Quitting peacefully.");
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Quitting peacefully.");
|
||||||
|
|
||||||
|
if(!variables["no-logs"].as<bool>())
|
||||||
|
{
|
||||||
// Restore cout and cerr
|
// Restore cout and cerr
|
||||||
std::cout.rdbuf(cout_rdbuf);
|
std::cout.rdbuf(cout_rdbuf);
|
||||||
std::cerr.rdbuf(cerr_rdbuf);
|
std::cerr.rdbuf(cerr_rdbuf);
|
||||||
|
}
|
||||||
|
|
||||||
breakpad_close();
|
breakpad_close();
|
||||||
return code;
|
return code;
|
||||||
|
|
Loading…
Reference in a new issue