summaryrefslogtreecommitdiff
path: root/bin/bbackupquery/bbackupquery.cpp
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2008-11-30 22:25:27 +0000
committerChris Wilson <chris+github@qwirx.com>2008-11-30 22:25:27 +0000
commit78158da871b47dda96c328b519cf4b11816ec066 (patch)
tree04c21a311571c7bb217783bb113eb9f6acbaea8e /bin/bbackupquery/bbackupquery.cpp
parent6d851fd3042ef3a5e5a3a4d78b9dabbcae472684 (diff)
Add support for using the logging framework to log (most) bbackupquery
output to a file, with its own verbosity level.
Diffstat (limited to 'bin/bbackupquery/bbackupquery.cpp')
-rw-r--r--bin/bbackupquery/bbackupquery.cpp36
1 files changed, 32 insertions, 4 deletions
diff --git a/bin/bbackupquery/bbackupquery.cpp b/bin/bbackupquery/bbackupquery.cpp
index 26d4ae50..31c28046 100644
--- a/bin/bbackupquery/bbackupquery.cpp
+++ b/bin/bbackupquery/bbackupquery.cpp
@@ -62,10 +62,13 @@ void PrintUsageAndExit()
#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 @@ int main(int argc, const char *argv[])
#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 @@ int main(int argc, const char *argv[])
}
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 @@ int main(int argc, const char *argv[])
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)
{