[Box Backup-commit] COMMIT r1552 - box/chris/merge/lib/server

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Sun Apr 22 15:25:08 BST 2007


Author: chris
Date: 2007-04-22 15:25:08 +0100 (Sun, 22 Apr 2007)
New Revision: 1552

Modified:
   box/chris/merge/lib/server/Daemon.cpp
   box/chris/merge/lib/server/Daemon.h
Log:
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)


Modified: box/chris/merge/lib/server/Daemon.cpp
===================================================================
--- box/chris/merge/lib/server/Daemon.cpp	2007-04-22 14:23:24 UTC (rev 1551)
+++ box/chris/merge/lib/server/Daemon.cpp	2007-04-22 14:25:08 UTC (rev 1552)
@@ -51,7 +51,8 @@
 Daemon::Daemon()
 	: mpConfiguration(NULL),
 	  mReloadConfigWanted(false),
-	  mTerminateWanted(false)
+	  mTerminateWanted(false),
+	  mKeepConsoleOpenAfterFork(false)
 {
 	if(spDaemon != NULL)
 	{
@@ -109,8 +110,9 @@
 	#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 @@
 			}
 			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 @@
 		}
 		#endif // BOX_MEMORY_LEAK_TESTING
 	
-		if(asDaemon)
+		if(asDaemon && !mKeepConsoleOpenAfterFork)
 		{
 #ifndef WIN32
 			// Close standard streams

Modified: box/chris/merge/lib/server/Daemon.h
===================================================================
--- box/chris/merge/lib/server/Daemon.h	2007-04-22 14:23:24 UTC (rev 1551)
+++ box/chris/merge/lib/server/Daemon.h	2007-04-22 14:25:08 UTC (rev 1552)
@@ -77,6 +77,7 @@
 	box_time_t mLoadedConfigModifiedTime;
 	bool mReloadConfigWanted;
 	bool mTerminateWanted;
+	bool mKeepConsoleOpenAfterFork;
 	static Daemon *spDaemon;
 };
 




More information about the Boxbackup-commit mailing list