Changeset 1784


Ignore:
Timestamp:
01/08/2007 00:18:50 (5 years ago)
Author:
chris
Message:

Replace almost all calls to syslog() with logging framework. (merges [1783])

Location:
box/chris/general
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • box/chris/general/bin/bbackupctl/bbackupctl.cpp

    r1690 r1784  
    163163 
    164164#if defined WIN32 && ! defined NDEBUG 
    165                 syslog(LOG_ERR,"Failed to connect to the command socket"); 
     165                BOX_ERROR("Failed to connect to the command socket"); 
    166166#endif 
    167167 
     
    176176        if(!getLine.GetLine(configSummary)) 
    177177        { 
    178 #if defined WIN32 && ! defined NDEBUG 
    179                 syslog(LOG_ERR, "Failed to receive configuration summary " 
     178                BOX_ERROR("Failed to receive configuration summary " 
    180179                        "from daemon"); 
    181 #else 
    182                 printf("Failed to receive configuration summary from daemon\n"); 
    183 #endif 
    184  
    185180                return 1; 
    186181        } 
     
    189184        if(getLine.IsEOF()) 
    190185        { 
    191 #if defined WIN32 && ! defined NDEBUG 
    192                 syslog(LOG_ERR, "Server rejected the connection. " 
    193                         "Are you running bbackupctl as the same user " 
    194                         "as the daemon?"); 
    195 #else 
    196                 printf("Server rejected the connection. " 
    197                         "Are you running bbackupctl as the same user " 
    198                         "as the daemon?\n"); 
    199 #endif 
    200  
     186                BOX_ERROR("Server rejected the connection. Are you running " 
     187                        "bbackupctl as the same user as the daemon?"); 
    201188                return 1; 
    202189        } 
     
    225212        if(!getLine.GetLine(stateLine) || getLine.IsEOF()) 
    226213        { 
    227 #if defined WIN32 && ! defined NDEBUG 
    228                 syslog(LOG_ERR, "Failed to receive state line from daemon"); 
    229 #else 
    230                 printf("Failed to receive state line from daemon\n"); 
    231 #endif 
     214                BOX_ERROR("Failed to receive state line from daemon"); 
    232215                return 1; 
    233216        } 
     
    237220        if(::sscanf(stateLine.c_str(), "state %d", &currentState) != 1) 
    238221        { 
    239                 printf("State line didn't decode\n"); 
     222                BOX_ERROR("Received invalid state line from daemon"); 
    240223                return 1; 
    241224        } 
     
    267250                        if(!autoBackup) 
    268251                        { 
    269                                 printf("ERROR: Daemon is not in automatic mode -- " 
    270                                         "sync will never start!\n"); 
     252                                BOX_ERROR("Daemon is not in automatic mode, " 
     253                                        "sync will never start!"); 
    271254                                return 1; 
    272255                        } 
  • box/chris/general/bin/bbackupd/BackupClientContext.cpp

    r1659 r1784  
    1010#include "Box.h" 
    1111 
    12 #ifdef HAVE_SYSLOG_H 
    13         #include <syslog.h> 
    14 #endif 
    1512#ifdef HAVE_SIGNAL_H 
    1613        #include <signal.h> 
    1714#endif 
     15 
    1816#ifdef HAVE_SYS_TIME_H 
    1917        #include <sys/time.h> 
     
    128126                 
    129127                // Log intention 
    130                 ::syslog(LOG_INFO, "Opening connection to server %s...", mHostname.c_str()); 
     128                BOX_INFO("Opening connection to server '" << 
     129                        mHostname << "'..."); 
    131130 
    132131                // Connect! 
     
    148147                        if (!mpExtendedLogFileHandle) 
    149148                        { 
    150                                 ::syslog(LOG_ERR, "Failed to open extended " 
    151                                         "log file: %s", strerror(errno)); 
     149                                BOX_ERROR("Failed to open extended log " 
     150                                        "file: " << strerror(errno)); 
    152151                        } 
    153152                        else 
     
    195194                 
    196195                // Log success 
    197                 ::syslog(LOG_INFO, "Connection made, login successful"); 
     196                BOX_INFO("Connection made, login successful"); 
    198197 
    199198                // Check to see if there is any space available on the server 
     
    203202                        mStorageLimitExceeded = true; 
    204203                        // Log 
    205                         ::syslog(LOG_WARNING, "Exceeded storage hard-limit on server -- not uploading changes to files"); 
     204                        BOX_WARNING("Exceeded storage hard-limit on server, " 
     205                                "not uploading changes to files"); 
    206206                } 
    207207        } 
  • box/chris/general/bin/bbackupd/Win32ServiceFunctions.cpp

    r1033 r1784  
    4545        memset(buf, 0, sizeof(buf)); 
    4646        _snprintf(buf, sizeof(buf)-1, "%s (%d)", s, err); 
    47         ::syslog(LOG_ERR, "%s", buf); 
     47        BOX_ERROR(buf); 
    4848        MessageBox(0, buf, "Error",  
    4949                MB_OK | MB_SETFOREGROUND | MB_DEFAULT_DESKTOP_ONLY); 
     
    192192                if (emu_stat(pConfigFileName, &st) != 0) 
    193193                { 
    194                         syslog(LOG_ERR, "Failed to open configuration file: " 
    195                                 "%s: %s", pConfigFileName, strerror(errno)); 
     194                        BOX_ERROR("Failed to open configuration file '" << 
     195                                pConfigFileName << "': " << strerror(errno)); 
    196196                        return 1; 
    197197                } 
     
    200200                { 
    201201         
    202                         syslog(LOG_ERR, "Failed to open configuration file: " 
    203                                 "%s: not a file", pConfigFileName); 
     202                        BOX_ERROR("Failed to open configuration file '" << 
     203                                pConfigFileName << "': not a file"); 
    204204                        return 1; 
    205205                } 
     
    210210        if (!scm)  
    211211        { 
    212                 syslog(LOG_ERR, "Failed to open service control manager: " 
    213                         "error %d", GetLastError()); 
     212                BOX_ERROR("Failed to open service control manager: " << 
     213                        GetErrorMessage(GetLastError())); 
    214214                return 1; 
    215215        } 
     
    249249                        case ERROR_SERVICE_EXISTS: 
    250250                        { 
    251                                 ::syslog(LOG_ERR, "Failed to create Box Backup " 
     251                                BOX_ERROR("Failed to create Box Backup " 
    252252                                        "service: it already exists"); 
    253253                        } 
     
    256256                        case ERROR_SERVICE_MARKED_FOR_DELETE: 
    257257                        { 
    258                                 ::syslog(LOG_ERR, "Failed to create Box Backup " 
     258                                BOX_ERROR("Failed to create Box Backup " 
    259259                                        "service: it is waiting to be deleted"); 
    260260                        } 
     
    263263                        case ERROR_DUPLICATE_SERVICE_NAME: 
    264264                        { 
    265                                 ::syslog(LOG_ERR, "Failed to create Box Backup " 
     265                                BOX_ERROR("Failed to create Box Backup " 
    266266                                        "service: a service with this name " 
    267267                                        "already exists"); 
     
    271271                        default: 
    272272                        { 
    273                                 ::syslog(LOG_ERR, "Failed to create Box Backup " 
    274                                         "service: error %d", err); 
     273                                BOX_ERROR("Failed to create Box Backup " 
     274                                        "service: error " << 
     275                                        GetErrorMessage(GetLastError())); 
    275276                        } 
    276277                } 
     
    279280        } 
    280281 
    281         ::syslog(LOG_INFO, "Created Box Backup service"); 
     282        BOX_INFO("Created Box Backup service"); 
    282283         
    283284        SERVICE_DESCRIPTION desc; 
     
    287288                &desc)) 
    288289        { 
    289                 ::syslog(LOG_WARNING, "Failed to set description for " 
    290                         "Box Backup service: error %d", GetLastError()); 
     290                BOX_WARNING("Failed to set description for Box Backup " 
     291                        "service: " << GetErrorMessage(GetLastError())); 
    291292        } 
    292293 
     
    302303        if (!scm)  
    303304        { 
    304                 syslog(LOG_ERR, "Failed to open service control manager: " 
    305                         "error %d", GetLastError()); 
     305                BOX_ERROR("Failed to open service control manager: " << 
     306                        GetErrorMessage(GetLastError())); 
    306307                return 1; 
    307308        } 
     
    318319                        // hello microsoft? anyone home? 
    319320                { 
    320                         syslog(LOG_ERR, "Failed to open Box Backup service: " 
     321                        BOX_ERROR("Failed to open Box Backup service: " 
    321322                                "not installed or not found"); 
    322323                } 
    323324                else 
    324325                { 
    325                         syslog(LOG_ERR, "Failed to open Box Backup service: " 
    326                                 "error %d", err); 
     326                        BOX_ERROR("Failed to open Box Backup service: " << 
     327                                GetErrorMessage(err)); 
    327328                } 
    328329                return 1; 
     
    335336                if (err != ERROR_SERVICE_NOT_ACTIVE) 
    336337                { 
    337                         syslog(LOG_WARNING, "Failed to stop Box Backup " 
    338                                 "service: error %d", err); 
     338                        BOX_WARNING("Failed to stop Box Backup service: " << 
     339                                GetErrorMessage(err)); 
    339340                } 
    340341        } 
     
    346347        if (deleted) 
    347348        { 
    348                 syslog(LOG_INFO, "Box Backup service deleted"); 
     349                BOX_INFO("Box Backup service deleted"); 
    349350                return 0; 
    350351        } 
    351352        else if (err == ERROR_SERVICE_MARKED_FOR_DELETE) 
    352353        { 
    353                 syslog(LOG_ERR, "Failed to remove Box Backup service: " 
     354                BOX_ERROR("Failed to remove Box Backup service: " 
    354355                        "it is already being deleted"); 
    355356        } 
    356357        else 
    357358        { 
    358                 syslog(LOG_ERR, "Failed to remove Box Backup service: " 
    359                         "error %d", err); 
     359                BOX_ERROR("Failed to remove Box Backup service: " << 
     360                        GetErrorMessage(err)); 
    360361        } 
    361362 
  • box/chris/general/bin/bbackupquery/BackupQueries.cpp

    r1639 r1784  
    20102010                        opts['r'] /* resume? */); 
    20112011        } 
    2012         catch (BoxException &e) 
    2013         { 
    2014                 ::syslog(LOG_ERR, "Failed to restore: %s", e.what()); 
    2015                 return; 
    2016         } 
    20172012        catch(std::exception &e) 
    20182013        { 
    2019                 ::syslog(LOG_ERR, "Failed to restore: %s", e.what()); 
     2014                BOX_ERROR("Failed to restore: " << e.what()); 
    20202015                return; 
    20212016        } 
    20222017        catch(...) 
    20232018        { 
    2024                 ::syslog(LOG_ERR, "Failed to restore: unknown error"); 
     2019                BOX_ERROR("Failed to restore: unknown exception"); 
    20252020                return; 
    20262021        } 
  • box/chris/general/bin/bbstored/BBStoreDHousekeeping.cpp

    r1382 r1784  
    1111 
    1212#include <stdio.h> 
    13  
    14 #ifdef HAVE_SYSLOG_H 
    15         #include <syslog.h> 
    16 #endif 
    1713 
    1814#include "BackupStoreDaemon.h" 
     
    8379        // Store the time 
    8480        mLastHousekeepingRun = timeNow; 
    85         ::syslog(LOG_INFO, "Starting housekeeping"); 
     81        BOX_INFO("Starting housekeeping"); 
    8682 
    8783        // Get the list of accounts 
     
    113109                catch(BoxException &e) 
    114110                { 
    115                         ::syslog(LOG_ERR, "while housekeeping account %08X, exception %s (%d/%d) -- aborting housekeeping run for this account", 
    116                                 *i, e.what(), e.GetType(), e.GetSubType()); 
     111                        BOX_ERROR("Housekeeping on account " << 
     112                                BOX_FORMAT_ACCOUNT(*i) << " threw exception, " 
     113                                "aborting run for this account: " << 
     114                                e.what() << " (" << 
     115                                e.GetType() << "/" << e.GetSubType() << ")"); 
    117116                } 
    118117                catch(std::exception &e) 
    119118                { 
    120                         ::syslog(LOG_ERR, "while housekeeping account %08X, exception %s -- aborting housekeeping run for this account", 
    121                                 *i, e.what()); 
     119                        BOX_ERROR("Housekeeping on account " << 
     120                                BOX_FORMAT_ACCOUNT(*i) << " threw exception, " 
     121                                "aborting run for this account: " << 
     122                                e.what()); 
    122123                } 
    123124                catch(...) 
    124125                { 
    125                         ::syslog(LOG_ERR, "while housekeeping account %08X, unknown exception -- aborting housekeeping run for this account", 
    126                                 *i); 
     126                        BOX_ERROR("Housekeeping on account " << 
     127                                BOX_FORMAT_ACCOUNT(*i) << " threw exception, " 
     128                                "aborting run for this account: " 
     129                                "unknown exception"); 
    127130                } 
    128131         
     
    145148        } 
    146149                 
    147         ::syslog(LOG_INFO, "Finished housekeeping"); 
     150        BOX_INFO("Finished housekeeping"); 
    148151 
    149152        // Placed here for accuracy, if StopRun() is true, for example. 
     
    191194        if(mInterProcessComms.GetLine(line, false /* no pre-processing */, MaximumWaitTime)) 
    192195        { 
    193                 TRACE1("housekeeping received command '%s' over interprocess comms\n", line.c_str()); 
     196                TRACE1("Housekeeping received command '%s' over interprocess comms\n", line.c_str()); 
    194197         
    195198                int account = 0; 
     
    213216                        { 
    214217                                // Yes! -- need to stop now so when it retries to get the lock, it will succeed 
    215                                 ::syslog(LOG_INFO, "Housekeeping giving way to connection for account 0x%08x", AccountNum); 
     218                                BOX_INFO("Housekeeping on account " << 
     219                                        BOX_FORMAT_ACCOUNT(AccountNum) << 
     220                                        "giving way to client connection"); 
    216221                                return true; 
    217222                        } 
  • box/chris/general/bin/bbstored/BackupCommands.cpp

    r1333 r1784  
    99 
    1010#include "Box.h" 
    11  
    12 #ifdef HAVE_SYSLOG_H 
    13 #include <syslog.h> 
    14 #endif 
    1511 
    1612#include <set> 
     
    8985        // Check given client ID against the ID in the certificate certificate 
    9086        // and that the client actually has an account on this machine 
    91         if(mClientID != rContext.GetClientID() || !rContext.GetClientHasAccount()) 
    92         { 
    93                 ::syslog(LOG_INFO, "Failed login: Client ID presented was %08X", mClientID); 
    94                 return std::auto_ptr<ProtocolObject>(new BackupProtocolServerError( 
    95                         BackupProtocolServerError::ErrorType, BackupProtocolServerError::Err_BadLogin)); 
     87        if(mClientID != rContext.GetClientID()) 
     88        { 
     89                BOX_WARNING("Failed login from client ID " <<  
     90                        BOX_FORMAT_ACCOUNT(mClientID) << 
     91                        ": wrong certificate for this account"); 
     92                return std::auto_ptr<ProtocolObject>( 
     93                        new BackupProtocolServerError( 
     94                                BackupProtocolServerError::ErrorType, 
     95                                BackupProtocolServerError::Err_BadLogin)); 
     96        } 
     97 
     98        if(!rContext.GetClientHasAccount()) 
     99        { 
     100                BOX_WARNING("Failed login from client ID " <<  
     101                        BOX_FORMAT_ACCOUNT(mClientID) << 
     102                        ": no such account on this server"); 
     103                return std::auto_ptr<ProtocolObject>( 
     104                        new BackupProtocolServerError( 
     105                                BackupProtocolServerError::ErrorType, 
     106                                BackupProtocolServerError::Err_BadLogin)); 
    96107        } 
    97108 
     
    102113                if(!rContext.AttemptToGetWriteLock()) 
    103114                { 
    104                         ::syslog(LOG_INFO, "Failed to get write lock (for Client ID %08X)", mClientID); 
    105                         return std::auto_ptr<ProtocolObject>(new BackupProtocolServerError( 
    106                                 BackupProtocolServerError::ErrorType, BackupProtocolServerError::Err_CannotLockStoreForWriting));                        
     115                        BOX_WARNING("Failed to get write lock for Client ID " << 
     116                                BOX_FORMAT_ACCOUNT(mClientID)); 
     117                        return std::auto_ptr<ProtocolObject>( 
     118                                new BackupProtocolServerError( 
     119                                        BackupProtocolServerError::ErrorType, 
     120                                        BackupProtocolServerError::Err_CannotLockStoreForWriting));                      
    107121                } 
    108122                 
     
    121135         
    122136        // Log login 
    123         ::syslog(LOG_INFO, "Login: Client ID %08X, %s", mClientID, ((mFlags & Flags_ReadOnly) != Flags_ReadOnly)?"Read/Write":"Read-only"); 
     137        BOX_NOTICE("Login from Client ID " <<  
     138                BOX_FORMAT_ACCOUNT(mClientID) << 
     139                " " << 
     140                (((mFlags & Flags_ReadOnly) != Flags_ReadOnly) 
     141                ?"Read/Write":"Read-only")); 
    124142 
    125143        // Get the usage info for reporting to the client 
     
    141159std::auto_ptr<ProtocolObject> BackupProtocolServerFinished::DoCommand(BackupProtocolServer &rProtocol, BackupContext &rContext) 
    142160{ 
    143         ::syslog(LOG_INFO, "Session finished"); 
     161        BOX_NOTICE("Session finished for Client ID " <<  
     162                BOX_FORMAT_ACCOUNT(rContext.GetClientID())); 
    144163 
    145164        // Let the context know about it 
     
    312331                        if(en == 0) 
    313332                        { 
    314                                 ::syslog(LOG_ERR, "Object %llx in dir %llx for account %x references object %llx which does not exist in dir", 
    315                                         mObjectID, mInDirectory, rContext.GetClientID(), id); 
    316                                 return std::auto_ptr<ProtocolObject>(new BackupProtocolServerError( 
    317                                         BackupProtocolServerError::ErrorType, BackupProtocolServerError::Err_PatchConsistencyError));                    
     333                                BOX_ERROR("Object " <<  
     334                                        BOX_FORMAT_OBJECTID(mObjectID) << 
     335                                        " in dir " <<  
     336                                        BOX_FORMAT_OBJECTID(mInDirectory) << 
     337                                        " for account " << 
     338                                        BOX_FORMAT_ACCOUNT(rContext.GetClientID()) << 
     339                                        " references object " <<  
     340                                        BOX_FORMAT_OBJECTID(id) << 
     341                                        " which does not exist in dir"); 
     342                                return std::auto_ptr<ProtocolObject>( 
     343                                        new BackupProtocolServerError( 
     344                                                BackupProtocolServerError::ErrorType, 
     345                                                BackupProtocolServerError::Err_PatchConsistencyError));                  
    318346                        } 
    319347                        id = en->GetDependsNewer(); 
    320                 } while(en != 0 && id != 0); 
     348                } 
     349                while(en != 0 && id != 0); 
    321350                 
    322351                // OK! The last entry in the chain is the full file, the others are patches back from it. 
  • box/chris/general/bin/bbstored/BackupStoreDaemon.cpp

    r1691 r1784  
    209209                                ::openlog("bbstored/hk", LOG_PID, LOG_LOCAL6); 
    210210                                // Log that housekeeping started 
    211                                 ::syslog(LOG_INFO, "Housekeeping process started"); 
     211                                BOX_INFO("Housekeeping process started"); 
    212212                                // Ignore term and hup 
    213213                                // Parent will handle these and alert the child via the socket, don't want to randomly die 
     
    282282        catch(BoxException &e) 
    283283        { 
    284                 ::syslog(LOG_ERR, "%s: disconnecting due to " 
    285                         "exception %s (%d/%d)", DaemonName(),  
    286                         e.what(), e.GetType(), e.GetSubType()); 
     284                BOX_ERROR("Error in child process, terminating connection: " << 
     285                        e.what() << " (" << e.GetType() << "/" <<  
     286                        e.GetSubType() << ")"); 
    287287        } 
    288288        catch(std::exception &e) 
    289289        { 
    290                 ::syslog(LOG_ERR, "%s: disconnecting due to " 
    291                         "exception %s", DaemonName(), e.what()); 
     290                BOX_ERROR("Error in child process, terminating connection: " << 
     291                        e.what()); 
    292292        } 
    293293        catch(...) 
    294294        { 
    295                 ::syslog(LOG_ERR, "%s: disconnecting due to " 
    296                         "unknown exception", DaemonName()); 
     295                BOX_ERROR("Error in child process, terminating connection: " << 
     296                        "unknown exception"); 
    297297        } 
    298298} 
     
    312312         
    313313        // Log the name 
    314         ::syslog(LOG_INFO, "Certificate CN: %s", clientCommonName.c_str()); 
     314        BOX_INFO("Client certificate CN: " << clientCommonName); 
    315315         
    316316        // Check it 
     
    358358{ 
    359359        // Log the amount of data transferred 
    360         ::syslog(LOG_INFO, "Connection statistics for %s: " 
    361                         "IN=%lld OUT=%lld TOTAL=%lld", commonName, 
    362                         (long long)s.GetBytesRead(),  
    363                         (long long)s.GetBytesWritten(), 
    364                         (long long)s.GetBytesRead() +  
    365                         (long long)s.GetBytesWritten()); 
    366 } 
     360        BOX_INFO("Connection statistics for " << commonName << ":" 
     361                " IN="  << s.GetBytesRead() << 
     362                " OUT=" << s.GetBytesWritten() << 
     363                " TOTAL=" << (s.GetBytesRead() + s.GetBytesWritten())); 
     364} 
  • box/chris/general/bin/bbstored/HousekeepStoreAccount.cpp

    r1321 r1784  
    1010#include "Box.h" 
    1111 
     12#include <stdio.h> 
     13 
    1214#include <map> 
    13 #include <stdio.h> 
    1415 
    1516#include "HousekeepStoreAccount.h" 
     
    138139                { 
    139140                        // Log this 
    140                         ::syslog(LOG_ERR, "On housekeeping, sizes in store do not match calculated sizes, correcting"); 
    141                         ::syslog(LOG_ERR, "different (store,calc): acc 0x%08x, used (%lld,%lld), old (%lld,%lld), deleted (%lld,%lld), dirs (%lld,%lld)", 
    142                                 mAccountID, 
    143                                 (used + mBlocksUsedDelta), mBlocksUsed, (usedOld + mBlocksInOldFilesDelta), mBlocksInOldFiles, 
    144                                 (usedDeleted + mBlocksInDeletedFilesDelta), mBlocksInDeletedFiles, usedDirectories, mBlocksInDirectories); 
     141                        BOX_ERROR("Housekeeping on account " <<  
     142                                BOX_FORMAT_ACCOUNT(mAccountID) << " found " 
     143                                "and fixed wrong block counts: " 
     144                                "used (" << 
     145                                (used + mBlocksUsedDelta) << "," << 
     146                                mBlocksUsed << "), old (" << 
     147                                (usedOld + mBlocksInOldFilesDelta) << "," << 
     148                                mBlocksInOldFiles << "), deleted (" << 
     149                                (usedDeleted + mBlocksInDeletedFilesDelta) << 
     150                                "," << mBlocksInDeletedFiles << "), dirs (" << 
     151                                usedDirectories << "," << mBlocksInDirectories 
     152                                << ")"); 
    145153                } 
    146154                 
     
    174182        if(mFilesDeleted > 0 || mEmptyDirectoriesDeleted > 0) 
    175183        { 
    176                 ::syslog(LOG_INFO, "Account 0x%08x, removed %lld blocks (%lld files, %lld dirs)%s", mAccountID, 0 - (mBlocksUsedDelta + removeASAPBlocksUsedDelta), 
    177                         mFilesDeleted, mEmptyDirectoriesDeleted, 
    178                         deleteInterrupted?" was interrupted":""); 
     184                BOX_INFO("Housekeeping on account " <<  
     185                        BOX_FORMAT_ACCOUNT(mAccountID) << " " 
     186                        "removed " << 
     187                        (0 - (mBlocksUsedDelta + removeASAPBlocksUsedDelta)) << 
     188                        " blocks (" << mFilesDeleted << " files, " << 
     189                        mEmptyDirectoriesDeleted << " dirs)" << 
     190                        (deleteInterrupted?" and was interrupted":"")); 
    179191        } 
    180192         
    181193        // Make sure the delta's won't cause problems if the counts are really wrong, and 
    182194        // it wasn't fixed because the store was updated during the scan. 
    183         if(mBlocksUsedDelta                     < (0 - info->GetBlocksUsed()))                          mBlocksUsedDelta =                      (0 - info->GetBlocksUsed()); 
    184         if(mBlocksInOldFilesDelta               < (0 - info->GetBlocksInOldFiles()))            mBlocksInOldFilesDelta =        (0 - info->GetBlocksInOldFiles()); 
    185         if(mBlocksInDeletedFilesDelta   < (0 - info->GetBlocksInDeletedFiles()))        mBlocksInDeletedFilesDelta =(0 - info->GetBlocksInDeletedFiles()); 
    186         if(mBlocksInDirectoriesDelta    < (0 - info->GetBlocksInDirectories()))         mBlocksInDirectoriesDelta = (0 - info->GetBlocksInDirectories()); 
     195        if(mBlocksUsedDelta < (0 - info->GetBlocksUsed())) 
     196        { 
     197                mBlocksUsedDelta = (0 - info->GetBlocksUsed()); 
     198        } 
     199        if(mBlocksInOldFilesDelta < (0 - info->GetBlocksInOldFiles())) 
     200        { 
     201                mBlocksInOldFilesDelta = (0 - info->GetBlocksInOldFiles()); 
     202        } 
     203        if(mBlocksInDeletedFilesDelta < (0 - info->GetBlocksInDeletedFiles())) 
     204        { 
     205                mBlocksInDeletedFilesDelta = (0 - info->GetBlocksInDeletedFiles()); 
     206        } 
     207        if(mBlocksInDirectoriesDelta < (0 - info->GetBlocksInDirectories())) 
     208        { 
     209                mBlocksInDirectoriesDelta = (0 - info->GetBlocksInDirectories()); 
     210        } 
    187211         
    188212        // Update the usage counts in the store 
     
    555579                if(pentry == 0) 
    556580                { 
    557                         ::syslog(LOG_ERR, "acc 0x%08x, object %lld not found in dir %lld, logic error/corruption? Run bbstoreaccounts check <accid> fix", mAccountID, ObjectID, InDirectory); 
     581                        BOX_ERROR("Housekeeping on account " << 
     582                                BOX_FORMAT_ACCOUNT(mAccountID) << " " 
     583                                "found error: object " << 
     584                                BOX_FORMAT_OBJECTID(ObjectID) << " " 
     585                                "not found in dir " <<  
     586                                BOX_FORMAT_OBJECTID(InDirectory) << ", " 
     587                                "indicates logic error/corruption? Run " 
     588                                "bbstoreaccounts check <accid> fix"); 
    558589                        return; 
    559590                } 
  • box/chris/general/lib/backupclient/BackupClientFileAttributes.cpp

    r1635 r1784  
    345345                if (winTime >= 0x100000000LL || _gmtime64(&winTime) == 0) 
    346346                { 
    347                         ::syslog(LOG_ERR, "Invalid Modification Time " 
    348                                 "caught for file: %s", Filename); 
     347                        BOX_ERROR("Invalid Modification Time caught for " 
     348                                "file: '" << Filename << "'"); 
    349349                        pattr->ModificationTime = 0; 
    350350                } 
     
    356356                if (winTime > 0x100000000LL || _gmtime64(&winTime) == 0) 
    357357                { 
    358                         ::syslog(LOG_ERR, "Invalid Attribute Modification " 
    359                                 "Time caught for file: %s", Filename); 
     358                        BOX_ERROR("Invalid Attribute Modification Time "  
     359                                "caught for file: '" << Filename << "'"); 
    360360                        pattr->AttrModificationTime = 0; 
    361361                } 
     
    628628         
    629629#ifdef WIN32 
    630                 ::syslog(LOG_WARNING,  
    631                         "Cannot create symbolic links on Windows: %s",  
    632                         Filename); 
     630                BOX_WARNING("Cannot create symbolic links on Windows: '" << 
     631                        Filename << "'"); 
    633632#else 
    634633                // Make a symlink, first deleting anything in the way 
  • box/chris/general/lib/backupclient/BackupClientRestore.cpp

    r1661 r1784  
    236236        catch (BoxException &e) 
    237237        { 
    238                 ::syslog(LOG_ERR, "Failed to check existence for %s: %s",  
    239                         rLocalDirectoryName.c_str(), e.what()); 
     238                BOX_ERROR("Failed to check existence for " << 
     239                        rLocalDirectoryName << ": " << e.what()); 
    240240                return Restore_UnknownError; 
    241241        } 
    242242        catch(std::exception &e) 
    243243        { 
    244                 ::syslog(LOG_ERR, "Failed to check existence for %s: %s",  
    245                         rLocalDirectoryName.c_str(), e.what()); 
     244                BOX_ERROR("Failed to check existence for " << 
     245                        rLocalDirectoryName << ": " << e.what()); 
    246246                return Restore_UnknownError; 
    247247        } 
    248248        catch(...) 
    249249        { 
    250                 ::syslog(LOG_ERR, "Failed to check existence for %s: " 
    251                         "unknown error", rLocalDirectoryName.c_str()); 
     250                BOX_ERROR("Failed to check existence for " << 
     251                        rLocalDirectoryName << ": unknown error"); 
    252252                return Restore_UnknownError; 
    253253        } 
     
    264264                                if(::unlink(rLocalDirectoryName.c_str()) != 0) 
    265265                                { 
    266                                         ::syslog(LOG_ERR, "Failed to delete " 
    267                                                 "file %s: %s", 
    268                                                 rLocalDirectoryName.c_str(), 
     266                                        BOX_ERROR("Failed to delete file " << 
     267                                                rLocalDirectoryName << ": " << 
    269268                                                strerror(errno)); 
    270269                                        return Restore_UnknownError; 
    271270                                } 
    272                                 TRACE1("In restore, directory name collision with file %s", rLocalDirectoryName.c_str()); 
     271                                BOX_TRACE("In restore, directory name "  
     272                                        "collision with file " << 
     273                                        rLocalDirectoryName); 
    273274                        } 
    274275                        break; 
     
    326327                catch (BoxException &e) 
    327328                { 
    328                         ::syslog(LOG_ERR, "Failed to check existence for %s: " 
    329                                 "%s", parentDirectoryName.c_str(), e.what()); 
     329                        BOX_ERROR("Failed to check existence for " << 
     330                                parentDirectoryName << ": " << e.what()); 
    330331                        return Restore_UnknownError; 
    331332                } 
    332333                catch(std::exception &e) 
    333334                { 
    334                         ::syslog(LOG_ERR, "Failed to check existence for %s: " 
    335                                 "%s", parentDirectoryName.c_str(), e.what()); 
     335                        BOX_ERROR("Failed to check existence for " << 
     336                                parentDirectoryName << ": " << e.what()); 
    336337                        return Restore_UnknownError; 
    337338                } 
    338339                catch(...) 
    339340                { 
    340                         ::syslog(LOG_ERR, "Failed to check existence for %s: " 
    341                                 "unknown error", parentDirectoryName.c_str()); 
     341                        BOX_ERROR("Failed to check existence for " << 
     342                                parentDirectoryName << ": unknown error"); 
    342343                        return Restore_UnknownError; 
    343344                } 
     
    350351 
    351352                        case ObjectExists_File: 
    352                                 fprintf(stderr, "Failed to restore: '%s' " 
     353                                BOX_ERROR("Failed to restore: '" << 
     354                                        parentDirectoryName << "' " 
    353355                                        "is a file, but should be a " 
    354                                         "directory.\n",  
    355                                         parentDirectoryName.c_str()); 
     356                                        "directory."); 
    356357                                return Restore_TargetPathNotFound; 
    357358 
    358359                        case ObjectExists_NoObject: 
    359                                 fprintf(stderr, "Failed to restore: " 
    360                                         "parent '%s' of target directory " 
    361                                         "does not exist.\n", 
    362                                         parentDirectoryName.c_str()); 
     360                                BOX_ERROR("Failed to restore: parent '" << 
     361                                        parentDirectoryName << "' of target " 
     362                                        "directory does not exist."); 
    363363                                return Restore_TargetPathNotFound; 
    364364 
    365365                        default: 
    366                                 fprintf(stderr, "Failed to restore: " 
    367                                         "unknown result from " 
    368                                         "ObjectExists('%s').\n", 
    369                                         parentDirectoryName.c_str()); 
     366                                BOX_ERROR("Failed to restore: unknown " 
     367                                        "result from ObjectExists('" << 
     368                                        parentDirectoryName << "')"); 
    370369                                return Restore_UnknownError; 
    371370                } 
     
    376375                ::mkdir(rLocalDirectoryName.c_str(), S_IRWXU) != 0) 
    377376        { 
    378                 ::syslog(LOG_ERR, "Failed to create directory %s: %s", 
    379                         rLocalDirectoryName.c_str(), 
     377                BOX_ERROR("Failed to create directory '" << 
     378                        rLocalDirectoryName << "': " <<  
    380379                        strerror(errno)); 
    381380                return Restore_UnknownError; 
     
    387386                Params.mResumeInfo.Save(Params.mRestoreResumeInfoFilename); 
    388387        } 
    389         catch (BoxException &e) 
    390         { 
    391                 ::syslog(LOG_ERR, "Failed to save resume info file %s: %s",  
    392                         Params.mRestoreResumeInfoFilename.c_str(), e.what()); 
    393                 return Restore_UnknownError; 
    394         } 
    395388        catch(std::exception &e) 
    396389        { 
    397                 ::syslog(LOG_ERR, "Failed to save resume info file %s: %s",  
    398                         Params.mRestoreResumeInfoFilename.c_str(), e.what()); 
     390                BOX_ERROR("Failed to save resume info file '" << 
     391                        Params.mRestoreResumeInfoFilename << "': " << 
     392                        e.what()); 
    399393                return Restore_UnknownError; 
    400394        } 
    401395        catch(...) 
    402396        { 
    403                 ::syslog(LOG_ERR, "Failed to save resume info file %s: " 
    404                         "unknown error",  
    405                         Params.mRestoreResumeInfoFilename.c_str()); 
     397                BOX_ERROR("Failed to save resume info file '" << 
     398                        Params.mRestoreResumeInfoFilename << 
     399                        "': unknown error"); 
    406400                return Restore_UnknownError; 
    407401        } 
     
    428422                dirAttr.WriteAttributes(rLocalDirectoryName.c_str(), true); 
    429423        } 
    430         catch (BoxException &e) 
    431         { 
    432                 ::syslog(LOG_ERR, "Failed to restore attributes for %s: %s",  
    433                         rLocalDirectoryName.c_str(), e.what()); 
    434                 return Restore_UnknownError; 
    435         } 
    436424        catch(std::exception &e) 
    437425        { 
    438                 ::syslog(LOG_ERR, "Failed to restore attributes for %s: %s",  
    439                         rLocalDirectoryName.c_str(), e.what()); 
     426                BOX_ERROR("Failed to restore attributes for '" << 
     427                        rLocalDirectoryName << "': " << e.what()); 
    440428                return Restore_UnknownError; 
    441429        } 
    442430        catch(...) 
    443431        { 
    444                 ::syslog(LOG_ERR, "Failed to restore attributes for %s: " 
    445                         "unknown error", rLocalDirectoryName.c_str()); 
     432                BOX_ERROR("Failed to restore attributes for '" << 
     433                        rLocalDirectoryName << "': unknown error"); 
    446434                return Restore_UnknownError; 
    447435        } 
     
    465453                                if(::unlink(localFilename.c_str()) == 0) 
    466454                                { 
    467                                         ::syslog(LOG_ERR, "Failed to delete " 
    468                                                 "file %s: %s", 
    469                                                 localFilename.c_str(), 
     455                                        BOX_ERROR("Failed to delete file '" << 
     456                                                localFilename << "': " << 
    470457                                                strerror(errno)); 
    471458                                        return Restore_UnknownError; 
     
    495482                                        } 
    496483                                } 
    497                                 catch (BoxException &e) 
    498                                 { 
    499                                         ::syslog(LOG_ERR, "Failed to restore " 
    500                                                 "file %s: %s",  
    501                                                 localFilename.c_str(),  
     484                                catch(std::exception &e) 
     485                                { 
     486                                        BOX_ERROR("Failed to restore file '" << 
     487                                                localFilename << "': " << 
    502488                                                e.what()); 
    503489                                        return Restore_UnknownError; 
    504490                                } 
    505                                 catch(std::exception &e) 
    506                                 { 
    507                                         ::syslog(LOG_ERR, "Failed to restore " 
    508                                                 "file %s: %s",  
    509                                                 localFilename.c_str(),  
    510                                                 e.what()); 
    511                                         return Restore_UnknownError; 
    512                                 } 
    513491                                catch(...) 
    514492                                { 
    515                                         ::syslog(LOG_ERR, "Failed to restore " 
    516                                                 "file %s: unknown error",  
    517                                                 localFilename.c_str()); 
     493                                        BOX_ERROR("Failed to restore file '" << 
     494                                                localFilename << 
     495                                                "': unknown error"); 
    518496                                        return Restore_UnknownError; 
    519497                                } 
     
    541519                                                        existing */); 
    542520                                } 
    543                                 catch (BoxException &e) 
    544                                 { 
    545                                         ::syslog(LOG_ERR, "Failed to determine " 
    546                                                 "whether file exists: %s: %s",  
    547                                                 localFilename.c_str(),  
     521                                catch(std::exception &e) 
     522                                { 
     523                                        BOX_ERROR("Failed to determine " 
     524                                                "whether file exists: '" << 
     525                                                localFilename << "': " << 
    548526                                                e.what()); 
    549527                                        return Restore_UnknownError; 
    550528                                } 
    551                                 catch(std::exception &e) 
    552                                 { 
    553                                         ::syslog(LOG_ERR, "Failed to determine " 
    554                                                 "whether file exists: %s: %s",  
    555                                                 localFilename.c_str(),  
    556                                                 e.what()); 
    557                                         return Restore_UnknownError; 
    558                                 } 
    559529                                catch(...) 
    560530                                { 
    561                                         ::syslog(LOG_ERR, "Failed to determine " 
    562                                                 "whether file exists: %s: " 
    563                                                 "unknown error",  
    564                                                 localFilename.c_str()); 
     531                                        BOX_ERROR("Failed to determine " 
     532                                                "whether file exists: '" << 
     533                                                localFilename << "': " 
     534                                                "unknown error"); 
    565535                                        return Restore_UnknownError; 
    566536                                } 
     
    578548                                                        Params.mResumeInfo.Save(Params.mRestoreResumeInfoFilename); 
    579549                                                } 
    580                                                 catch (BoxException &e) 
    581                                                 { 
    582                                                         ::syslog(LOG_ERR, "Failed to save resume info file %s: %s",  
    583                                                                 Params.mRestoreResumeInfoFilename.c_str(), e.what()); 
    584                                                         return Restore_UnknownError; 
    585                                                 } 
    586550                                                catch(std::exception &e) 
    587551                                                { 
    588                                                         ::syslog(LOG_ERR, "Failed to save resume info file %s: %s",  
    589                                                                 Params.mRestoreResumeInfoFilename.c_str(), e.what()); 
     552                                                        BOX_ERROR("Failed to save resume info file '" << 
     553                                                                Params.mRestoreResumeInfoFilename << 
     554                                                                "': " << e.what()); 
    590555                                                        return Restore_UnknownError; 
    591556                                                } 
    592557                                                catch(...) 
    593558                                                { 
    594                                                         ::syslog(LOG_ERR, "Failed to save resume info file %s: " 
    595                                                                 "unknown error",  
    596                                                                 Params.mRestoreResumeInfoFilename.c_str()); 
     559                                                        BOX_ERROR("Failed to save resume info file '" << 
     560                                                                Params.mRestoreResumeInfoFilename << 
     561                                                                "': unknown error"); 
    597562                                                        return Restore_UnknownError; 
    598563                                                } 
     
    614579                                Params.mRestoreResumeInfoFilename); 
    615580                } 
    616                 catch (BoxException &e) 
    617                 { 
    618                         ::syslog(LOG_ERR, "Failed to save resume info file " 
    619                                 "%s: %s",  
    620                                 Params.mRestoreResumeInfoFilename.c_str(), 
     581                catch(std::exception &e) 
     582                { 
     583                        BOX_ERROR("Failed to save resume info file '" << 
     584                                Params.mRestoreResumeInfoFilename << "': " << 
    621585                                e.what()); 
    622586                        return Restore_UnknownError; 
    623587                } 
    624                 catch(std::exception &e) 
    625                 { 
    626                         ::syslog(LOG_ERR, "Failed to save resume info file " 
    627                                 "%s: %s",  
    628                                 Params.mRestoreResumeInfoFilename.c_str(), 
    629                                 e.what()); 
    630                         return Restore_UnknownError; 
    631                 } 
    632588                catch(...) 
    633589                { 
    634                         ::syslog(LOG_ERR, "Failed to save resume info file " 
    635                                 "%s: unknown error",  
    636                                 Params.mRestoreResumeInfoFilename.c_str()); 
     590                        BOX_ERROR("Failed to save resume info file '" << 
     591                                Params.mRestoreResumeInfoFilename << 
     592                                "': unknown error"); 
    637593                        return Restore_UnknownError; 
    638594                } 
     
    682638                dirAttr.WriteAttributes(rLocalDirectoryName.c_str(), false); 
    683639        } 
    684         catch (BoxException &e) 
    685         { 
    686                 ::syslog(LOG_ERR, "Failed to restore attributes for %s: %s",  
    687                         rLocalDirectoryName.c_str(), e.what()); 
    688                 return Restore_UnknownError; 
    689         } 
    690640        catch(std::exception &e) 
    691641        { 
    692                 ::syslog(LOG_ERR, "Failed to restore attributes for %s: %s",  
    693                         rLocalDirectoryName.c_str(), e.what()); 
     642                BOX_ERROR("Failed to restore attributes for '" << 
     643                        rLocalDirectoryName << "': " << e.what()); 
    694644                return Restore_UnknownError; 
    695645        } 
    696646        catch(...) 
    697647        { 
    698                 ::syslog(LOG_ERR, "Failed to restore attributes for %s: " 
    699                         "unknown error", rLocalDirectoryName.c_str()); 
     648                BOX_ERROR("Failed to restore attributes for '" << 
     649                        rLocalDirectoryName << "': unknown error"); 
    700650                return Restore_UnknownError; 
    701651        } 
  • box/chris/general/lib/backupclient/BackupStoreFile.cpp

    r1637 r1784  
    1818#include <new> 
    1919#include <string.h> 
     20 
    2021#ifndef BOX_DISABLE_BACKWARDS_COMPATIBILITY_BACKUPSTOREFILE 
    21         #ifndef WIN32 
    22                 #include <syslog.h> 
    23         #endif 
    2422        #include <stdio.h> 
    2523#endif 
     
    759757                                        if(!sWarnedAboutBackwardsCompatiblity) 
    760758                                        { 
    761                                                 ::printf("WARNING: Decoded one or more files using backwards compatibility mode for block index.\n"); 
    762                                                 ::syslog(LOG_ERR, "WARNING: Decoded one or more files using backwards compatibility mode for block index.\n"); 
     759                                                BOX_WARNING("WARNING: Decoded one or more files using backwards compatibility mode for block index."); 
    763760                                                sWarnedAboutBackwardsCompatiblity = true; 
    764761                                        } 
  • box/chris/general/lib/common/BoxTime.cpp

    r1318 r1784  
    1313        #include <sys/time.h> 
    1414#endif 
     15 
    1516#ifdef HAVE_TIME_H 
    1617        #include <time.h> 
    1718#endif 
    18 #ifdef HAVE_SYSLOG_H 
    19         #include <syslog.h> 
    20 #endif 
     19 
    2120#include <errno.h> 
    2221#include <string.h> 
     
    4140                if (gettimeofday(&tv, NULL) != 0) 
    4241                { 
    43                         ::syslog(LOG_ERR, "gettimeofday() failed (%s), " 
    44                                 "dropping precision", strerror(errno)); 
     42                        BOX_ERROR("Failed to gettimeofday(), dropping " 
     43                                "precision: " << strerror(errno)); 
    4544                } 
    4645                else 
  • box/chris/general/lib/common/DebugPrintf.cpp

    r219 r1784  
    1414#include <stdio.h> 
    1515#include <stdarg.h> 
    16  
    17 #ifdef WIN32 
    18         #include "emu.h" 
    19 #else 
    20         #include <syslog.h> 
    21 #endif 
    2216 
    2317#include "MemLeakFindOn.h" 
  • box/chris/general/lib/common/Logging.h

    r1603 r1784  
    1111#define LOGGING__H 
    1212 
     13#include <iomanip> 
    1314#include <sstream> 
    1415#include <vector> 
     
    4243        #define BOX_TRACE(stuff)   BOX_LOG(Log::TRACE, stuff) 
    4344#endif 
     45 
     46#define BOX_FORMAT_ACCOUNT(accno) \ 
     47        std::hex << \ 
     48        std::showbase << \ 
     49        std::internal << \ 
     50        std::setw(8) << \ 
     51        std::setfill('0') << \ 
     52        (accno) 
     53 
     54#define BOX_FORMAT_OBJECTID(objectid) \ 
     55        std::hex << \ 
     56        std::showbase << \ 
     57        (objectid) 
    4458 
    4559#undef ERROR 
  • box/chris/general/lib/raidfile/RaidFileRead.cpp

    r1345 r1784  
    2020#ifdef HAVE_SYS_UIO_H 
    2121        #include <sys/uio.h> 
    22 #endif 
    23  
    24 #ifdef HAVE_SYSLOG_H 
    25         #include <syslog.h> 
    2622#endif 
    2723 
     
    549545void RaidFileRead_Raid::AttemptToRecoverFromIOError(bool Stripe1) 
    550546{ 
    551         TRACE3("Attempting to recover from I/O error: %d %s, on stripe %d\n", mSetNumber, mFilename.c_str(), Stripe1?1:2); 
    552         ::syslog(LOG_ERR | LOG_LOCAL5, "Attempting to recover from I/O error: %d %s, on stripe %d\n", mSetNumber, mFilename.c_str(), Stripe1?1:2); 
     547        BOX_WARNING("Attempting to recover from I/O error: " << mSetNumber << 
     548                " " << mFilename << ", on stripe " << (Stripe1?1:2)); 
    553549 
    554550        // Close offending file 
     
    862858                        if(errno == EIO) 
    863859                        { 
    864                                 TRACE3("I/O error when seeking in %d %s (to %d), stripe 1\n", mSetNumber, mFilename.c_str(), (int)FilePosition); 
    865                                 ::syslog(LOG_ERR | LOG_LOCAL5, "I/O error when seeking in %d %s (to %d), stripe 1\n", mSetNumber, mFilename.c_str(), (int)FilePosition); 
     860                                BOX_ERROR("I/O error when seeking in " << 
     861                                        mSetNumber << " " << mFilename << 
     862                                        " (to " << FilePosition << "), " << 
     863                                        "stripe 1"); 
    866864                                // Attempt to recover 
    867865                                AttemptToRecoverFromIOError(true /* is stripe 1 */); 
     
    880878                        if(errno == EIO) 
    881879                        { 
    882                                 TRACE3("I/O error when seeking in %d %s (to %d), stripe 2\n", mSetNumber, mFilename.c_str(), (int)FilePosition); 
    883                                 ::syslog(LOG_ERR | LOG_LOCAL5, "I/O error when seeking in %d %s (to %d), stripe 2\n", mSetNumber, mFilename.c_str(), (int)FilePosition); 
     880                                BOX_ERROR("I/O error when seeking in " << 
     881                                        mSetNumber << " " << mFilename << 
     882                                        " (to " << FilePosition << "), " << 
     883                                        "stripe 2"); 
    884884                                // Attempt to recover 
    885885                                AttemptToRecoverFromIOError(false /* is stripe 2 */); 
     
    10551055                if(existance != RaidFileUtil::AsRaid) 
    10561056                { 
    1057                         TRACE2("Opening %d %s in normal mode, but parity file doesn't exist\n", SetNumber, Filename.c_str()); 
    1058                         ::syslog(LOG_ERR | LOG_LOCAL5, "Opening %d %s in normal mode, but parity file doesn't exist\n", SetNumber, Filename.c_str()); 
     1057                        BOX_ERROR("Opening " << SetNumber << " " << 
     1058                                Filename << " in normal mode, but " 
     1059                                "parity file doesn't exist"); 
    10591060                        // TODO: Alert recovery daemon 
    10601061                } 
     
    11311132                        if(stripe1errno == EIO) 
    11321133                        { 
    1133                                 TRACE2("I/O error on opening %d %s stripe 1, trying recovery mode\n", SetNumber, Filename.c_str()); 
    1134                                 ::syslog(LOG_ERR | LOG_LOCAL5, "I/O error on opening %d %s stripe 1, trying recovery mode\n", SetNumber, Filename.c_str()); 
     1134                                BOX_ERROR("I/O error on opening " << 
     1135                                        SetNumber << " " << Filename << 
     1136                                        " stripe 1, trying recovery mode"); 
    11351137                                RaidFileRead_Raid::MoveDamagedFileAlertDaemon(SetNumber, Filename, true /* is stripe 1 */); 
    11361138 
     
    11471149                        if(stripe2errno == EIO) 
    11481150                        { 
    1149                                 TRACE2("I/O error on opening %d %s stripe 2, trying recovery mode\n", SetNumber, Filename.c_str()); 
    1150                                 ::syslog(LOG_ERR | LOG_LOCAL5, "I/O error on opening %d %s stripe 2, trying recovery mode\n", SetNumber, Filename.c_str()); 
     1151                                BOX_ERROR("I/O error on opening " << 
     1152                                        SetNumber << " " << Filename << 
     1153                                        " stripe 2, trying recovery mode"); 
    11511154                                RaidFileRead_Raid::MoveDamagedFileAlertDaemon(SetNumber, Filename, false /* is stripe 2 */); 
    11521155 
     
    11701173        if(existance == RaidFileUtil::AsRaidWithMissingReadable) 
    11711174        { 
    1172                 TRACE3("Attempting to open RAID file %d %s in recovery mode (stripe %d present)\n", SetNumber, Filename.c_str(), (existingFiles & RaidFileUtil::Stripe1Exists)?1:2); 
    1173                 ::syslog(LOG_ERR | LOG_LOCAL5, "Attempting to open RAID file %d %s in recovery mode (stripe %d present)\n", SetNumber, Filename.c_str(), (existingFiles & RaidFileUtil::Stripe1Exists)?1:2); 
     1175                BOX_ERROR("Attempting to open RAID file " << SetNumber << 
     1176                        " " << Filename << " in recovery mode (stripe " << 
     1177                        ((existingFiles & RaidFileUtil::Stripe1Exists)?1:2) << 
     1178                        " present)"); 
    11741179         
    11751180                // Generate the filenames of all the lovely files 
  • box/chris/general/lib/server/Daemon.cpp

    r1741 r1784  
    1919#include <string.h> 
    2020#include <stdarg.h> 
    21  
    22 #ifdef HAVE_SYSLOG_H 
    23         #include <syslog.h> 
    24 #endif 
    2521 
    2622#ifdef WIN32 
     
    354350                        if(::setsid() == -1) 
    355351                        { 
    356                                 ::syslog(LOG_ERR, "can't setsid"); 
     352                                BOX_ERROR("Failed to setsid(): " <<  
     353                                        strerror(errno)); 
    357354                                THROW_EXCEPTION(ServerException, DaemoniseFailed) 
    358355                        } 
  • box/chris/general/lib/server/LocalProcessStream.cpp

    r1039 r1784  
    121121        if(!CreatePipe(&readFromChild, &writeInChild, &secAttr, 0)) 
    122122        { 
    123                 ::syslog(LOG_ERR, "Failed to CreatePipe for child process: " 
    124                         "error %d", GetLastError()); 
     123                BOX_ERROR("Failed to CreatePipe for child process: " 
     124                        GetErrorMessage(GetLastError())); 
    125125                THROW_EXCEPTION(ServerException, SocketPairFailed) 
    126126        } 
     
    156156        if(!result) 
    157157        { 
    158                 ::syslog(LOG_ERR, "Failed to CreateProcess: '%s': " 
    159                         "error %d", CommandLine, GetLastError()); 
     158                BOX_ERROR("Failed to CreateProcess: '" << CommandLine << 
     159                        "': " << GetErrorMessage(GetLastError())); 
    160160                CloseHandle(writeInChild); 
    161161                CloseHandle(readFromChild); 
  • box/chris/general/lib/server/SSLLib.cpp

    r217 r1784  
    1414#include <openssl/err.h> 
    1515#include <openssl/rand.h> 
    16  
    17 #ifndef WIN32 
    18 #include <syslog.h> 
    19 #endif 
    2016 
    2117#include "SSLLib.h" 
     
    7470        { 
    7571                ::ERR_error_string_n(errcode, errname, sizeof(errname)); 
    76                 #ifndef NDEBUG 
    77                         if(SSLLib__TraceErrors) 
    78                         { 
    79                                 TRACE2("SSL err during %s: %s\n", ErrorDuringAction, errname); 
    80                         } 
    81                 #endif 
    82                 ::syslog(LOG_ERR, "SSL err during %s: %s", ErrorDuringAction, errname); 
     72                BOX_ERROR("SSL error during " << ErrorDuringAction << ": " << 
     73                        errname); 
    8374        } 
    8475} 
  • box/chris/general/lib/server/ServerStream.h

    r1603 r1784  
    1515 
    1616#ifndef WIN32 
    17         #include <syslog.h> 
    1817        #include <sys/wait.h> 
    1918#endif 
     
    7473                        if(childExit) 
    7574                        { 
    76                                 ::syslog(LOG_ERR, "in server child, exception %s (%d/%d) -- terminating child", e.what(), e.GetType(), e.GetSubType()); 
     75                                BOX_ERROR("Error in child process, " 
     76                                        "terminating connection: exception " << 
     77                                        e.what() << "(" << e.GetType() << 
     78                                        "/" << e.GetSubType() << ")"); 
    7779                                _exit(1); 
    7880                        } 
     
    8385                        if(childExit) 
    8486                        { 
    85                                 ::syslog(LOG_ERR, "in server child, exception %s -- terminating child", e.what()); 
     87                                BOX_ERROR("Error in child process, " 
     88                                        "terminating connection: exception " << 
     89                                        e.what()); 
    8690                                _exit(1); 
    8791                        } 
     
    9296                        if(childExit) 
    9397                        { 
    94                                 ::syslog(LOG_ERR, "in server child, unknown exception -- terminating child"); 
     98                                BOX_ERROR("Error in child process, " 
     99                                        "terminating connection: " 
     100                                        "unknown exception"); 
    95101                                _exit(1); 
    96102                        } 
     
    267273                                                         
    268274                                                        // Log it 
    269                                                         ::syslog(LOG_INFO, "%s (handling in child %d)", logMessage.c_str(), pid); 
     275                                                        BOX_WARNING("Error message from child process " << pid << ": " << logMessage); 
    270276                                                } 
    271277                                                else 
  • box/chris/general/lib/server/Socket.cpp

    r456 r1784  
    1818#include <sys/socket.h> 
    1919#include <netdb.h> 
    20 #include <syslog.h> 
    2120#include <netinet/in.h> 
    2221#include <arpa/inet.h> 
     
    125124        { 
    126125        case AF_UNIX: 
    127                 ::syslog(LOG_INFO, "Incoming connection from local (UNIX socket)"); 
     126                BOX_INFO("Incoming connection from local (UNIX socket)"); 
    128127                break;           
    129128         
     
    131130                { 
    132131                        sockaddr_in *a = (sockaddr_in*)addr; 
    133                         ::syslog(LOG_INFO, "Incoming connection from %s port %d", inet_ntoa(a->sin_addr), ntohs(a->sin_port)); 
     132                        BOX_INFO("Incoming connection from " << 
     133                                inet_ntoa(a->sin_addr) << " port " << 
     134                                ntohs(a->sin_port)); 
    134135                } 
    135136                break;           
    136137         
    137138        default: 
    138                 ::syslog(LOG_INFO, "Incoming connection of unknown type"); 
     139                BOX_WARNING("Incoming connection of unknown type"); 
    139140                break; 
    140141        } 
  • box/chris/general/lib/server/WinNamedPipeStream.cpp

    r1464 r1784  
    6464                catch (std::exception &e) 
    6565                { 
    66                         ::syslog(LOG_ERR, "Caught exception while destroying " 
    67                                 "named pipe, ignored."); 
     66                        BOX_ERROR("Caught exception while destroying " 
     67                                "named pipe, ignored: " << e.what()); 
    6868                } 
    6969        } 
     
    101101        if (mSocketHandle == INVALID_HANDLE_VALUE) 
    102102        { 
    103                 ::syslog(LOG_ERR, "CreateNamedPipeW failed: %s",  
    104                         GetErrorMessage(GetLastError()).c_str()); 
     103                BOX_ERROR("Failed to CreateNamedPipeW(" << pName << "): " << 
     104                        GetErrorMessage(GetLastError())); 
    105105                THROW_EXCEPTION(ServerException, SocketOpenError) 
    106106        } 
     
    110110        if (!connected) 
    111111        { 
    112                 ::syslog(LOG_ERR, "ConnectNamedPipe failed: %s",  
    113                         GetErrorMessage(GetLastError()).c_str()); 
     112                BOX_ERROR("Failed to ConnectNamedPipe(" << pName << "): " << 
     113                        GetErrorMessage(GetLastError())); 
    114114                Close(); 
    115115                THROW_EXCEPTION(ServerException, SocketOpenError) 
     
    127127        if (mReadableEvent == INVALID_HANDLE_VALUE) 
    128128        { 
    129                 ::syslog(LOG_ERR, "Failed to create the Readable event: %s", 
    130                         GetErrorMessage(GetLastError()).c_str()); 
     129                BOX_ERROR("Failed to create the Readable event: " << 
     130                        GetErrorMessage(GetLastError())); 
    131131                Close(); 
    132132                THROW_EXCEPTION(CommonException, Internal) 
     
    145145                if (err != ERROR_IO_PENDING) 
    146146                { 
    147                         ::syslog(LOG_ERR, "Failed to start overlapped read: " 
    148                                 "%s", GetErrorMessage(err).c_str()); 
     147                        BOX_ERROR("Failed to start overlapped read: " << 
     148                                GetErrorMessage(err)); 
    149149                        Close(); 
    150150                        THROW_EXCEPTION(ConnectionException,  
     
    184184                if (err == ERROR_PIPE_BUSY) 
    185185                { 
    186                         ::syslog(LOG_ERR, "Failed to connect to backup " 
    187                                 "daemon: it is busy with another connection"); 
     186                        BOX_ERROR("Failed to connect to backup daemon: " 
     187                                "it is busy with another connection"); 
    188188                } 
    189189                else 
    190190                { 
    191                         ::syslog(LOG_ERR, "Failed to connect to backup " 
    192                                 "daemon: %s", GetErrorMessage(err).c_str()); 
     191                        BOX_ERROR("Failed to connect to backup daemon: " << 
     192                                GetErrorMessage(err)); 
    193193                } 
    194194                THROW_EXCEPTION(ServerException, SocketOpenError) 
     
    262262                                        if (err == ERROR_BROKEN_PIPE) 
    263263                                        { 
    264                                                 ::syslog(LOG_ERR, "Control " 
    265                                                         "client disconnected"); 
     264                                                BOX_ERROR("Control client " 
     265                                                        "disconnected"); 
    266266                                        } 
    267267                                        else 
    268268                                        { 
    269                                                 ::syslog(LOG_ERR,  
    270                                                         "Failed to wait for " 
     269                                                BOX_ERROR("Failed to wait for " 
    271270                                                        "ReadFile to complete: " 
    272                                                         "%s",  
    273                                                         GetErrorMessage(err).c_str()); 
     271                                                        << GetErrorMessage(err)); 
    274272                                        } 
    275273 
     
    327325                        else if (err == ERROR_BROKEN_PIPE) 
    328326                        { 
    329                                 ::syslog(LOG_ERR,  
    330                                         "Control client disconnected"); 
     327                                BOX_ERROR("Control client disconnected"); 
    331328                                mReadClosed = true; 
    332329                        } 
    333330                        else 
    334331                        { 
    335                                 ::syslog(LOG_ERR, "Failed to start " 
    336                                         "overlapped read: %s",  
    337                                         GetErrorMessage(err).c_str()); 
     332                                BOX_ERROR("Failed to start overlapped read: " 
     333                                        << GetErrorMessage(err)); 
    338334                                Close(); 
    339335                                THROW_EXCEPTION(ConnectionException,  
     
    388384                        else 
    389385                        { 
    390                                 ::syslog(LOG_ERR, "Failed to read from " 
    391                                         "control socket: %s",  
    392                                         GetErrorMessage(err).c_str()); 
     386                                BOX_ERROR("Failed to read from control socket: " 
     387                                        << GetErrorMessage(err)); 
    393388                                THROW_EXCEPTION(ConnectionException,  
    394389                                        Conn_SocketReadError) 
     
    441436                { 
    442437                        DWORD err = GetLastError(); 
    443                         ::syslog(LOG_ERR, "Failed to write to control socket: " 
    444                                 "%s", GetErrorMessage(err).c_str()); 
     438                        BOX_ERROR("Failed to write to control socket: " << 
     439                                GetErrorMessage(err)); 
    445440                        Close(); 
    446441 
     
    475470        if (mSocketHandle == INVALID_HANDLE_VALUE && mIsConnected) 
    476471        { 
    477                 fprintf(stderr, "Inconsistent connected state\n"); 
    478                 ::syslog(LOG_ERR, "Inconsistent connected state"); 
     472                BOX_ERROR("Named pipe: inconsistent connected state"); 
    479473                mIsConnected = false; 
    480474        } 
     
    489483                if (!CancelIo(mSocketHandle)) 
    490484                { 
    491                         ::syslog(LOG_ERR, "Failed to cancel outstanding " 
    492                                 "I/O: %s",  
    493                                 GetErrorMessage(GetLastError()).c_str()); 
     485                        BOX_ERROR("Failed to cancel outstanding I/O: " << 
     486                                GetErrorMessage(GetLastError())); 
    494487                } 
    495488 
    496489                if (mReadableEvent == INVALID_HANDLE_VALUE) 
    497490                { 
    498                         ::syslog(LOG_ERR, "Failed to destroy Readable " 
    499                                 "event: invalid handle"); 
     491                        BOX_ERROR("Failed to destroy Readable event: " 
     492                                "invalid handle"); 
    500493                } 
    501494                else if (!CloseHandle(mReadableEvent)) 
    502495                { 
    503                         ::syslog(LOG_ERR, "Failed to destroy Readable " 
    504                                 "event: %s",  
    505                                 GetErrorMessage(GetLastError()).c_str()); 
     496                        BOX_ERROR("Failed to destroy Readable event: " << 
     497                                GetErrorMessage(GetLastError())); 
    506498                } 
    507499 
     
    510502                if (!FlushFileBuffers(mSocketHandle)) 
    511503                { 
    512                         ::syslog(LOG_INFO, "FlushFileBuffers failed: %s",  
    513                                 GetErrorMessage(GetLastError()).c_str()); 
     504                        BOX_ERROR("Failed to FlushFileBuffers: " << 
     505                                GetErrorMessage(GetLastError())); 
    514506                } 
    515507         
     
    519511                        if (err != ERROR_PIPE_NOT_CONNECTED) 
    520512                        { 
    521                                 ::syslog(LOG_ERR, "DisconnectNamedPipe " 
    522                                         "failed: %s",  
    523                                         GetErrorMessage(err).c_str()); 
     513                                BOX_ERROR("Failed to DisconnectNamedPipe: " << 
     514                                        GetErrorMessage(err)); 
    524515                        } 
    525516                } 
     
    537528        if (!result)  
    538529        { 
    539                 ::syslog(LOG_ERR, "CloseHandle failed: %s",  
    540                         GetErrorMessage(GetLastError()).c_str()); 
     530                BOX_ERROR("Failed to CloseHandle: " << 
     531                        GetErrorMessage(GetLastError())); 
    541532                THROW_EXCEPTION(ServerException, SocketCloseError) 
    542533        } 
     
    586577        if (!FlushFileBuffers(mSocketHandle)) 
    587578        { 
    588                 ::syslog(LOG_WARNING, "FlushFileBuffers failed: %s",  
    589                         GetErrorMessage(GetLastError()).c_str()); 
     579                BOX_ERROR("Failed to FlushFileBuffers: " << 
     580                        GetErrorMessage(GetLastError())); 
    590581        } 
    591582} 
Note: See TracChangeset for help on using the changeset viewer.