From e0d11ae476981fd56229b4ccffdd30166361548b Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 9 Apr 2014 22:15:25 +0000 Subject: Remove the global logging level. It's incompatible with having a logger that logs everything, regardless of the global log level. --- bin/bbackupquery/BackupQueries.cpp | 4 +--- bin/bbackupquery/bbackupquery.cpp | 49 +++++++++++++++----------------------- 2 files changed, 20 insertions(+), 33 deletions(-) (limited to 'bin/bbackupquery') diff --git a/bin/bbackupquery/BackupQueries.cpp b/bin/bbackupquery/BackupQueries.cpp index 6204cf90..413b5c1c 100644 --- a/bin/bbackupquery/BackupQueries.cpp +++ b/bin/bbackupquery/BackupQueries.cpp @@ -1967,11 +1967,9 @@ void BackupQueries::CommandRestore(const std::vector &args, const b // At TRACE level, we print a line for each file and // directory, so we don't need dots. - bool printDots = ! Logging::IsEnabled(Log::TRACE); - result = BackupClientRestore(mrConnection, dirID, storeDirEncoded.c_str(), localName.c_str(), - printDots /* print progress dots */, restoreDeleted, + true /* print progress dots */, restoreDeleted, false /* don't undelete after restore! */, opts['r'] /* resume? */, opts['f'] /* force continue after errors */); diff --git a/bin/bbackupquery/bbackupquery.cpp b/bin/bbackupquery/bbackupquery.cpp index 1ff3b28a..07d14871 100644 --- a/bin/bbackupquery/bbackupquery.cpp +++ b/bin/bbackupquery/bbackupquery.cpp @@ -221,9 +221,9 @@ int main(int argc, const char *argv[]) Logging::SetProgramName("bbackupquery"); #ifdef BOX_RELEASE_BUILD - int masterLevel = Log::NOTICE; // need an int to do math with + int consoleLogLevel = Log::NOTICE; // need an int to do math with #else - int masterLevel = Log::INFO; // need an int to do math with + int consoleLogLevel = Log::INFO; // need an int to do math with #endif #ifdef WIN32 @@ -253,40 +253,40 @@ int main(int argc, const char *argv[]) { case 'q': { - if(masterLevel == Log::NOTHING) + if(consoleLogLevel == Log::NOTHING) { BOX_FATAL("Too many '-q': " "Cannot reduce logging " "level any more"); return 2; } - masterLevel--; + consoleLogLevel--; } break; case 'v': { - if(masterLevel == Log::EVERYTHING) + if(consoleLogLevel == Log::EVERYTHING) { BOX_FATAL("Too many '-v': " "Cannot increase logging " "level any more"); return 2; } - masterLevel++; + consoleLogLevel++; } break; case 'V': { - masterLevel = Log::EVERYTHING; + consoleLogLevel = Log::EVERYTHING; } break; case 'W': { - masterLevel = Logging::GetNamedLevel(optarg); - if (masterLevel == Log::INVALID) + consoleLogLevel = Logging::GetNamedLevel(optarg); + if (consoleLogLevel == Log::INVALID) { BOX_FATAL("Invalid logging level"); return 2; @@ -351,7 +351,7 @@ int main(int argc, const char *argv[]) argc -= optind; argv += optind; - Logging::SetGlobalLevel((Log::Level)masterLevel); + Logging::GetConsole().Filter((Log::Level)consoleLogLevel); std::auto_ptr fileLogger; if (fileLogLevel != Log::INVALID) @@ -359,19 +359,7 @@ int main(int argc, const char *argv[]) fileLogger.reset(new FileLogger(fileLogFile, fileLogLevel)); } - bool quiet = false; - if (masterLevel < Log::NOTICE) - { - // Quiet mode - quiet = true; - } - - // Print banner? - if(!quiet) - { - const char *banner = BANNER_TEXT("Backup Query Tool"); - BOX_NOTICE(banner); - } + BOX_NOTICE(BANNER_TEXT("Backup Query Tool")); #ifdef WIN32 if (unicodeConsole) @@ -399,7 +387,7 @@ int main(int argc, const char *argv[]) #endif // WIN32 // Read in the configuration file - if(!quiet) BOX_INFO("Using configuration file " << configFilename); + BOX_INFO("Using configuration file " << configFilename); std::string errs; std::auto_ptr config( @@ -428,7 +416,7 @@ int main(int argc, const char *argv[]) BackupClientCryptoKeys_Setup(conf.GetKeyValue("KeysFile").c_str()); // 2. Connect to server - if(!quiet) BOX_INFO("Connecting to store..."); + BOX_INFO("Connecting to store..."); SocketStreamTLS *socket = new SocketStreamTLS; std::auto_ptr apSocket(socket); socket->Open(tlsContext, Socket::TypeINET, @@ -436,7 +424,7 @@ int main(int argc, const char *argv[]) conf.GetKeyValueInt("StorePort")); // 3. Make a protocol, and handshake - if(!quiet) BOX_INFO("Handshake with store..."); + BOX_INFO("Handshake with store..."); std::auto_ptr apConnection(new BackupProtocolClient(apSocket)); BackupProtocolClient& connection(*(apConnection.get())); @@ -449,7 +437,7 @@ int main(int argc, const char *argv[]) } // 4. Log in to server - if(!quiet) BOX_INFO("Login to store..."); + BOX_INFO("Login to store..."); // Check the version of the server { std::auto_ptr serverVersion(connection.QueryVersion(BACKUP_STORE_SERVER_VERSION)); @@ -463,7 +451,8 @@ int main(int argc, const char *argv[]) (readWrite)?0:(BackupProtocolLogin::Flags_ReadOnly)); // 5. Tell user. - if(!quiet) printf("Login complete.\n\nType \"help\" for a list of commands.\n\n"); + BOX_INFO("Login complete."); + BOX_INFO("Type \"help\" for a list of commands."); // Set up a context for our work BackupQueries context(connection, conf, readWrite); @@ -572,9 +561,9 @@ int main(int argc, const char *argv[]) } // Done... stop nicely - if(!quiet) BOX_INFO("Logging off..."); + BOX_INFO("Logging off..."); connection.QueryFinished(); - if(!quiet) BOX_INFO("Session finished."); + BOX_INFO("Session finished."); // Return code returnCode = context.GetReturnCode(); -- cgit v1.2.3