Changeset 2604


Ignore:
Timestamp:
10/02/2010 19:01:12 (2 years ago)
Author:
chris
Message:

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.

Location:
box/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/bin/bbackupquery/bbackupquery.cpp

    r2493 r2604  
    6161void PrintUsageAndExit() 
    6262{ 
    63         printf("Usage: bbackupquery [-q] [-w] " 
     63        printf("Usage: bbackupquery [-q*|v*|V|W<level>] [-w] " 
    6464#ifdef WIN32 
    6565        "[-u] " 
     
    124124 
    125125#ifdef WIN32 
    126         const char* validOpts = "qvwuc:l:o:O:W:"; 
     126        const char* validOpts = "qvVwuc:l:o:O:W:"; 
    127127        bool unicodeConsole = false; 
    128128#else 
    129         const char* validOpts = "qvwc:l:o:O:W:"; 
     129        const char* validOpts = "qvVwc:l:o:O:W:"; 
    130130#endif 
    131131 
     
    139139                switch(c) 
    140140                { 
    141                         case 'q': 
     141                case 'q': 
    142142                        { 
    143143                                if(masterLevel == Log::NOTHING) 
     
    152152                        break; 
    153153 
    154                         case 'v': 
     154                case 'v': 
    155155                        { 
    156156                                if(masterLevel == Log::EVERYTHING) 
     
    162162                                } 
    163163                                masterLevel++; 
     164                        } 
     165                        break; 
     166 
     167                case 'V': 
     168                        { 
     169                                masterLevel = Log::EVERYTHING; 
    164170                        } 
    165171                        break; 
  • box/trunk/lib/backupclient/BackupClientFileAttributes.cpp

    r2493 r2604  
    235235        if(mpClearAttributes->GetSize() != rAttr.mpClearAttributes->GetSize()) 
    236236        { 
     237                BOX_TRACE("Attribute Compare: Attributes objects are " 
     238                        "different sizes, cannot compare them: local " << 
     239                        mpClearAttributes->GetSize() << " bytes, remote " << 
     240                        rAttr.mpClearAttributes->GetSize() << " bytes"); 
    237241                return false; 
    238242        } 
     
    242246        attr_StreamFormat *a1 = (attr_StreamFormat*)mpClearAttributes->GetBuffer(); 
    243247        attr_StreamFormat *a2 = (attr_StreamFormat*)rAttr.mpClearAttributes->GetBuffer(); 
    244          
    245         if(a1->AttributeType != a2->AttributeType 
    246                 || a1->UID != a2->UID 
    247                 || a1->GID != a2->GID 
    248                 || a1->UserDefinedFlags != a2->UserDefinedFlags 
    249                 || a1->Mode != a2->Mode) 
    250         { 
    251                 return false; 
    252         } 
     248 
     249        #define COMPARE(attribute, message) \ 
     250        if (a1->attribute != a2->attribute) \ 
     251        { \ 
     252                BOX_TRACE("Attribute Compare: " << message << " differ: " \ 
     253                        "local " << a1->attribute << ", " \ 
     254                        "remote " << a2->attribute); \ 
     255                return false; \ 
     256        } 
     257        COMPARE(AttributeType, "Attribute types"); 
     258        COMPARE(UID, "UIDs"); 
     259        COMPARE(GID, "GIDs"); 
     260        COMPARE(UserDefinedFlags, "User-defined flags"); 
     261        COMPARE(Mode, "Modes"); 
    253262         
    254263        if(!IgnoreModTime) 
     
    258267                if(t1 != t2) 
    259268                { 
     269                        BOX_TRACE("Attribute Compare: File modification " 
     270                                "times differ: local " << t1 << ", " 
     271                                "remote " << t2); 
    260272                        return false; 
    261273                } 
     
    268280                if(t1 != t2) 
    269281                { 
     282                        BOX_TRACE("Attribute Compare: Attribute modification " 
     283                                "times differ: local " << t1 << ", " 
     284                                "remote " << t2); 
    270285                        return false; 
    271286                } 
     
    277292        { 
    278293                // Symlink strings don't match. This also compares xattrs 
    279                 if(::memcmp(a1 + 1, a2 + 1, size - sizeof(attr_StreamFormat)) != 0) 
    280                 { 
     294                int datalen = size - sizeof(attr_StreamFormat); 
     295 
     296                if(::memcmp(a1 + 1, a2 + 1, datalen) != 0) 
     297                { 
     298                        std::string s1((char *)(a1 + 1), datalen); 
     299                        std::string s2((char *)(a2 + 1), datalen); 
     300                        BOX_TRACE("Attribute Compare: Symbolic link target " 
     301                                "or extended attributes differ: " 
     302                                "local " << PrintEscapedBinaryData(s1) << ", " 
     303                                "remote " << PrintEscapedBinaryData(s2)); 
    281304                        return false; 
    282305                } 
  • box/trunk/lib/common/Logging.cpp

    r2546 r2604  
    496496        return true; 
    497497} 
     498 
     499std::string PrintEscapedBinaryData(const std::string& rInput) 
     500{ 
     501        std::ostringstream output; 
     502 
     503        for (size_t i = 0; i < rInput.length(); i++) 
     504        { 
     505                if (isprint(rInput[i])) 
     506                { 
     507                        output << rInput[i]; 
     508                } 
     509                else 
     510                { 
     511                        output << "\\x" << std::hex << std::setw(2) << 
     512                                std::setfill('0') << (int) rInput[i] << 
     513                                std::dec; 
     514                } 
     515        } 
     516 
     517        return output.str(); 
     518} 
  • box/trunk/lib/common/Logging.h

    r2544 r2604  
    1818 
    1919#include "FileStream.h" 
    20  
    21 /* 
    22 #define BOX_LOG(level, stuff) \ 
    23 { \ 
    24     if(Log::sMaxLoggingLevelForAnyOutput >= level) \ 
    25         std::ostringstream line; \ 
    26         line << stuff; \ 
    27         Log::Write(level, __FILE__, __LINE__, line.str()); \ 
    28     } \ 
    29 } 
    30 */ 
    3120 
    3221#define BOX_LOG(level, stuff) \ 
     
    5342        { BOX_LOG(Log::TRACE, stuff) } 
    5443 
     44#define BOX_SYS_ERROR(stuff) \ 
     45        stuff << ": " << std::strerror(errno) << " (" << errno << ")" 
     46 
    5547#define BOX_LOG_SYS_WARNING(stuff) \ 
    56         BOX_WARNING(stuff << ": " << std::strerror(errno) << " (" << errno << ")") 
     48        BOX_WARNING(BOX_SYS_ERROR(stuff)) 
    5749#define BOX_LOG_SYS_ERROR(stuff) \ 
    58         BOX_ERROR(stuff << ": " << std::strerror(errno) << " (" << errno << ")") 
     50        BOX_ERROR(BOX_SYS_ERROR(stuff)) 
    5951#define BOX_LOG_SYS_FATAL(stuff) \ 
    60         BOX_FATAL(stuff << ": " << std::strerror(errno) << " (" << errno << ")") 
     52        BOX_FATAL(BOX_SYS_ERROR(stuff)) 
     53 
     54#define LOG_AND_THROW_ERROR(message, filename, exception, subtype) \ 
     55        BOX_LOG_SYS_ERROR(message << ": " << filename); \ 
     56        THROW_EXCEPTION_MESSAGE(exception, subtype, \ 
     57                BOX_SYS_ERROR(message << ": " << filename)); 
    6158 
    6259inline std::string GetNativeErrorMessage() 
     
    340337}; 
    341338 
     339std::string PrintEscapedBinaryData(const std::string& rInput); 
     340 
    342341#endif // LOGGING__H 
Note: See TracChangeset for help on using the changeset viewer.