[Box Backup-commit] COMMIT r2082 - box/trunk/infrastructure

boxbackup-dev@fluffy.co.uk boxbackup-dev@fluffy.co.uk
Thu, 31 Jan 2008 23:52:09 +0000 (UTC)


Author: chris
Date: 2008-01-31 23:52:08 +0000 (Thu, 31 Jan 2008)
New Revision: 2082

Modified:
   box/trunk/infrastructure/buildenv-testmain-template.cpp
Log:
Add support for verbosity control in tests.


Modified: box/trunk/infrastructure/buildenv-testmain-template.cpp
===================================================================
--- box/trunk/infrastructure/buildenv-testmain-template.cpp	2008-01-31 23:44:54 UTC (rev 2081)
+++ box/trunk/infrastructure/buildenv-testmain-template.cpp	2008-01-31 23:52:08 UTC (rev 2082)
@@ -160,6 +160,12 @@
 	MEMLEAKFINDER_START
 
 #ifdef HAVE_GETOPT_H
+	#ifdef NDEBUG
+	int logLevel = Log::NOTICE; // need an int to do math with
+	#else
+	int logLevel = Log::INFO; // need an int to do math with
+	#endif
+
 	struct option longopts[] = 
 	{
 		{ "bbackupd-args",	required_argument, NULL, 'c' },
@@ -170,7 +176,7 @@
 	
 	int ch;
 	
-	while ((ch = getopt_long(argc, argv, "c:d:s:t:TUV", longopts, NULL))
+	while ((ch = getopt_long(argc, argv, "c:d:qs:t:vTUV", longopts, NULL))
 		!= -1)
 	{
 		switch(ch)
@@ -202,6 +208,38 @@
 			}
 			break;
 
+			case 'q':
+			{
+				if(logLevel == Log::NOTHING)
+				{
+					BOX_FATAL("Too many '-q': "
+						"Cannot reduce logging "
+						"level any more");
+					return 2;
+				}
+				logLevel--;
+			}
+			break;
+
+			case 'v':
+			{
+				if(logLevel == Log::EVERYTHING)
+				{
+					BOX_FATAL("Too many '-v': "
+						"Cannot increase logging "
+						"level any more");
+					return 2;
+				}
+				logLevel++;
+			}
+			break;
+
+			case 'V':
+			{
+				logLevel = Log::EVERYTHING;
+			}
+			break;
+
 			case 't':
 			{
 				Console::SetTag(optarg);
@@ -221,12 +259,6 @@
 			}
 			break;
 
-			case 'V':
-			{
-				Logging::SetGlobalLevel(Log::EVERYTHING);
-			}
-			break;
-
 			case '?':
 			{
 				fprintf(stderr, "Unknown option: '%c'\n",
@@ -243,6 +275,8 @@
 		}
 	}
 
+	Logging::SetGlobalLevel((Log::Level)logLevel);
+
 	argc -= optind - 1;
 	argv += optind - 1;
 #endif // HAVE_GETOPT_H