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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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. 
Note: See TracChangeset for help on using the changeset viewer.