Ignore:
Timestamp:
03/08/2007 00:29:31 (5 years ago)
Author:
chris
Message:

Convert most printf() and fprintf() calls to use logging framework
instead. (merges [1789])

File:
1 edited

Legend:

Unmodified
Added
Removed
  • box/chris/general/lib/backupstore/BackupStoreCheck.cpp

    r969 r1790  
    103103                        if(!mQuiet) 
    104104                        { 
    105                                 ::printf("Couldn't lock the account -- did not check.\nTry again later after the client has disconnected.\nAlternatively, forcibly kill the server.\n"); 
     105                                BOX_ERROR("Failed to lock the account -- did not check.\nTry again later after the client has disconnected.\nAlternatively, forcibly kill the server."); 
    106106                        } 
    107107                        THROW_EXCEPTION(BackupStoreException, CouldNotLockStoreAccount) 
     
    111111        if(!mQuiet && mFixErrors) 
    112112        { 
    113                 ::printf("NOTE: Will fix errors encountered during checking.\n"); 
     113                BOX_NOTICE("Will fix errors encountered during checking."); 
    114114        } 
    115115 
     
    117117        if(!mQuiet) 
    118118        { 
    119                 ::printf("Check store account ID %08x\nPhase 1, check objects...\n", mAccountID); 
     119                BOX_INFO("Checking store account ID " << 
     120                        BOX_FORMAT_ACCOUNT(mAccountID) << "..."); 
     121                BOX_INFO("Phase 1, check objects..."); 
    120122        } 
    121123        CheckObjects(); 
     
    124126        if(!mQuiet) 
    125127        { 
    126                 ::printf("Phase 2, check directories...\n"); 
     128                BOX_INFO("Phase 2, check directories..."); 
    127129        } 
    128130        CheckDirectories(); 
     
    131133        if(!mQuiet) 
    132134        { 
    133                 ::printf("Phase 3, check root...\n"); 
     135                BOX_INFO("Phase 3, check root..."); 
    134136        } 
    135137        CheckRoot(); 
     
    138140        if(!mQuiet) 
    139141        { 
    140                 ::printf("Phase 4, fix unattached objects...\n"); 
     142                BOX_INFO("Phase 4, fix unattached objects..."); 
    141143        } 
    142144        CheckUnattachedObjects(); 
     
    145147        if(!mQuiet) 
    146148        { 
    147                 ::printf("Phase 5, fix unrecovered inconsistencies...\n"); 
     149                BOX_INFO("Phase 5, fix unrecovered inconsistencies..."); 
    148150        } 
    149151        FixDirsWithWrongContainerID(); 
     
    153155        if(!mQuiet) 
    154156        { 
    155                 ::printf("Phase 6, regenerate store info...\n"); 
     157                BOX_INFO("Phase 6, regenerate store info..."); 
    156158        } 
    157159        WriteNewStoreInfo(); 
     
    161163        if(mNumberErrorsFound > 0) 
    162164        { 
    163                 ::printf("%lld errors found\n", mNumberErrorsFound); 
     165                BOX_WARNING("Finished checking store account ID " << 
     166                        BOX_FORMAT_ACCOUNT(mAccountID) << ": " << 
     167                        mNumberErrorsFound << " errors found"); 
    164168                if(!mFixErrors) 
    165169                { 
    166                         ::printf("NOTE: No changes to the store account have been made.\n"); 
     170                        BOX_WARNING("No changes to the store account " 
     171                                "have been made."); 
    167172                } 
    168173                if(!mFixErrors && mNumberErrorsFound > 0) 
    169174                { 
    170                         ::printf("Run again with fix option to fix these errors\n"); 
    171                 } 
    172                 if(mNumberErrorsFound > 0) 
    173                 { 
    174                         ::printf("You should now use bbackupquery on the client machine to examine the store.\n"); 
     175                        BOX_WARNING("Run again with fix option to " 
     176                                "fix these errors"); 
     177                } 
     178                if(mFixErrors && mNumberErrorsFound > 0) 
     179                { 
     180                        BOX_WARNING("You should now use bbackupquery " 
     181                                "on the client machine to examine the store."); 
    175182                        if(mLostAndFoundDirectoryID != 0) 
    176183                        { 
    177                                 ::printf("A lost+found directory was created in the account root.\n"\ 
    178                                         "This contains files and directories which could not be matched to existing directories.\n"\ 
    179                                         "bbackupd will delete this directory in a few days time.\n"); 
     184                                BOX_WARNING("A lost+found directory was " 
     185                                        "created in the account root.\n" 
     186                                        "This contains files and directories " 
     187                                        "which could not be matched to " 
     188                                        "existing directories.\n"\ 
     189                                        "bbackupd will delete this directory " 
     190                                        "in a few days time."); 
    180191                        } 
    181192                } 
     
    183194        else 
    184195        { 
    185                 ::printf("Store account checked, no errors found.\n"); 
     196                BOX_NOTICE("Finished checking store account ID " << 
     197                        BOX_FORMAT_ACCOUNT(mAccountID) << ": " 
     198                        "no errors found"); 
    186199        } 
    187200} 
     
    305318                        else 
    306319                        { 
    307                                 ::printf("Spurious or invalid directory %s/%s found%s -- delete manually\n", rDirName.c_str(), (*i).c_str(), mFixErrors?", deleting":""); 
     320                                BOX_WARNING("Spurious or invalid directory " << 
     321                                        rDirName << DIRECTORY_SEPARATOR <<  
     322                                        (*i) << " found, " << 
     323                                        (mFixErrors?"deleting":"delete manually")); 
    308324                                ++mNumberErrorsFound; 
    309325                        } 
     
    337353        if(!RaidFileRead::DirectoryExists(mDiscSetNumber, dirName)) 
    338354        { 
    339                 TRACE1("RaidFile dir %s does not exist\n", dirName.c_str()); 
     355                BOX_WARNING("RaidFile dir " << dirName << " does not exist"); 
    340356                return; 
    341357        } 
     
    379395                { 
    380396                        // Unexpected or bad file, delete it 
    381                         ::printf("Spurious file %s" DIRECTORY_SEPARATOR "%s " 
    382                                 "found%s\n", dirName.c_str(), (*i).c_str(),  
    383                                 mFixErrors?", deleting":""); 
     397                        BOX_WARNING("Spurious file " << dirName <<  
     398                                DIRECTORY_SEPARATOR << (*i) << " found" << 
     399                                (mFixErrors?", deleting":"")); 
    384400                        ++mNumberErrorsFound; 
    385401                        if(mFixErrors) 
     
    402418                        { 
    403419                                // File was bad, delete it 
    404                                 ::printf("Corrupted file %s%s found%s\n", dirName.c_str(), leaf, mFixErrors?", deleting":""); 
     420                                BOX_WARNING("Corrupted file " << dirName << 
     421                                        leaf << " found" << 
     422                                        (mFixErrors?", deleting":"")); 
    405423                                ++mNumberErrorsFound; 
    406424                                if(mFixErrors) 
     
    510528        { 
    511529                // Get that dodgy thing deleted! 
    512                 ::printf("Have file as root directory. This is bad.\n"); 
     530                BOX_ERROR("Have file as root directory. This is bad."); 
    513531                return -1; 
    514532        } 
     
    597615                                { 
    598616                                        // Wasn't quite right, and has been modified 
    599                                         ::printf("Directory ID %llx has bad structure\n", pblock->mID[e]); 
     617                                        BOX_WARNING("Directory ID " << 
     618                                                BOX_FORMAT_OBJECTID(pblock->mID[e]) << 
     619                                                " has bad structure"); 
    600620                                        ++mNumberErrorsFound; 
    601621                                        isModified = true; 
     
    623643                                                { 
    624644                                                        // Entry is of wrong type 
    625                                                         ::printf("Directory ID %llx references object %llx which has a different type than expected.\n", pblock->mID[e], en->GetObjectID()); 
     645                                                        BOX_WARNING("Directory ID " << 
     646                                                                BOX_FORMAT_OBJECTID(pblock->mID[e]) << 
     647                                                                " references object " << 
     648                                                                BOX_FORMAT_OBJECTID(en->GetObjectID()) << 
     649                                                                " which has a different type than expected."); 
    626650                                                        badEntry = true; 
    627651                                                } 
     
    631655                                                        if(iflags & Flags_IsContained) 
    632656                                                        { 
     657                                                                BOX_WARNING("Directory ID " << 
     658                                                                        BOX_FORMAT_OBJECTID(pblock->mID[e]) << 
     659                                                                        " references object " << 
     660                                                                        BOX_FORMAT_OBJECTID(en->GetObjectID()) << 
     661                                                                        " which is already contained."); 
    633662                                                                badEntry = true; 
    634                                                                 ::printf("Directory ID %llx references object %llx which is already contained.\n", pblock->mID[e], en->GetObjectID()); 
    635663                                                        } 
    636664                                                        else 
     
    646674                                                                        { 
    647675                                                                                // Add to will fix later list 
    648                                                                                 ::printf("Directory ID %llx has wrong container ID.\n", en->GetObjectID()); 
     676                                                                                BOX_WARNING("Directory ID " << BOX_FORMAT_OBJECTID(en->GetObjectID()) << " has wrong container ID."); 
    649677                                                                                mDirsWithWrongContainerID.push_back(en->GetObjectID()); 
    650678                                                                        } 
     
    652680                                                                        { 
    653681                                                                                // This is OK for files, they might move 
    654                                                                                 ::printf("File ID %llx has different container ID, probably moved\n", en->GetObjectID()); 
     682                                                                                BOX_WARNING("File ID " << BOX_FORMAT_OBJECTID(en->GetObjectID()) << " has different container ID, probably moved"); 
    655683                                                                        } 
    656684                                                                         
     
    671699                                                                isModified = true; 
    672700                                                                // Tell user 
    673                                                                 ::printf("Directory ID %llx has wrong size for object %llx\n", pblock->mID[e], en->GetObjectID()); 
     701                                                                BOX_WARNING("Directory ID " << BOX_FORMAT_OBJECTID(pblock->mID[e]) << " has wrong size for object " << BOX_FORMAT_OBJECTID(en->GetObjectID())); 
    674702                                                        } 
    675703                                                } 
     
    687715                                                        // Just remove the entry 
    688716                                                        badEntry = true; 
    689                                                         ::printf("Directory ID %llx references object %llx which does not exist.\n", pblock->mID[e], en->GetObjectID()); 
     717                                                        BOX_WARNING("Directory ID " << BOX_FORMAT_OBJECTID(pblock->mID[e]) << " references object " << BOX_FORMAT_OBJECTID(en->GetObjectID()) << " which does not exist."); 
    690718                                                } 
    691719                                        } 
     
    730758                                if(isModified && mFixErrors) 
    731759                                {        
    732                                         ::printf("Fixing directory ID %llx\n", pblock->mID[e]); 
     760                                        BOX_WARNING("Fixing directory ID " << BOX_FORMAT_OBJECTID(pblock->mID[e])); 
    733761 
    734762                                        // Save back to disc 
Note: See TracChangeset for help on using the changeset viewer.