diff options
Diffstat (limited to 'lib/backupclient')
-rw-r--r-- | lib/backupclient/BackupClientFileAttributes.cpp | 13 | ||||
-rw-r--r-- | lib/backupclient/BackupClientRestore.cpp | 184 | ||||
-rw-r--r-- | lib/backupclient/BackupStoreFile.cpp | 7 |
3 files changed, 75 insertions, 129 deletions
diff --git a/lib/backupclient/BackupClientFileAttributes.cpp b/lib/backupclient/BackupClientFileAttributes.cpp index 9918c0d6..925d1620 100644 --- a/lib/backupclient/BackupClientFileAttributes.cpp +++ b/lib/backupclient/BackupClientFileAttributes.cpp @@ -344,8 +344,8 @@ void BackupClientFileAttributes::ReadAttributes(const char *Filename, bool ZeroM // to be true (still aborts), but it can at least hold 2^32. if (winTime >= 0x100000000LL || _gmtime64(&winTime) == 0) { - ::syslog(LOG_ERR, "Invalid Modification Time " - "caught for file: %s", Filename); + BOX_ERROR("Invalid Modification Time caught for " + "file: '" << Filename << "'"); pattr->ModificationTime = 0; } @@ -355,8 +355,8 @@ void BackupClientFileAttributes::ReadAttributes(const char *Filename, bool ZeroM if (winTime > 0x100000000LL || _gmtime64(&winTime) == 0) { - ::syslog(LOG_ERR, "Invalid Attribute Modification " - "Time caught for file: %s", Filename); + BOX_ERROR("Invalid Attribute Modification Time " + "caught for file: '" << Filename << "'"); pattr->AttrModificationTime = 0; } #endif @@ -627,9 +627,8 @@ void BackupClientFileAttributes::WriteAttributes(const char *Filename, } #ifdef WIN32 - ::syslog(LOG_WARNING, - "Cannot create symbolic links on Windows: %s", - Filename); + BOX_WARNING("Cannot create symbolic links on Windows: '" << + Filename << "'"); #else // Make a symlink, first deleting anything in the way ::unlink(Filename); diff --git a/lib/backupclient/BackupClientRestore.cpp b/lib/backupclient/BackupClientRestore.cpp index 9b3a3edc..92853624 100644 --- a/lib/backupclient/BackupClientRestore.cpp +++ b/lib/backupclient/BackupClientRestore.cpp @@ -235,20 +235,20 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir } catch (BoxException &e) { - ::syslog(LOG_ERR, "Failed to check existence for %s: %s", - rLocalDirectoryName.c_str(), e.what()); + BOX_ERROR("Failed to check existence for " << + rLocalDirectoryName << ": " << e.what()); return Restore_UnknownError; } catch(std::exception &e) { - ::syslog(LOG_ERR, "Failed to check existence for %s: %s", - rLocalDirectoryName.c_str(), e.what()); + BOX_ERROR("Failed to check existence for " << + rLocalDirectoryName << ": " << e.what()); return Restore_UnknownError; } catch(...) { - ::syslog(LOG_ERR, "Failed to check existence for %s: " - "unknown error", rLocalDirectoryName.c_str()); + BOX_ERROR("Failed to check existence for " << + rLocalDirectoryName << ": unknown error"); return Restore_UnknownError; } @@ -263,13 +263,14 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir ::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()); if(::unlink(rLocalDirectoryName.c_str()) != 0) { - ::syslog(LOG_ERR, "Failed to delete " - "file %s: %s", - rLocalDirectoryName.c_str(), + BOX_ERROR("Failed to delete file " << + rLocalDirectoryName << ": " << strerror(errno)); return Restore_UnknownError; } - TRACE1("In restore, directory name collision with file %s", rLocalDirectoryName.c_str()); + BOX_TRACE("In restore, directory name " + "collision with file " << + rLocalDirectoryName); } break; case ObjectExists_NoObject: @@ -325,20 +326,20 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir } catch (BoxException &e) { - ::syslog(LOG_ERR, "Failed to check existence for %s: " - "%s", parentDirectoryName.c_str(), e.what()); + BOX_ERROR("Failed to check existence for " << + parentDirectoryName << ": " << e.what()); return Restore_UnknownError; } catch(std::exception &e) { - ::syslog(LOG_ERR, "Failed to check existence for %s: " - "%s", parentDirectoryName.c_str(), e.what()); + BOX_ERROR("Failed to check existence for " << + parentDirectoryName << ": " << e.what()); return Restore_UnknownError; } catch(...) { - ::syslog(LOG_ERR, "Failed to check existence for %s: " - "unknown error", parentDirectoryName.c_str()); + BOX_ERROR("Failed to check existence for " << + parentDirectoryName << ": unknown error"); return Restore_UnknownError; } @@ -349,24 +350,22 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir break; case ObjectExists_File: - fprintf(stderr, "Failed to restore: '%s' " + BOX_ERROR("Failed to restore: '" << + parentDirectoryName << "' " "is a file, but should be a " - "directory.\n", - parentDirectoryName.c_str()); + "directory."); return Restore_TargetPathNotFound; case ObjectExists_NoObject: - fprintf(stderr, "Failed to restore: " - "parent '%s' of target directory " - "does not exist.\n", - parentDirectoryName.c_str()); + BOX_ERROR("Failed to restore: parent '" << + parentDirectoryName << "' of target " + "directory does not exist."); return Restore_TargetPathNotFound; default: - fprintf(stderr, "Failed to restore: " - "unknown result from " - "ObjectExists('%s').\n", - parentDirectoryName.c_str()); + BOX_ERROR("Failed to restore: unknown " + "result from ObjectExists('" << + parentDirectoryName << "')"); return Restore_UnknownError; } } @@ -375,8 +374,8 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir exists == ObjectExists_File) && ::mkdir(rLocalDirectoryName.c_str(), S_IRWXU) != 0) { - ::syslog(LOG_ERR, "Failed to create directory %s: %s", - rLocalDirectoryName.c_str(), + BOX_ERROR("Failed to create directory '" << + rLocalDirectoryName << "': " << strerror(errno)); return Restore_UnknownError; } @@ -386,23 +385,18 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir { Params.mResumeInfo.Save(Params.mRestoreResumeInfoFilename); } - catch (BoxException &e) - { - ::syslog(LOG_ERR, "Failed to save resume info file %s: %s", - Params.mRestoreResumeInfoFilename.c_str(), e.what()); - return Restore_UnknownError; - } catch(std::exception &e) { - ::syslog(LOG_ERR, "Failed to save resume info file %s: %s", - Params.mRestoreResumeInfoFilename.c_str(), e.what()); + BOX_ERROR("Failed to save resume info file '" << + Params.mRestoreResumeInfoFilename << "': " << + e.what()); return Restore_UnknownError; } catch(...) { - ::syslog(LOG_ERR, "Failed to save resume info file %s: " - "unknown error", - Params.mRestoreResumeInfoFilename.c_str()); + BOX_ERROR("Failed to save resume info file '" << + Params.mRestoreResumeInfoFilename << + "': unknown error"); return Restore_UnknownError; } @@ -427,22 +421,16 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir { dirAttr.WriteAttributes(rLocalDirectoryName.c_str(), true); } - catch (BoxException &e) - { - ::syslog(LOG_ERR, "Failed to restore attributes for %s: %s", - rLocalDirectoryName.c_str(), e.what()); - return Restore_UnknownError; - } catch(std::exception &e) { - ::syslog(LOG_ERR, "Failed to restore attributes for %s: %s", - rLocalDirectoryName.c_str(), e.what()); + BOX_ERROR("Failed to restore attributes for '" << + rLocalDirectoryName << "': " << e.what()); return Restore_UnknownError; } catch(...) { - ::syslog(LOG_ERR, "Failed to restore attributes for %s: " - "unknown error", rLocalDirectoryName.c_str()); + BOX_ERROR("Failed to restore attributes for '" << + rLocalDirectoryName << "': unknown error"); return Restore_UnknownError; } @@ -464,9 +452,8 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir // Unlink anything which already exists -- for resuming restores, we can't overwrite files already there. if(::unlink(localFilename.c_str()) == 0) { - ::syslog(LOG_ERR, "Failed to delete " - "file %s: %s", - localFilename.c_str(), + BOX_ERROR("Failed to delete file '" << + localFilename << "': " << strerror(errno)); return Restore_UnknownError; } @@ -494,27 +481,18 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir BackupStoreFile::DecodeFile(*objectStream, localFilename.c_str(), rConnection.GetTimeout()); } } - catch (BoxException &e) - { - ::syslog(LOG_ERR, "Failed to restore " - "file %s: %s", - localFilename.c_str(), - e.what()); - return Restore_UnknownError; - } catch(std::exception &e) { - ::syslog(LOG_ERR, "Failed to restore " - "file %s: %s", - localFilename.c_str(), + BOX_ERROR("Failed to restore file '" << + localFilename << "': " << e.what()); return Restore_UnknownError; } catch(...) { - ::syslog(LOG_ERR, "Failed to restore " - "file %s: unknown error", - localFilename.c_str()); + BOX_ERROR("Failed to restore file '" << + localFilename << + "': unknown error"); return Restore_UnknownError; } @@ -540,28 +518,20 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir true /* treat links as not existing */); } - catch (BoxException &e) - { - ::syslog(LOG_ERR, "Failed to determine " - "whether file exists: %s: %s", - localFilename.c_str(), - e.what()); - return Restore_UnknownError; - } catch(std::exception &e) { - ::syslog(LOG_ERR, "Failed to determine " - "whether file exists: %s: %s", - localFilename.c_str(), + BOX_ERROR("Failed to determine " + "whether file exists: '" << + localFilename << "': " << e.what()); return Restore_UnknownError; } catch(...) { - ::syslog(LOG_ERR, "Failed to determine " - "whether file exists: %s: " - "unknown error", - localFilename.c_str()); + BOX_ERROR("Failed to determine " + "whether file exists: '" << + localFilename << "': " + "unknown error"); return Restore_UnknownError; } @@ -577,23 +547,18 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir { Params.mResumeInfo.Save(Params.mRestoreResumeInfoFilename); } - catch (BoxException &e) - { - ::syslog(LOG_ERR, "Failed to save resume info file %s: %s", - Params.mRestoreResumeInfoFilename.c_str(), e.what()); - return Restore_UnknownError; - } catch(std::exception &e) { - ::syslog(LOG_ERR, "Failed to save resume info file %s: %s", - Params.mRestoreResumeInfoFilename.c_str(), e.what()); + BOX_ERROR("Failed to save resume info file '" << + Params.mRestoreResumeInfoFilename << + "': " << e.what()); return Restore_UnknownError; } catch(...) { - ::syslog(LOG_ERR, "Failed to save resume info file %s: " - "unknown error", - Params.mRestoreResumeInfoFilename.c_str()); + BOX_ERROR("Failed to save resume info file '" << + Params.mRestoreResumeInfoFilename << + "': unknown error"); return Restore_UnknownError; } @@ -613,27 +578,18 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir Params.mResumeInfo.Save( Params.mRestoreResumeInfoFilename); } - catch (BoxException &e) - { - ::syslog(LOG_ERR, "Failed to save resume info file " - "%s: %s", - Params.mRestoreResumeInfoFilename.c_str(), - e.what()); - return Restore_UnknownError; - } catch(std::exception &e) { - ::syslog(LOG_ERR, "Failed to save resume info file " - "%s: %s", - Params.mRestoreResumeInfoFilename.c_str(), + BOX_ERROR("Failed to save resume info file '" << + Params.mRestoreResumeInfoFilename << "': " << e.what()); return Restore_UnknownError; } catch(...) { - ::syslog(LOG_ERR, "Failed to save resume info file " - "%s: unknown error", - Params.mRestoreResumeInfoFilename.c_str()); + BOX_ERROR("Failed to save resume info file '" << + Params.mRestoreResumeInfoFilename << + "': unknown error"); return Restore_UnknownError; } @@ -681,22 +637,16 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir { dirAttr.WriteAttributes(rLocalDirectoryName.c_str(), false); } - catch (BoxException &e) - { - ::syslog(LOG_ERR, "Failed to restore attributes for %s: %s", - rLocalDirectoryName.c_str(), e.what()); - return Restore_UnknownError; - } catch(std::exception &e) { - ::syslog(LOG_ERR, "Failed to restore attributes for %s: %s", - rLocalDirectoryName.c_str(), e.what()); + BOX_ERROR("Failed to restore attributes for '" << + rLocalDirectoryName << "': " << e.what()); return Restore_UnknownError; } catch(...) { - ::syslog(LOG_ERR, "Failed to restore attributes for %s: " - "unknown error", rLocalDirectoryName.c_str()); + BOX_ERROR("Failed to restore attributes for '" << + rLocalDirectoryName << "': unknown error"); return Restore_UnknownError; } diff --git a/lib/backupclient/BackupStoreFile.cpp b/lib/backupclient/BackupStoreFile.cpp index 75095fa4..7e93d59d 100644 --- a/lib/backupclient/BackupStoreFile.cpp +++ b/lib/backupclient/BackupStoreFile.cpp @@ -17,10 +17,8 @@ #include <string.h> #include <new> #include <string.h> + #ifndef BOX_DISABLE_BACKWARDS_COMPATIBILITY_BACKUPSTOREFILE - #ifndef WIN32 - #include <syslog.h> - #endif #include <stdio.h> #endif @@ -758,8 +756,7 @@ int BackupStoreFile::DecodedStream::Read(void *pBuffer, int NBytes, int Timeout) // Warn and log this issue if(!sWarnedAboutBackwardsCompatiblity) { - ::printf("WARNING: Decoded one or more files using backwards compatibility mode for block index.\n"); - ::syslog(LOG_ERR, "WARNING: Decoded one or more files using backwards compatibility mode for block index.\n"); + BOX_WARNING("WARNING: Decoded one or more files using backwards compatibility mode for block index."); sWarnedAboutBackwardsCompatiblity = true; } } |