diff options
author | Chris Wilson <chris+github@qwirx.com> | 2010-02-10 19:01:12 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2010-02-10 19:01:12 +0000 |
commit | 32506e95005d396f91557e4a730ca0ee8e2c3102 (patch) | |
tree | adf918be1d281073c969259d47c4e4e5072ba68d /lib/common | |
parent | 4c4cc95eb12403298d93404f225ac04fec16586b (diff) |
Log more detailed info about backup comparison failures, for debugging.
Enable -V option in bbackupquery, and document that -q, -v, -V and
-W<level> are allowed in the command-line help.
Diffstat (limited to 'lib/common')
-rw-r--r-- | lib/common/Logging.cpp | 21 | ||||
-rw-r--r-- | lib/common/Logging.h | 27 |
2 files changed, 34 insertions, 14 deletions
diff --git a/lib/common/Logging.cpp b/lib/common/Logging.cpp index 681e1352..296443ea 100644 --- a/lib/common/Logging.cpp +++ b/lib/common/Logging.cpp @@ -495,3 +495,24 @@ bool FileLogger::Log(Log::Level Level, const std::string& rFile, Logging::Add(this); return true; } + +std::string PrintEscapedBinaryData(const std::string& rInput) +{ + std::ostringstream output; + + for (size_t i = 0; i < rInput.length(); i++) + { + if (isprint(rInput[i])) + { + output << rInput[i]; + } + else + { + output << "\\x" << std::hex << std::setw(2) << + std::setfill('0') << (int) rInput[i] << + std::dec; + } + } + + return output.str(); +} diff --git a/lib/common/Logging.h b/lib/common/Logging.h index 35e14d83..24863d2c 100644 --- a/lib/common/Logging.h +++ b/lib/common/Logging.h @@ -18,17 +18,6 @@ #include "FileStream.h" -/* -#define BOX_LOG(level, stuff) \ -{ \ - if(Log::sMaxLoggingLevelForAnyOutput >= level) \ - std::ostringstream line; \ - line << stuff; \ - Log::Write(level, __FILE__, __LINE__, line.str()); \ - } \ -} -*/ - #define BOX_LOG(level, stuff) \ { \ std::ostringstream _box_log_line; \ @@ -52,12 +41,20 @@ if (Logging::IsEnabled(Log::TRACE)) \ { BOX_LOG(Log::TRACE, stuff) } +#define BOX_SYS_ERROR(stuff) \ + stuff << ": " << std::strerror(errno) << " (" << errno << ")" + #define BOX_LOG_SYS_WARNING(stuff) \ - BOX_WARNING(stuff << ": " << std::strerror(errno) << " (" << errno << ")") + BOX_WARNING(BOX_SYS_ERROR(stuff)) #define BOX_LOG_SYS_ERROR(stuff) \ - BOX_ERROR(stuff << ": " << std::strerror(errno) << " (" << errno << ")") + BOX_ERROR(BOX_SYS_ERROR(stuff)) #define BOX_LOG_SYS_FATAL(stuff) \ - BOX_FATAL(stuff << ": " << std::strerror(errno) << " (" << errno << ")") + BOX_FATAL(BOX_SYS_ERROR(stuff)) + +#define LOG_AND_THROW_ERROR(message, filename, exception, subtype) \ + BOX_LOG_SYS_ERROR(message << ": " << filename); \ + THROW_EXCEPTION_MESSAGE(exception, subtype, \ + BOX_SYS_ERROR(message << ": " << filename)); inline std::string GetNativeErrorMessage() { @@ -339,4 +336,6 @@ class HideExceptionMessageGuard bool mOldHiddenState; }; +std::string PrintEscapedBinaryData(const std::string& rInput); + #endif // LOGGING__H |