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/bin/bbackupctl/bbackupctl.cpp

    r1784 r1790  
    110110 
    111111        // Read in the configuration file 
    112         if(!quiet) printf("Using configuration file %s\n",  
    113                 configFilename.c_str()); 
     112        if(!quiet) BOX_NOTICE("Using configuration file " << configFilename); 
    114113 
    115114        std::string errs; 
     
    120119        if(config.get() == 0 || !errs.empty()) 
    121120        { 
    122                 printf("Invalid configuration file:\n%s", errs.c_str()); 
     121                BOX_ERROR("Invalid configuration file: " << errs); 
    123122                return 1; 
    124123        } 
     
    129128        if(!conf.KeyExists("CommandSocket")) 
    130129        { 
    131                 printf("Daemon isn't using a control socket, " 
     130                BOX_ERROR("Daemon isn't using a control socket, " 
    132131                        "could not execute command.\n" 
    133132                        "Add a CommandSocket declaration to the " 
    134                         "bbackupd.conf file.\n"); 
     133                        "bbackupd.conf file."); 
    135134                return 1; 
    136135        } 
     
    154153        catch(...) 
    155154        { 
    156                 printf("Failed to connect to daemon control socket.\n" 
     155                BOX_ERROR("Failed to connect to daemon control socket.\n" 
    157156                        "Possible causes:\n" 
    158157                        "  * Daemon not running\n" 
    159158                        "  * Daemon busy syncing with store server\n" 
    160159                        "  * Another bbackupctl process is communicating with the daemon\n" 
    161                         "  * Daemon is waiting to recover from an error\n" 
     160                        "  * Daemon is waiting to recover from an error" 
    162161                ); 
    163  
    164 #if defined WIN32 && ! defined NDEBUG 
    165                 BOX_ERROR("Failed to connect to the command socket"); 
    166 #endif 
    167162 
    168163                return 1; 
     
    194189                        &updateStoreInterval, &minimumFileAge, &maxUploadWait) != 4) 
    195190        { 
    196                 printf("Config summary didn't decode\n"); 
     191                BOX_ERROR("Config summary didn't decode."); 
    197192                return 1; 
    198193        } 
     
    200195        if(!quiet) 
    201196        { 
    202                 printf("Daemon configuration summary:\n" 
    203                         "  AutomaticBackup = %s\n" 
    204                         "  UpdateStoreInterval = %d seconds\n" 
    205                         "  MinimumFileAge = %d seconds\n" 
    206                         "  MaxUploadWait = %d seconds\n", 
    207                         autoBackup?"true":"false", updateStoreInterval,  
    208                         minimumFileAge, maxUploadWait); 
     197                BOX_INFO("Daemon configuration summary:\n" 
     198                        "  AutomaticBackup = " <<  
     199                        (autoBackup?"true":"false") << "\n" 
     200                        "  UpdateStoreInterval = " << updateStoreInterval <<  
     201                        " seconds\n" 
     202                        "  MinimumFileAge = " << minimumFileAge << " seconds\n" 
     203                        "  MaxUploadWait = " << maxUploadWait << " seconds\n"); 
    209204        } 
    210205 
     
    267262                        if (currentState != 0) 
    268263                        { 
    269                                 printf("Waiting for current sync/error state " 
    270                                         "to finish...\n"); 
     264                                BOX_INFO("Waiting for current sync/error state " 
     265                                        "to finish..."); 
    271266                        } 
    272267                } 
     
    311306                                if(line == "start-sync") 
    312307                                { 
    313                                         if (!quiet) printf("Sync started...\n"); 
     308                                        if (!quiet) BOX_INFO("Sync started..."); 
    314309                                        syncIsRunning = true; 
    315310                                } 
     
    318313                                        if (syncIsRunning) 
    319314                                        { 
    320                                                 if (!quiet) printf("Sync finished.\n"); 
     315                                                if (!quiet) BOX_INFO("Sync finished.\n"); 
    321316                                                // Send a quit command to finish nicely 
    322317                                                connection.Write("quit\n", 5); 
     
    327322                                        else 
    328323                                        { 
    329                                                 if (!quiet) printf("Previous sync finished.\n"); 
     324                                                if (!quiet) BOX_INFO("Previous sync finished."); 
    330325                                        } 
    331326                                        // daemon must still be busy 
     
    341336                                        if(!quiet) 
    342337                                        { 
    343                                                 printf("Succeeded.\n"); 
     338                                                BOX_INFO("Succeeded.\n"); 
    344339                                        } 
    345340                                        finished = true; 
     
    347342                                else if(line == "error") 
    348343                                { 
    349                                         printf("ERROR. (Check command spelling)\n"); 
     344                                        BOX_ERROR("Check command spelling"); 
    350345                                        returnCode = 1; 
    351346                                        finished = true; 
Note: See TracChangeset for help on using the changeset viewer.