Changeset 1790


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])

Location:
box/chris/general
Files:
14 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; 
  • box/chris/general/bin/bbackupquery/BackupQueries.cpp

    r1784 r1790  
    182182                                GetConsoleCP())) 
    183183                        { 
    184                                 printf("Failed to convert encoding"); 
     184                                BOX_ERROR("Failed to convert encoding"); 
    185185                                return; 
    186186                        } 
     
    256256                if(alias[a] == 0) 
    257257                { 
    258                         printf("Unrecognised command: %s\n", Command); 
     258                        BOX_ERROR("Unrecognised command: " << Command); 
    259259                        return; 
    260260                } 
     
    276276                        if(::strchr(commands[cmd].opts, *c) == NULL) 
    277277                        { 
    278                                 printf("Invalid option '%c' for command %s\n",  
    279                                         *c, commands[cmd].name); 
     278                                BOX_ERROR("Invalid option '" << *c << "' for " 
     279                                        "command " << commands[cmd].name); 
    280280                                return; 
    281281                        } 
     
    306306                { 
    307307                        // Simple implementation, so do it here 
    308                         printf("%s (%08llx)\n",  
    309                                 GetCurrentDirectoryName().c_str(),  
    310                                 (long long)GetCurrentDirectoryID()); 
     308                        BOX_INFO(GetCurrentDirectoryName() << " (" << 
     309                                BOX_FORMAT_OBJECTID(GetCurrentDirectoryID())); 
    311310                } 
    312311                break; 
     
    321320                 
    322321        case COMMAND_sh: 
    323                 printf("The command to run must be specified as an argument.\n"); 
     322                BOX_ERROR("The command to run must be specified as an argument."); 
    324323                break; 
    325324                 
     
    402401                if(rootDir == 0) 
    403402                { 
    404                         printf("Directory '%s' not found on store\n", 
    405                                 args[0].c_str()); 
     403                        BOX_ERROR("Directory '" << args[0] << "' not found " 
     404                                "on store."); 
    406405                        return; 
    407406                } 
     
    748747        if(args.size() != 1 || args[0].size() == 0) 
    749748        { 
    750                 printf("Incorrect usage.\ncd [-o] [-d] <directory>\n"); 
     749                BOX_ERROR("Incorrect usage. cd [-o] [-d] <directory>"); 
    751750                return; 
    752751        } 
     
    765764        if(id == 0) 
    766765        { 
    767                 printf("Directory '%s' not found\n", args[0].c_str()); 
     766                BOX_ERROR("Directory '" << args[0] << "' not found."); 
    768767                return; 
    769768        } 
     
    786785        if(args.size() != 1 || args[0].size() == 0) 
    787786        { 
    788                 printf("Incorrect usage.\nlcd <local-directory>\n"); 
     787                BOX_ERROR("Incorrect usage. lcd <local-directory>"); 
    789788                SetReturnCode(COMMAND_RETURN_ERROR); 
    790789                return; 
     
    796795        if(!ConvertConsoleToUtf8(args[0].c_str(), dirName)) 
    797796        { 
    798                 printf("Failed to convert path from console encoding.\n"); 
     797                BOX_ERROR("Failed to convert path from console encoding."); 
    799798                SetReturnCode(COMMAND_RETURN_ERROR); 
    800799                return; 
     
    806805        if(result != 0) 
    807806        { 
    808                 printf((errno == ENOENT || errno == ENOTDIR)?"Directory '%s' does not exist\n":"Error changing dir to '%s'\n", 
    809                         args[0].c_str()); 
     807                if(errno == ENOENT || errno == ENOTDIR) 
     808                { 
     809                        BOX_ERROR("Directory '" << args[0] << "' does not exist."); 
     810                } 
     811                else 
     812                { 
     813                        BOX_ERROR("Error changing to directory '" << 
     814                                args[0] << ": " << strerror(errno)); 
     815                } 
     816 
    810817                SetReturnCode(COMMAND_RETURN_ERROR); 
    811818                return; 
     
    816823        if(::getcwd(wd, PATH_MAX) == 0) 
    817824        { 
    818                 printf("Error getting current directory\n"); 
     825                BOX_ERROR("Error getting current directory: " << 
     826                        strerror(errno)); 
    819827                SetReturnCode(COMMAND_RETURN_ERROR); 
    820828                return; 
     
    824832        if(!ConvertUtf8ToConsole(wd, dirName)) 
    825833        { 
    826                 printf("Failed to convert new path from console encoding.\n"); 
     834                BOX_ERROR("Failed to convert new path from console encoding."); 
    827835                SetReturnCode(COMMAND_RETURN_ERROR); 
    828836                return; 
    829837        } 
    830         printf("Local current directory is now '%s'\n", dirName.c_str()); 
     838        BOX_INFO("Local current directory is now '" << dirName << "'."); 
    831839#else 
    832         printf("Local current directory is now '%s'\n", wd); 
     840        BOX_INFO("Local current directory is now '" << wd << "'."); 
    833841#endif 
    834842} 
     
    848856        if(args.size() != 2) 
    849857        { 
    850                 printf("Incorrect usage.\ngetobject <object-id> <local-filename>\n"); 
     858                BOX_ERROR("Incorrect usage. getobject <object-id> " 
     859                        "<local-filename>"); 
    851860                return; 
    852861        } 
     
    855864        if(id == std::numeric_limits<long long>::min() || id == std::numeric_limits<long long>::max() || id == 0) 
    856865        { 
    857                 printf("Not a valid object ID (specified in hex)\n"); 
     866                BOX_ERROR("Not a valid object ID (specified in hex)."); 
    858867                return; 
    859868        } 
     
    863872        if(::stat(args[1].c_str(), &st) == 0 || errno != ENOENT) 
    864873        { 
    865                 printf("The local file %s already exists\n", args[1].c_str()); 
     874                BOX_ERROR("The local file '" << args[1] << " already exists."); 
    866875                return; 
    867876        } 
     
    881890                        objectStream->CopyStreamTo(out); 
    882891                         
    883                         printf("Object ID %08llx fetched successfully.\n", id); 
     892                        BOX_INFO("Object ID " << BOX_FORMAT_OBJECTID(id) << 
     893                                " fetched successfully."); 
    884894                } 
    885895                else 
    886896                { 
    887                         printf("Object does not exist on store.\n"); 
     897                        BOX_ERROR("Object ID " << BOX_FORMAT_OBJECTID(id) << 
     898                                " does not exist on store."); 
    888899                        ::unlink(args[1].c_str()); 
    889900                } 
     
    892903        { 
    893904                ::unlink(args[1].c_str()); 
    894                 printf("Error occured fetching object.\n"); 
     905                BOX_ERROR("Error occured fetching object."); 
    895906        } 
    896907} 
     
    912923        if(args.size() < 1 || (opts['i'] && args.size() != 2) || args.size() > 2) 
    913924        { 
    914                 printf("Incorrect usage.\n" 
     925                BOX_ERROR("Incorrect usage.\n" 
    915926                        "get <remote-filename> [<local-filename>] or\n" 
    916                         "get -i <object-id> <local-filename>\n"); 
     927                        "get -i <object-id> <local-filename>"); 
    917928                return; 
    918929        } 
     
    932943                        if(!ConvertConsoleToUtf8(i->c_str(), out)) 
    933944                        { 
    934                                 fprintf(stderr, "failed to convert encoding\n"); 
     945                                BOX_ERROR("Failed to convert encoding."); 
    935946                                return; 
    936947                        } 
     
    953964                                if(dirId == 0) 
    954965                                { 
    955                                         printf("Directory '%s' not found\n",  
    956                                                 dirName.c_str()); 
     966                                        BOX_ERROR("Directory '" << dirName << 
     967                                                "' not found."); 
    957968                                        return; 
    958969                                } 
     
    982993                                fileId == 0) 
    983994                        { 
    984                                 printf("Not a valid object ID (specified in hex)\n"); 
     995                                BOX_ERROR("Not a valid object ID (specified in hex)."); 
    985996                                return; 
    986997                        } 
     
    9891000                        if(dir.FindEntryByID(fileId) == 0) 
    9901001                        { 
    991                                 printf("ID '%08llx' not found in current " 
     1002                                BOX_ERROR("File ID " <<  
     1003                                        BOX_FORMAT_OBJECTID(fileId) << 
     1004                                        " not found in current " 
    9921005                                        "directory on store.\n" 
    993                                         "(You can only download objects by ID " 
    994                                         "from the current directory.)\n",  
    995                                         fileId); 
     1006                                        "(You can only download files by ID " 
     1007                                        "from the current directory.)"); 
    9961008                                return; 
    9971009                        } 
     
    10081020                        if(en == 0) 
    10091021                        { 
    1010                                 printf("Filename '%s' not found in current " 
     1022                                BOX_ERROR("Filename '" << args[0] << "' " 
     1023                                        "not found in current " 
    10111024                                        "directory on store.\n" 
    10121025                                        "(Subdirectories in path not " 
    1013                                         "searched.)\n", args[0].c_str()); 
     1026                                        "searched.)"); 
    10141027                                return; 
    10151028                        } 
     
    10281041        if(::stat(localName.c_str(), &st) == 0 || errno != ENOENT) 
    10291042        { 
    1030                 printf("The local file %s already exists, will not " 
    1031                         "overwrite it.\n", localName.c_str()); 
     1043                BOX_ERROR("The local file " << localName << " already exists, " 
     1044                        "will not overwrite it."); 
    10321045                SetReturnCode(COMMAND_RETURN_ERROR); 
    10331046                return; 
     
    10471060 
    10481061                // Done. 
    1049                 printf("Object ID %08llx fetched sucessfully.\n", fileId); 
     1062                BOX_INFO("Object ID " << BOX_FORMAT_OBJECTID(fileId) << 
     1063                        " fetched successfully."); 
    10501064        } 
    10511065        catch (BoxException &e) 
     
    11611175                else 
    11621176                { 
    1163                         printf("Warning: couldn't determine the time of the last synchronisation -- checks not performed.\n"); 
     1177                        BOX_WARNING("Failed to determine the time of the last " 
     1178                                "synchronisation -- checks not performed."); 
    11641179                } 
    11651180        } 
     
    11681183        if(params.mQuickCompare) 
    11691184        { 
    1170                 printf("WARNING: Quick compare used -- file attributes are not checked.\n"); 
     1185                BOX_WARNING("Quick compare used -- file attributes are not " 
     1186                        "checked."); 
    11711187        } 
    11721188         
     
    11931209                if(!params.mIgnoreExcludes) 
    11941210                { 
    1195                         printf("Cannot use excludes on directory to directory comparison -- use -E flag to specify ignored excludes\n"); 
     1211                        BOX_ERROR("Cannot use excludes on directory to directory comparison -- use -E flag to specify ignored excludes."); 
    11961212                        return; 
    11971213                } 
     
    12041220        else 
    12051221        { 
    1206                 printf("Incorrect usage.\ncompare -a\n or compare -l <location-name>\n or compare <store-dir-name> <local-dir-name>\n"); 
     1222                BOX_ERROR("Incorrect usage.\ncompare -a\n or compare -l <location-name>\n or compare <store-dir-name> <local-dir-name>"); 
    12071223                return; 
    12081224        } 
     
    12101226        if (!params.mQuietCompare) 
    12111227        {        
    1212                 printf("\n[ %d (of %d) differences probably due to file " 
    1213                         "modifications after the last upload ]\n", 
    1214                         params.mDifferencesExplainedByModTime,  
    1215                         params.mDifferences); 
    1216         } 
    1217  
    1218         printf("Differences: %d (%d dirs excluded, %d files excluded, " 
    1219                 "%d files not checked)\n", 
    1220                 params.mDifferences, params.mExcludedDirs,  
    1221                 params.mExcludedFiles, params.mUncheckedFiles); 
     1228                BOX_INFO("[ " << 
     1229                        params.mDifferencesExplainedByModTime << " (of " << 
     1230                        params.mDifferences << ") differences probably " 
     1231                        "due to file modifications after the last upload ]"); 
     1232        } 
     1233 
     1234        BOX_INFO("Differences: " << params.mDifferences << " (" << 
     1235                params.mExcludedDirs   << " dirs excluded, " << 
     1236                params.mExcludedFiles  << " files excluded, " << 
     1237                params.mUncheckedFiles << " files not checked)"); 
    12221238         
    12231239        // Set return code? 
     
    12541270        if(!locations.SubConfigurationExists(rLocation.c_str())) 
    12551271        { 
    1256                 printf("Location %s does not exist.\n", rLocation.c_str()); 
     1272                BOX_ERROR("Location " << rLocation << " does not exist."); 
    12571273                return; 
    12581274        } 
     
    12651281                        DIRECTORY_SEPARATOR_ASCHAR) 
    12661282                { 
    1267                         fprintf(stderr, "Warning: location '%s' path ends " 
    1268                                 "with '%s', compare may fail!", 
    1269                                 rLocation.c_str(), DIRECTORY_SEPARATOR); 
     1283                        BOX_WARNING("Location '" << rLocation << "' path ends " 
     1284                                "with '" DIRECTORY_SEPARATOR "', " 
     1285                                "compare may fail!"); 
    12701286                } 
    12711287        } 
     
    13201336        if(dirID == 0) 
    13211337        { 
    1322                 printf("Local directory '%s' exists, but " 
    1323                         "server directory '%s' does not exist\n",  
    1324                         rLocalDir.c_str(), rStoreDir.c_str());           
     1338                BOX_WARNING("Local directory '" << rLocalDir << "' exists, " 
     1339                        "but server directory '" << rStoreDir << "' does not " 
     1340                        "exist."); 
    13251341                rParams.mDifferences ++; 
    13261342                return; 
     
    13701386                if(errno == ENOTDIR) 
    13711387                { 
    1372                         printf("Local object '%s' is a file, " 
    1373                                 "server object '%s' is a directory\n",  
    1374                                 localDirDisplay.c_str(),  
    1375                                 storeDirDisplay.c_str()); 
     1388                        BOX_WARNING("Local object '" << localDirDisplay << "' " 
     1389                                "is a file, server object '" <<  
     1390                                storeDirDisplay << "' is a directory."); 
    13761391                        rParams.mDifferences ++; 
    13771392                } 
    13781393                else if(errno == ENOENT) 
    13791394                { 
    1380                         printf("Local directory '%s' does not exist " 
    1381                                 "(compared to server directory '%s')\n", 
    1382                                 localDirDisplay.c_str(),  
    1383                                 storeDirDisplay.c_str()); 
     1395                        BOX_WARNING("Local directory '" << localDirDisplay << 
     1396                                "' does not exist (compared to server " 
     1397                                "directory '" << storeDirDisplay << "')."); 
    13841398                        rParams.mDifferences ++; 
    13851399                } 
    13861400                else 
    13871401                { 
    1388                         printf("ERROR: stat on local dir '%s'\n",  
    1389                                 localDirDisplay.c_str()); 
     1402                        BOX_WARNING("Failed to access local directory '" << 
     1403                                localDirDisplay << ": " << strerror(errno) << 
     1404                                "'."); 
    13901405                        rParams.mUncheckedFiles ++; 
    13911406                } 
     
    14081423        if(!dir.HasAttributes()) 
    14091424        { 
    1410                 printf("Store directory '%s' doesn't have attributes.\n",  
    1411                         storeDirDisplay.c_str()); 
     1425                BOX_WARNING("Store directory '" << storeDirDisplay << "' " 
     1426                        "doesn't have attributes."); 
    14121427        } 
    14131428        else 
     
    14241439                if(!(attr.Compare(localAttr, true, true /* ignore modification times */))) 
    14251440                { 
    1426                         printf("Local directory '%s' has different attributes " 
    1427                                 "to store directory '%s'.\n", 
    1428                                 localDirDisplay.c_str(),  
    1429                                 storeDirDisplay.c_str()); 
     1441                        BOX_WARNING("Local directory '" << localDirDisplay << 
     1442                                "' has different attributes to store " 
     1443                                "directory '" << storeDirDisplay << "'."); 
    14301444                        rParams.mDifferences ++; 
    14311445                } 
     
    14361450        if(dirhandle == 0) 
    14371451        { 
    1438                 printf("ERROR: opendir on local dir '%s'\n",  
    1439                         localDirDisplay.c_str()); 
     1452                BOX_WARNING("Failed to open local directory '" <<  
     1453                        localDirDisplay << "': " << strerror(errno)); 
    14401454                rParams.mUncheckedFiles ++; 
    14411455                return; 
     
    14581472                                if (localDirEn->d_type != DT_DIR) 
    14591473                                { 
    1460                                         fprintf(stderr, "ERROR: d_type does " 
    1461                                                 "not really work on your " 
    1462                                                 "platform. Reconfigure Box!\n"); 
     1474                                        BOX_ERROR("d_type does not really " 
     1475                                                "work on your platform. " 
     1476                                                "Reconfigure Box!"); 
    14631477                                        return; 
    14641478                                } 
     
    15051519                if(::closedir(dirhandle) != 0) 
    15061520                { 
    1507                         printf("ERROR: closedir on local dir '%s'\n",  
    1508                                 localDirDisplay.c_str()); 
     1521                        BOX_ERROR("Failed to close local directory '" << 
     1522                                localDirDisplay << "': " << strerror(errno)); 
    15091523                } 
    15101524                dirhandle = 0; 
     
    15661580                        { 
    15671581                                // Not found -- report 
    1568                                 printf("Local file '%s' does not exist, " 
    1569                                         "but store file '%s' does.\n", 
    1570                                         localPathDisplay.c_str(), 
    1571                                         storePathDisplay.c_str()); 
     1582                                BOX_WARNING("Local file '" <<  
     1583                                        localDirDisplay << "' does not exist, " 
     1584                                        "but store file '" << 
     1585                                        storePathDisplay << "' does."); 
    15721586                                rParams.mDifferences ++; 
    15731587                        } 
     
    16441658                                                                fileOnServerStream->IsSymLink() /* ignore modification time if it's a symlink */)) 
    16451659                                                { 
    1646                                                         printf("Local file '%s' " 
    1647                                                                 "has different attributes " 
    1648                                                                 "to store file '%s'.\n", 
    1649                                                                 localPathDisplay.c_str(),  
    1650                                                                 storePathDisplay.c_str());                                               
     1660                                                        BOX_WARNING("Local file '" << 
     1661                                                                localPathDisplay << 
     1662                                                                "' has different attributes " 
     1663                                                                "to store file '" << 
     1664                                                                storePathDisplay << 
     1665                                                                "'."); 
    16511666                                                        rParams.mDifferences ++; 
    16521667                                                        if(modifiedAfterLastSync) 
    16531668                                                        { 
    16541669                                                                rParams.mDifferencesExplainedByModTime ++; 
    1655                                                                 printf("(the file above was modified after the last sync time -- might be reason for difference)\n"); 
     1670                                                                BOX_INFO("(the file above was modified after the last sync time -- might be reason for difference)"); 
    16561671                                                        } 
    16571672                                                        else if(i->second->HasAttributes()) 
    16581673                                                        { 
    1659                                                                 printf("(the file above has had new attributes applied)\n"); 
     1674                                                                BOX_INFO("(the file above has had new attributes applied)\n"); 
    16601675                                                        } 
    16611676                                                } 
     
    17231738                                        if(!equal) 
    17241739                                        { 
    1725                                                 printf("Local file '%s' " 
     1740                                                BOX_WARNING("Local file '" << 
     1741                                                        localPathDisplay << "' " 
    17261742                                                        "has different contents " 
    1727                                                         "to store file '%s'.\n", 
    1728                                                         localPathDisplay.c_str(),  
    1729                                                         storePathDisplay.c_str()); 
     1743                                                        "to store file '" << 
     1744                                                        storePathDisplay << 
     1745                                                        "'."); 
    17301746                                                rParams.mDifferences ++; 
    17311747                                                if(modifiedAfterLastSync) 
    17321748                                                { 
    17331749                                                        rParams.mDifferencesExplainedByModTime ++; 
    1734                                                         printf("(the file above was modified after the last sync time -- might be reason for difference)\n"); 
     1750                                                        BOX_INFO("(the file above was modified after the last sync time -- might be reason for difference)"); 
    17351751                                                } 
    17361752                                                else if(i->second->HasAttributes()) 
    17371753                                                { 
    1738                                                         printf("(the file above has had new attributes applied)\n"); 
     1754                                                        BOX_INFO("(the file above has had new attributes applied)\n"); 
    17391755                                                } 
    17401756                                        } 
     
    17951811                                !(rParams.mpExcludeFiles->IsExcluded(localPath))) 
    17961812                        { 
    1797                                 printf("Local file '%s' exists, " 
    1798                                         "but store file '%s' " 
    1799                                         "does not exist.\n", 
    1800                                         localPathDisplay.c_str(), 
    1801                                         storePathDisplay.c_str()); 
     1813                                BOX_WARNING("Local file '" <<  
     1814                                        localPathDisplay << 
     1815                                        "' exists, but store file '" << 
     1816                                        storePathDisplay << 
     1817                                        "' does not."); 
    18021818                                rParams.mDifferences ++; 
    18031819                                 
     
    18101826                                                { 
    18111827                                                        rParams.mDifferencesExplainedByModTime ++; 
    1812                                                         printf("(the file above was modified after the last sync time -- might be reason for difference)\n"); 
     1828                                                        BOX_INFO("(the file above was modified after the last sync time -- might be reason for difference)"); 
    18131829                                                } 
    18141830                                        } 
     
    18531869                        { 
    18541870                                // Not found -- report 
    1855                                 printf("Local directory '%s' is excluded, but " 
    1856                                         "store directory '%s' still exists.\n", 
    1857                                         localPathDisplay.c_str(), 
    1858                                         storePathDisplay.c_str()); 
     1871                                BOX_WARNING("Local directory '" << 
     1872                                        localPathDisplay << "' is excluded, " 
     1873                                        "but store directory '" << 
     1874                                        storePathDisplay << "' still exists."); 
    18591875                                rParams.mDifferences ++; 
    18601876                        } 
     
    18621878                        { 
    18631879                                // Not found -- report 
    1864                                 printf("Local directory '%s' does not exist, " 
    1865                                         "but store directory '%s' does.\n", 
    1866                                         localPathDisplay.c_str(), 
    1867                                         storePathDisplay.c_str()); 
     1880                                BOX_WARNING("Local directory '" << 
     1881                                        localPathDisplay << "' does not exist, " 
     1882                                        "but store directory '" << 
     1883                                        storePathDisplay << "' does."); 
    18681884                                rParams.mDifferences ++; 
    18691885                        } 
     
    19091925                        if(rParams.mpExcludeDirs == 0 || !(rParams.mpExcludeDirs->IsExcluded(localPath))) 
    19101926                        { 
    1911                                 printf("Local directory '%s' exists, but " 
    1912                                         "store directory '%s' does not exist.\n", 
    1913                                         localPathDisplay.c_str(), 
    1914                                         storePathDisplay.c_str()); 
     1927                                BOX_WARNING("Local directory '" << 
     1928                                        localPathDisplay << "' exists, but " 
     1929                                        "store directory '" << 
     1930                                        storePathDisplay << "' does not."); 
    19151931                                rParams.mDifferences ++; 
    19161932                        } 
     
    19451961        if(args.size() != 2) 
    19461962        { 
    1947                 printf("Incorrect usage.\nrestore [-d] [-r] [-i] <directory-name> <local-directory-name>\n"); 
     1963                BOX_ERROR("Incorrect usage. restore [-d] [-r] [-i] <remote-name> <local-name>"); 
    19481964                return; 
    19491965        } 
     
    19601976                if(dirID == std::numeric_limits<long long>::min() || dirID == std::numeric_limits<long long>::max() || dirID == 0) 
    19611977                { 
    1962                         printf("Not a valid object ID (specified in hex)\n"); 
     1978                        BOX_ERROR("Not a valid object ID (specified in hex)"); 
    19631979                        return; 
    19641980                } 
     
    19831999        if(dirID == 0) 
    19842000        { 
    1985                 printf("Directory '%s' not found on server\n", args[0].c_str()); 
     2001                BOX_ERROR("Directory '" << args[0] << "' not found on server"); 
    19862002                return; 
    19872003        } 
    19882004        if(dirID == BackupProtocolClientListDirectory::RootDirectory) 
    19892005        { 
    1990                 printf("Cannot restore the root directory -- restore locations individually.\n"); 
     2006                BOX_ERROR("Cannot restore the root directory -- restore locations individually."); 
    19912007                return; 
    19922008        } 
     
    20242040        { 
    20252041        case Restore_Complete: 
    2026                 printf("Restore complete\n"); 
     2042                BOX_INFO("Restore complete."); 
    20272043                break; 
    20282044         
    20292045        case Restore_ResumePossible: 
    2030                 printf("Resume possible -- repeat command with -r flag to resume\n"); 
     2046                BOX_ERROR("Resume possible -- repeat command with -r flag to resume"); 
    20312047                break; 
    20322048         
    20332049        case Restore_TargetExists: 
    2034                 printf("The target directory exists. You cannot restore over an existing directory.\n"); 
     2050                BOX_ERROR("The target directory exists. You cannot restore over an existing directory."); 
    20352051                break; 
    20362052                 
    20372053        #ifdef WIN32 
    20382054        case Restore_TargetPathNotFound: 
    2039                 printf("The target directory path does not exist.\n" 
     2055                BOX_ERROR("The target directory path does not exist.\n" 
    20402056                        "To restore to a directory whose parent " 
    2041                         "does not exist, create the parent first.\n"); 
     2057                        "does not exist, create the parent first."); 
    20422058                break; 
    20432059        #endif 
    20442060 
    20452061        case Restore_UnknownError: 
    2046                 printf("Unknown error during restore.\n"); 
     2062                BOX_ERROR("Unknown error during restore."); 
    20472063                break; 
    20482064 
    20492065        default: 
    2050                 printf("ERROR: Unknown restore result %d.\n", result); 
     2066                BOX_ERROR("Unknown restore result " << result << "."); 
    20512067                break; 
    20522068        } 
     
    21682184        if(args.size() != 1) 
    21692185        { 
    2170                 printf("Incorrect usage.\nundelete <directory-name>\n"); 
     2186                BOX_ERROR("Incorrect usage. undelete <directory-name>"); 
    21712187                return; 
    21722188        } 
     
    21862202        if(dirID == 0) 
    21872203        { 
    2188                 printf("Directory '%s' not found on server\n", args[0].c_str()); 
     2204                BOX_ERROR("Directory '" << args[0] << "' not found on server."); 
    21892205                return; 
    21902206        } 
    21912207        if(dirID == BackupProtocolClientListDirectory::RootDirectory) 
    21922208        { 
    2193                 printf("Cannot undelete the root directory.\n"); 
     2209                BOX_ERROR("Cannot undelete the root directory."); 
    21942210                return; 
    21952211        } 
  • box/chris/general/bin/bbackupquery/bbackupquery.cpp

    r1690 r1790  
    1313        #include <unistd.h> 
    1414#endif 
     15 
     16#include <errno.h> 
    1517#include <stdio.h> 
    16 #include <sys/types.h> 
     18 
     19#ifdef HAVE_SYS_TYPES_H 
     20        #include <sys/types.h> 
     21#endif 
     22 
    1723#ifdef HAVE_LIBREADLINE 
    1824        #ifdef HAVE_READLINE_READLINE_H 
     
    169175                        if(logFile == 0) 
    170176                        { 
    171                                 printf("Can't open log file '%s'\n", optarg); 
     177                                BOX_ERROR("Failed to open log file '" << 
     178                                        optarg << "': " << strerror(errno)); 
    172179                        } 
    173180                        break; 
     
    202209                if (!SetConsoleCP(CP_UTF8)) 
    203210                { 
    204                         fprintf(stderr, "Failed to set input codepage: " 
    205                                 "error %d\n", GetLastError()); 
     211                        BOX_ERROR("Failed to set input codepage: " << 
     212                                GetErrorMessage(GetLastError())); 
    206213                } 
    207214 
    208215                if (!SetConsoleOutputCP(CP_UTF8)) 
    209216                { 
    210                         fprintf(stderr, "Failed to set output codepage: " 
    211                                 "error %d\n", GetLastError()); 
     217                        BOX_ERROR("Failed to set output codepage: " << 
     218                                GetErrorMessage(GetLastError())); 
    212219                } 
    213220 
     
    223230 
    224231        // Read in the configuration file 
    225         if(!quiet) printf("Using configuration file %s\n",  
    226                 configFilename.c_str()); 
     232        if(!quiet) BOX_INFO("Using configuration file " << configFilename); 
    227233 
    228234        std::string errs; 
     
    233239        if(config.get() == 0 || !errs.empty()) 
    234240        { 
    235                 printf("Invalid configuration file:\n%s", errs.c_str()); 
     241                BOX_FATAL("Invalid configuration file: " << errs); 
    236242                return 1; 
    237243        } 
     
    253259 
    254260        // 2. Connect to server 
    255         if(!quiet) printf("Connecting to store...\n"); 
     261        if(!quiet) BOX_INFO("Connecting to store..."); 
    256262        SocketStreamTLS socket; 
    257263        socket.Open(tlsContext, Socket::TypeINET, conf.GetKeyValue("StoreHostname").c_str(), BOX_PORT_BBSTORED); 
    258264         
    259265        // 3. Make a protocol, and handshake 
    260         if(!quiet) printf("Handshake with store...\n"); 
     266        if(!quiet) BOX_INFO("Handshake with store..."); 
    261267        BackupProtocolClient connection(socket); 
    262268        connection.Handshake(); 
     
    269275         
    270276        // 4. Log in to server 
    271         if(!quiet) printf("Login to store...\n"); 
     277        if(!quiet) BOX_INFO("Login to store..."); 
    272278        // Check the version of the server 
    273279        { 
     
    346352         
    347353        // Done... stop nicely 
    348         if(!quiet) printf("Logging off...\n"); 
     354        if(!quiet) BOX_INFO("Logging off..."); 
    349355        connection.QueryFinished(); 
    350         if(!quiet) printf("Session finished.\n"); 
     356        if(!quiet) BOX_INFO("Session finished."); 
    351357         
    352358        // Return code 
  • box/chris/general/bin/bbstoreaccounts/bbstoreaccounts.cpp

    r1690 r1790  
    3838        if(SoftLimit >= HardLimit) 
    3939        { 
    40                 printf("ERROR: Soft limit must be less than the hard limit.\n"); 
     40                BOX_FATAL("Soft limit must be less than the hard limit."); 
    4141                exit(1); 
    4242        } 
    4343        if(SoftLimit > ((HardLimit * MAX_SOFT_LIMIT_SIZE) / 100)) 
    4444        { 
    45                 printf("ERROR: Soft limit must be no more than %d%% of the hard limit.\n", MAX_SOFT_LIMIT_SIZE); 
     45                BOX_FATAL("Soft limit must be no more than " <<  
     46                        MAX_SOFT_LIMIT_SIZE << "% of the hard limit."); 
    4647                exit(1); 
    4748        } 
     
    5455        if(DiscSet < 0 || DiscSet >= controller.GetNumDiscSets()) 
    5556        { 
    56                 printf("Disc set %d does not exist\n", DiscSet); 
     57                BOX_FATAL("Disc set " << DiscSet << " does not exist."); 
    5758                exit(1); 
    5859        } 
     
    9091        if(endptr == string || number == LONG_MIN || number == LONG_MAX) 
    9192        { 
    92                 printf("%s is an invalid number\n", string); 
     93                BOX_FATAL("'" << string << "' is not a valid number."); 
    9394                exit(1); 
    9495        } 
     
    117118         
    118119        default: 
    119                 printf("%s has an invalid units specifier\nUse B for blocks, M for Mb, G for Gb, eg 2Gb\n", string); 
     120                BOX_FATAL(string << " has an invalid units specifier " 
     121                        "(use B for blocks, M for Mb, G for Gb, eg 2Gb)"); 
    120122                exit(1); 
    121123                break;           
     
    144146        { 
    145147                // Couldn't lock the account -- just stop now 
    146                 printf("Couldn't lock the account -- did not change the limits\nTry again later.\n"); 
     148                BOX_ERROR("Failed to lock the account, did not change limits. " 
     149                        "Try again later."); 
    147150                return 1; 
    148151        } 
     
    169172        if(!db->EntryExists(ID)) 
    170173        { 
    171                 printf("Account %x does not exist\n", ID); 
     174                BOX_ERROR("Account " << BOX_FORMAT_ACCOUNT(ID) <<  
     175                        " does not exist."); 
    172176                return 1; 
    173177        } 
     
    199203        info->Save(); 
    200204 
    201         printf("Limits on account 0x%08x changed to %lld soft, %lld hard\n", ID, softlimit, hardlimit); 
     205        BOX_NOTICE("Limits on account " << BOX_FORMAT_ACCOUNT(ID) << 
     206                " changed to " << softlimit << " soft, " << 
     207                hardlimit << " hard."); 
    202208 
    203209        return 0; 
     
    212218        if(!db->EntryExists(ID)) 
    213219        { 
    214                 printf("Account %x does not exist\n", ID); 
     220                BOX_ERROR("Account " << BOX_FORMAT_ACCOUNT(ID) <<  
     221                        " does not exist."); 
    215222                return 1; 
    216223        } 
     
    242249        if(AskForConfirmation) 
    243250        { 
    244                 ::printf("Really delete account %08x?\n(type 'yes' to confirm)\n", ID); 
     251                BOX_WARNING("Really delete account " <<  
     252                        BOX_FORMAT_ACCOUNT(ID) << "? (type 'yes' to confirm)"); 
    245253                char response[256]; 
    246254                if(::fgets(response, sizeof(response), stdin) == 0 || ::strcmp(response, "yes\n") != 0) 
    247255                { 
    248                         printf("Deletion cancelled\n"); 
     256                        BOX_NOTICE("Deletion cancelled."); 
    249257                        return 0; 
    250258                } 
     
    257265        if(!db->EntryExists(ID)) 
    258266        { 
    259                 printf("Account %x does not exist\n", ID); 
     267                BOX_ERROR("Account " << BOX_FORMAT_ACCOUNT(ID) <<  
     268                        " does not exist."); 
    260269                return 1; 
    261270        } 
     
    319328                } 
    320329        } 
    321          
     330 
     331        int retcode = 0; 
     332 
    322333        // Thirdly, delete the directories... 
    323334        for(std::vector<std::string>::const_iterator d(toDelete.begin()); d != toDelete.end(); ++d) 
    324335        { 
    325                 ::printf("Deleting store directory %s...\n", (*d).c_str()); 
     336                BOX_NOTICE("Deleting store directory " << (*d) << "..."); 
    326337                // Just use the rm command to delete the files 
    327338                std::string cmd("rm -rf "); 
     
    330341                if(::system(cmd.c_str()) != 0) 
    331342                { 
    332                         ::printf("ERROR: Deletion of %s failed.\n(when cleaning up, remember to delete all raid directories)\n", (*d).c_str()); 
    333                         return 1; 
     343                        BOX_ERROR("Failed to delete files in " << (*d) << 
     344                                ", delete them manually."); 
     345                        retcode = 1; 
    334346                } 
    335347        } 
    336348         
    337349        // Success! 
    338         return 0; 
     350        return retcode; 
    339351} 
    340352 
     
    347359        if(!db->EntryExists(ID)) 
    348360        { 
    349                 printf("Account %x does not exist\n", ID); 
     361                BOX_ERROR("Account " << BOX_FORMAT_ACCOUNT(ID) <<  
     362                        " does not exist."); 
    350363                return 1; 
    351364        } 
     
    382395        if(db->EntryExists(ID)) 
    383396        { 
    384                 printf("Account %x already exists\n", ID); 
     397                BOX_ERROR("Account " << BOX_FORMAT_ACCOUNT(ID) <<  
     398                        " already exists."); 
    385399                return 1; 
    386400        } 
     
    390404        acc.Create(ID, DiscNumber, SoftLimit, HardLimit, rUsername); 
    391405         
    392         printf("Account %x created\n", ID); 
     406        BOX_NOTICE("Account " << BOX_FORMAT_ACCOUNT(ID) << " created."); 
    393407 
    394408        return 0; 
     
    445459        if(config.get() == 0 || !errs.empty()) 
    446460        { 
    447                 printf("Invalid configuration file:\n%s", errs.c_str()); 
     461                BOX_ERROR("Invalid configuration file " << configFilename << 
     462                        ":" << errs); 
    448463        } 
    449464         
     
    485500                        || ::sscanf(argv[2], "%d", &discnum) != 1) 
    486501                { 
    487                         printf("create requires raid file disc number, soft and hard limits\n"); 
     502                        BOX_ERROR("create requires raid file disc number, " 
     503                                "soft and hard limits."); 
    488504                        return 1; 
    489505                } 
     
    507523                if(argc < 4) 
    508524                { 
    509                         printf("setlimit requires soft and hard limits\n"); 
     525                        BOX_ERROR("setlimit requires soft and hard limits."); 
    510526                        return 1; 
    511527                } 
     
    541557                        else 
    542558                        { 
    543                                 ::printf("Unknown option %s.\n", argv[o]); 
     559                                BOX_ERROR("Unknown option " << argv[o] << "."); 
    544560                                return 2; 
    545561                        } 
     
    551567        else 
    552568        { 
    553                 printf("Unknown command '%s'\n", argv[0]); 
     569                BOX_ERROR("Unknown command '" << argv[0] << "'."); 
    554570                return 1; 
    555571        } 
  • box/chris/general/lib/backupclient/BackupClientRestore.cpp

    r1784 r1790  
    261261                        { 
    262262                                // File exists with this name, which is fun. Get rid of it. 
    263                                 ::printf("WARNING: File present with name '%s', removing out of the way of restored directory. Use specific restore with ID to restore this object.", rLocalDirectoryName.c_str()); 
     263                                BOX_WARNING("File present with name '" << 
     264                                        rLocalDirectoryName << "', removing " << 
     265                                        "out of the way of restored directory. " 
     266                                        "Use specific restore with ID to " 
     267                                        "restore this object."); 
    264268                                if(::unlink(rLocalDirectoryName.c_str()) != 0) 
    265269                                { 
  • 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 
  • box/chris/general/lib/backupstore/BackupStoreCheck2.cpp

    r1149 r1790  
    4848        else 
    4949        { 
    50                 ::printf("Root directory doesn't exist\n"); 
     50                BOX_WARNING("Root directory doesn't exist"); 
    5151                 
    5252                ++mNumberErrorsFound; 
     
    119119                        { 
    120120                                // Unattached object... 
    121                                 ::printf("Object %llx is unattached.\n", pblock->mID[e]); 
     121                                BOX_WARNING("Object " << BOX_FORMAT_OBJECTID(pblock->mID[e]) << " is unattached."); 
    122122                                ++mNumberErrorsFound; 
    123123 
     
    148148                                                if(diffFromObjectID != 0) 
    149149                                                { 
    150                                                         ::printf("Object %llx is unattached, and is a patch. Deleting, cannot reliably recover.\n", pblock->mID[e]); 
     150                                                        BOX_WARNING("Object " << BOX_FORMAT_OBJECTID(pblock->mID[e]) << " is unattached, and is a patch. Deleting, cannot reliably recover."); 
    151151                                                 
    152152                                                        // Delete this object instead 
     
    230230        if(!mFixErrors) 
    231231        { 
    232                 ::printf("Missing directory %llx could be recreated\n", MissingDirectoryID); 
     232                BOX_WARNING("Missing directory " <<  
     233                        BOX_FORMAT_OBJECTID(MissingDirectoryID) << 
     234                        " could be recreated."); 
    233235                mDirsAdded.insert(MissingDirectoryID); 
    234236                return true; 
    235237        } 
    236         ::printf("Recreating missing directory %llx\n", MissingDirectoryID); 
     238 
     239        BOX_WARNING("Recreating missing directory " <<  
     240                BOX_FORMAT_OBJECTID(MissingDirectoryID)); 
    237241         
    238242        // Create a blank directory 
     
    301305                { 
    302306                        // Found a name which can be used 
    303                         ::printf("Lost and found dir has name %s\n", name); 
     307                        BOX_WARNING("Lost and found dir has name " << name); 
    304308                        break; 
    305309                } 
     
    525529        catch(...) 
    526530        { 
    527                 ::printf("Load of existing store info failed, regenerating.\n"); 
     531                BOX_WARNING("Load of existing store info failed, regenerating."); 
    528532                ++mNumberErrorsFound; 
    529533        } 
     
    552556        else 
    553557        { 
    554                 ::printf("NOTE: Soft limit for account changed to ensure housekeeping doesn't delete files on next run\n"); 
     558                BOX_WARNING("Soft limit for account changed to ensure housekeeping doesn't delete files on next run."); 
    555559        } 
    556560        if(poldInfo.get() != 0 && poldInfo->GetBlocksHardLimit() > minHard) 
     
    560564        else 
    561565        { 
    562                 ::printf("NOTE: Hard limit for account changed to ensure housekeeping doesn't delete files on next run\n"); 
     566                BOX_WARNING("Hard limit for account changed to ensure housekeeping doesn't delete files on next run."); 
    563567        } 
    564568         
     
    587591        { 
    588592                info->Save(); 
    589                 ::printf("New store info file written successfully.\n"); 
     593                BOX_NOTICE("New store info file written successfully."); 
    590594        } 
    591595} 
  • box/chris/general/lib/common/DebugMemLeakFinder.cpp

    r1341 r1790  
    375375        else 
    376376        { 
    377                 printf("WARNING: Couldn't open memory leak results file %s for appending\n", filename); 
     377                BOX_WARNING("Couldn't open memory leak results file " << 
     378                        filename << " for appending"); 
    378379        } 
    379380} 
  • box/chris/general/lib/common/Logging.cpp

    r1642 r1790  
    244244                msg += "[" + sTag + "] "; 
    245245        } 
     246 
     247        if (level <= Log::FATAL) 
     248        { 
     249                msg += "FATAL: "; 
     250        } 
     251        else if (level <= Log::ERROR) 
     252        { 
     253                msg += "ERROR: "; 
     254        } 
     255        else if (level <= Log::WARNING) 
     256        { 
     257                msg += "WARNING: "; 
     258        } 
     259        else if (level <= Log::NOTICE) 
     260        { 
     261                msg += "NOTICE: "; 
     262        } 
    246263         
    247264        msg += rMessage; 
     
    273290                case Log::EVERYTHING: syslogLevel = LOG_DEBUG;   break; 
    274291        } 
    275                  
    276         syslog(syslogLevel, "%s", rMessage.c_str()); 
     292 
     293        std::string msg; 
     294 
     295        if (level <= Log::FATAL) 
     296        { 
     297                msg = "FATAL: "; 
     298        } 
     299        else if (level <= Log::ERROR) 
     300        { 
     301                msg = "ERROR: "; 
     302        } 
     303        else if (level <= Log::WARNING) 
     304        { 
     305                msg = "WARNING: "; 
     306        } 
     307        else if (level <= Log::NOTICE) 
     308        { 
     309                msg = "NOTICE: "; 
     310        } 
     311 
     312        msg += rMessage; 
     313 
     314        syslog(syslogLevel, "%s", msg.c_str()); 
    277315         
    278316        return true; 
  • box/chris/general/lib/crypto/Random.cpp

    r356 r1790  
    3535        } 
    3636#else 
    37         ::fprintf(stderr, "No random device -- additional seeding of random number generator not performed.\n"); 
     37        BOX_ERROR("No random device -- additional seeding of random number " 
     38                "generator not performed."); 
    3839#endif 
    3940} 
  • box/chris/general/lib/raidfile/RaidFileController.cpp

    r1683 r1790  
    103103        if(pconfig.get() == 0 || !err.empty()) 
    104104        { 
    105                 fprintf(stderr, "RaidFile configuation file errors:\n%s", 
    106                         err.c_str()); 
     105                BOX_ERROR("RaidFile configuration file errors: " << err); 
    107106                THROW_EXCEPTION(RaidFileException, BadConfigFile) 
    108107        } 
  • box/chris/general/lib/server/SSLLib.cpp

    r1784 r1790  
    5050        } 
    5151#else 
    52         ::fprintf(stderr, "No random device -- additional seeding of random number generator not performed.\n"); 
     52        BOX_WARNING("No random device -- additional seeding of " 
     53                "random number generator not performed."); 
    5354#endif 
    5455} 
  • box/chris/general/test/bbackupd/testfiles/extcheck1.pl.in

    r675 r1790  
    44my $flags = $ARGV[0] or ""; 
    55 
    6 unless(open IN,"../../bin/bbackupquery/bbackupquery -q -c testfiles/bbackupd.conf -l testfiles/query4.log \"compare -ac$flags\" quit|") 
     6unless(open IN,"../../bin/bbackupquery/bbackupquery -q -c testfiles/bbackupd.conf -l testfiles/query4.log \"compare -ac$flags\" quit 2>&1 |") 
    77{ 
    88        print "Couldn't open compare utility\n"; 
  • box/chris/general/test/bbackupd/testfiles/extcheck2.pl.in

    r675 r1790  
    44my $flags = $ARGV[0] or ""; 
    55 
    6 unless(open IN,"../../bin/bbackupquery/bbackupquery -q -c testfiles/bbackupd.conf -l testfiles/query4.log \"compare -ac$flags\" quit|") 
     6unless(open IN,"../../bin/bbackupquery/bbackupquery -q -c testfiles/bbackupd.conf -l testfiles/query4.log \"compare -ac$flags\" quit 2>&1 |") 
    77{ 
    88        print "Couldn't open compare utility\n"; 
Note: See TracChangeset for help on using the changeset viewer.