[Box Backup-commit] COMMIT r2393 - box/trunk/bin/bbackupquery
boxbackup-dev at boxbackup.org
boxbackup-dev at boxbackup.org
Sun Nov 30 22:25:27 GMT 2008
Author: chris
Date: 2008-11-30 22:25:27 +0000 (Sun, 30 Nov 2008)
New Revision: 2393
Modified:
box/trunk/bin/bbackupquery/bbackupquery.cpp
Log:
Add support for using the logging framework to log (most) bbackupquery
output to a file, with its own verbosity level.
Modified: box/trunk/bin/bbackupquery/bbackupquery.cpp
===================================================================
--- box/trunk/bin/bbackupquery/bbackupquery.cpp 2008-11-30 22:24:28 UTC (rev 2392)
+++ box/trunk/bin/bbackupquery/bbackupquery.cpp 2008-11-30 22:25:27 UTC (rev 2393)
@@ -62,10 +62,13 @@
#ifdef WIN32
"[-u] "
#endif
- "\n\t[-c config_file] [-l log_file] [commands]\n"
+ "\n"
+ "\t[-c config_file] [-o log_file] [-O log_file_level]\n"
+ "\t[-l protocol_log_file] [commands]\n"
+ "\n"
"As many commands as you require.\n"
"If commands are multiple words, remember to enclose the command in quotes.\n"
- "Remember to use quit command if you don't want to drop into interactive mode.\n");
+ "Remember to use the quit command unless you want to end up in interactive mode.\n");
exit(1);
}
@@ -118,12 +121,15 @@
#endif
#ifdef WIN32
- const char* validOpts = "qvwuc:l:W:";
+ const char* validOpts = "qvwuc:l:o:O:W:";
bool unicodeConsole = false;
#else
- const char* validOpts = "qvwc:l:W:";
+ const char* validOpts = "qvwc:l:o:O:W:";
#endif
+ std::string fileLogFile;
+ Log::Level fileLogLevel = Log::INVALID;
+
// See if there's another entry on the command line
int c;
while((c = getopt(argc, (char * const *)argv, validOpts)) != -1)
@@ -187,6 +193,22 @@
}
break;
+ case 'o':
+ fileLogFile = optarg;
+ fileLogLevel = Log::EVERYTHING;
+ break;
+
+ case 'O':
+ {
+ fileLogLevel = Logging::GetNamedLevel(optarg);
+ if (fileLogLevel == Log::INVALID)
+ {
+ BOX_FATAL("Invalid logging level");
+ return 2;
+ }
+ }
+ break;
+
#ifdef WIN32
case 'u':
unicodeConsole = true;
@@ -204,6 +226,12 @@
Logging::SetGlobalLevel((Log::Level)masterLevel);
+ std::auto_ptr<FileLogger> fileLogger;
+ if (fileLogLevel != Log::INVALID)
+ {
+ fileLogger.reset(new FileLogger(fileLogFile, fileLogLevel));
+ }
+
bool quiet = false;
if (masterLevel < Log::NOTICE)
{
More information about the Boxbackup-commit
mailing list