Mercurial > hg > orthanc
diff OrthancServer/main.cpp @ 2015:bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 13 Jun 2016 15:07:53 +0200 |
parents | 4dafe2a0d3ab |
children | 300599489cab |
line wrap: on
line diff
--- a/OrthancServer/main.cpp Mon Jun 13 13:39:10 2016 +0200 +++ b/OrthancServer/main.cpp Mon Jun 13 15:07:53 2016 +0200 @@ -443,7 +443,9 @@ << "Command-line options:" << std::endl << " --help\t\tdisplay this help and exit" << std::endl << " --logdir=[dir]\tdirectory where to store the log files" << std::endl - << "\t\t\t(if not used, the logs are dumped to stderr)" << std::endl + << "\t\t\t(by default, the log is dumped to stderr)" << std::endl + << " --logfile=[file]\tfile where to store the log of Orthanc" << std::endl + << "\t\t\t(by default, the log is dumped to stderr)" << std::endl << " --config=[file]\tcreate a sample configuration file and exit" << std::endl << " --errors\t\tprint the supported error codes and exit" << std::endl << " --verbose\t\tbe verbose in logs" << std::endl @@ -661,15 +663,19 @@ if (!restart && event == ServerBarrierEvent_Reload) { + // Handling of SIGHUP + if (Configuration::HasConfigurationChanged()) { LOG(WARNING) << "A SIGHUP signal has been received, resetting Orthanc"; + Logging::Flush(); restart = true; break; } else { LOG(WARNING) << "A SIGHUP signal has been received, but is ignored as the configuration has not changed"; + Logging::Flush(); continue; } } @@ -1148,6 +1154,21 @@ return -1; } } + else if (boost::starts_with(argument, "--logfile=")) + { + std::string file = argument.substr(10); + + try + { + Logging::SetTargetFile(file); + } + catch (OrthancException&) + { + LOG(ERROR) << "Cannot write to the specified log file (" + << file << "), aborting."; + return -1; + } + } else if (argument == "--upgrade") { allowDatabaseUpgrade = true; @@ -1208,6 +1229,8 @@ if (restart) { OrthancFinalize(); + LOG(WARNING) << "Logging system is resetting"; + Logging::Reset(); } else {