From 35e9013d1a108a186908ef1e6ee3f26f9407c5f1 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 22 Apr 2007 14:25:08 +0000 Subject: Add -V option, which sets maximum verbosity in one go. Add -T option, which adds timestamps to console logs. Add -t option, which enabled and sets the tag used on console logs. Add -k option, which keeps console open after forking. (refs #3) --- lib/server/Daemon.cpp | 34 ++++++++++++++++++++++++++++++---- lib/server/Daemon.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/server/Daemon.cpp b/lib/server/Daemon.cpp index 5ee45378..c639309a 100644 --- a/lib/server/Daemon.cpp +++ b/lib/server/Daemon.cpp @@ -51,7 +51,8 @@ Daemon *Daemon::spDaemon = 0; Daemon::Daemon() : mpConfiguration(NULL), mReloadConfigWanted(false), - mTerminateWanted(false) + mTerminateWanted(false), + mKeepConsoleOpenAfterFork(false) { if(spDaemon != NULL) { @@ -109,8 +110,9 @@ int Daemon::Main(const char *DefaultConfigFile, int argc, const char *argv[]) #endif char c; + optind = 0; // just in case anybody used getopt before - while((c = getopt(argc, (char * const *)argv, "c:Dqv")) != -1) + while((c = getopt(argc, (char * const *)argv, "c:DqvVt:Tk")) != -1) { switch(c) { @@ -153,10 +155,34 @@ int Daemon::Main(const char *DefaultConfigFile, int argc, const char *argv[]) } break; + case 'V': + { + masterLevel = Log::EVERYTHING; + } + break; + + case 't': + { + Console::SetTag(optarg); + } + break; + + case 'T': + { + Console::SetShowTime(true); + } + break; + + case 'k': + { + mKeepConsoleOpenAfterFork = true; + } + break; + case '?': { BOX_FATAL("Unknown option on command line: " - << "'" << optopt << "'"); + << "'" << (char)optopt << "'"); return 2; } break; @@ -377,7 +403,7 @@ int Daemon::Main(const std::string &rConfigFileName, bool singleProcess) } #endif // BOX_MEMORY_LEAK_TESTING - if(asDaemon) + if(asDaemon && !mKeepConsoleOpenAfterFork) { #ifndef WIN32 // Close standard streams diff --git a/lib/server/Daemon.h b/lib/server/Daemon.h index b28d752a..52bab257 100644 --- a/lib/server/Daemon.h +++ b/lib/server/Daemon.h @@ -77,6 +77,7 @@ private: box_time_t mLoadedConfigModifiedTime; bool mReloadConfigWanted; bool mTerminateWanted; + bool mKeepConsoleOpenAfterFork; static Daemon *spDaemon; }; -- cgit v1.2.3