From: Eric Bollengier Date: Tue, 11 Oct 2022 20:10:12 +0000 (+0200) Subject: Tweak debug levels for CDP X-Git-Tag: Beta-15.0.0~419 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a3b342ac01a48fe7b4f885f829310bcc8aacae9;p=thirdparty%2Fbacula.git Tweak debug levels for CDP --- diff --git a/bacula/src/plugins/fd/file-record.h b/bacula/src/plugins/fd/file-record.h index ec4e27cdd..6a52527ca 100644 --- a/bacula/src/plugins/fd/file-record.h +++ b/bacula/src/plugins/fd/file-record.h @@ -59,7 +59,7 @@ class FileRecord FILE *fp = fopen(this->name, "r"); if (!fp) { - Dmsg1(0, "Could not open file %s\n", this->name); + Dmsg1(10, "Could not open file %s\n", this->name); return false; } @@ -67,7 +67,7 @@ class FileRecord if(fstat(fd, &statbuf) != 0) { fclose(fp); - Dmsg1(0, "Could not encode attributes of file %s\n", this->name); + Dmsg1(10, "Could not encode attributes of file %s\n", this->name); return false; } diff --git a/bacula/src/plugins/fd/journal.c b/bacula/src/plugins/fd/journal.c index 5f4930e2c..fe7d0b1b2 100644 --- a/bacula/src/plugins/fd/journal.c +++ b/bacula/src/plugins/fd/journal.c @@ -34,7 +34,7 @@ bool Journal::beginTransaction(const char *mode) _fp = bfopen(_jPath, mode); if (!_fp) { - Dmsg0(0, "Tried to start transaction but Journal File was not found.\n"); + Dmsg0(10, "Tried to start transaction but Journal File was not found.\n"); return false; } @@ -55,7 +55,7 @@ bool Journal::beginTransaction(const char *mode) hasTransaction = true; return true; } else { - Dmsg0(0, "Tried to start transaction but could not lock Journal File.\n"); + Dmsg0(10, "Tried to start transaction but could not lock Journal File.\n"); return false; } } @@ -70,7 +70,7 @@ void Journal::endTransaction() int rc = flock(_fd, LOCK_UN); if (rc != 0) { - Dmsg0(0, "could not release flock\n"); + Dmsg0(10, "could not release flock\n"); } fclose(_fp); @@ -129,7 +129,7 @@ bool Journal::setJournalPath(const char *path) rec.journalVersion = JOURNAL_VERSION; this->writeSettings(rec); } else { - Dmsg1(0, "(ERROR) Could not create Journal File: %s\n", path); + Dmsg1(10, "(ERROR) Could not create Journal File: %s\n", path); return false; } } else { @@ -151,7 +151,7 @@ bool Journal::setJournalPath(const char *path, const char *spoolDir) rec.setSpoolDir(spoolDir); this->writeSettings(rec); } else { - Dmsg1(0, "(ERROR) Could not create Journal File: %s\n", path); + Dmsg1(10, "(ERROR) Could not create Journal File: %s\n", path); return false; } } else { @@ -229,7 +229,7 @@ SettingsRecord *Journal::readSettings() SettingsRecord *rec = NULL; if(!this->beginTransaction("r+")) { - Dmsg0(0, "Could not start transaction for readSettings()\n"); + Dmsg0(10, "Could not start transaction for readSettings()\n"); goto bail_out; } @@ -308,7 +308,7 @@ bail_out: } if(corrupted) { - Dmsg0(0, "Could not read Settings Record. Journal is Corrupted.\n"); + Dmsg0(10, "Could not read Settings Record. Journal is Corrupted.\n"); if(rec != NULL) { delete rec; @@ -328,7 +328,7 @@ bool Journal::writeFileRecord(const FileRecord &record) if(!this->beginTransaction("a")) { success = false; - Dmsg0(0, "Could not start transaction for writeFileRecord()\n"); + Dmsg0(10, "Could not start transaction for writeFileRecord()\n"); goto bail_out; } @@ -382,7 +382,7 @@ FileRecord *Journal::readFileRecord() FileRecord *rec = NULL; if(!hasTransaction) { - Dmsg0(0, "(ERROR) Journal::readFileRecord() called without any transaction\n"); + Dmsg0(10, "(ERROR) Journal::readFileRecord() called without any transaction\n"); goto bail_out; } @@ -469,7 +469,7 @@ bail_out: } if(corrupted) { - Dmsg0(0, "Could not read File Record. Journal is Corrupted.\n"); + Dmsg0(10, "Could not read File Record. Journal is Corrupted.\n"); if(rec != NULL) { delete rec; @@ -487,7 +487,7 @@ bool Journal::writeFolderRecord(const FolderRecord &record) if(!this->beginTransaction("a")) { success = false; - Dmsg0(0, "Could not start transaction for writeFileRecord()\n"); + Dmsg0(10, "Could not start transaction for writeFileRecord()\n"); goto bail_out; } @@ -499,7 +499,7 @@ bool Journal::writeFolderRecord(const FolderRecord &record) if(rc < 0) { success = false; - Dmsg1(0, "(ERROR) Could not write FolderRecord. RC=%d\n", rc); + Dmsg1(10, "(ERROR) Could not write FolderRecord. RC=%d\n", rc); goto bail_out; } @@ -524,7 +524,7 @@ FolderRecord *Journal::readFolderRecord() FolderRecord *rec = NULL; if(!hasTransaction) { - Dmsg0(0, "(ERROR) Journal::readFolderRecord() called without any transaction\n"); + Dmsg0(10, "(ERROR) Journal::readFolderRecord() called without any transaction\n"); goto bail_out; } @@ -568,7 +568,7 @@ FolderRecord *Journal::readFolderRecord() bail_out: if(corrupted) { - Dmsg0(0, "Could not read FolderRecord. Journal is Corrupted.\n"); + Dmsg0(10, "Could not read FolderRecord. Journal is Corrupted.\n"); if(rec != NULL) { delete rec; @@ -658,7 +658,7 @@ bail_out: rc = rename(tmp_jPath.c_str(), _jPath); if(rc != 0) { - Dmsg0(0, "Could not rename TMP Journal\n"); + Dmsg0(10, "Could not rename TMP Journal\n"); } } @@ -688,13 +688,13 @@ bool Journal::migrateTo(const char *newPath) newFp = bfopen(newPath, "w"); if (tmpFp == NULL) { - Dmsg1(0, "Could not bfopen %s. Aborting migration.\n", tmp_jPath); + Dmsg1(10, "Could not bfopen %s. Aborting migration.\n", tmp_jPath); success = false; goto bail_out; } if (newFp == NULL) { - Dmsg1(0, "Could not bfopen %s. Aborting migration.\n", newPath); + Dmsg1(10, "Could not bfopen %s. Aborting migration.\n", newPath); success = false; goto bail_out; } @@ -715,7 +715,7 @@ bool Journal::migrateTo(const char *newPath) for(int i = 0; i < 5; i++) { if(!bfgets(tmp, SANITY_CHECK, _fp)) { //Found a corrupted FileRecord - Dmsg0(0, "Found a corrupt FileRecord. Canceling Migration"); + Dmsg0(10, "Found a corrupt FileRecord. Canceling Migration"); success = false; goto bail_out; } @@ -746,7 +746,7 @@ bail_out: rc = rename(tmp_jPath, _jPath); if(rc != 0) { - Dmsg0(0, "Could not rename TMP Journal\n"); + Dmsg0(10, "Could not rename TMP Journal\n"); } free(_jPath); diff --git a/bacula/src/tools/cdp-client/backupservice.cpp b/bacula/src/tools/cdp-client/backupservice.cpp index d2a28e57e..0b938c49f 100644 --- a/bacula/src/tools/cdp-client/backupservice.cpp +++ b/bacula/src/tools/cdp-client/backupservice.cpp @@ -38,7 +38,7 @@ void BackupService::start(const char *spoolPath, Journal *j) err_msg = w->watch(rec->path); if (err_msg != NULL) { - Dmsg2(0, "Error while trying to watch %s. %s", rec->path, err_msg); + Dmsg2(10, "Error while trying to watch %s. %s", rec->path, err_msg); free_and_null_pool_memory(err_msg); } else { _watchers[rec->path] = w; @@ -64,7 +64,7 @@ POOLMEM *BackupService::watch(const char *folder) _journal->writeFolderRecord(rec); _watchers[rec.path] = w; } else { - Dmsg2(0, "Error while trying to watch %s. %s", fpath, err_msg); + Dmsg2(10, "Error while trying to watch %s. %s", fpath, err_msg); delete w; } @@ -87,7 +87,7 @@ void BackupService::onChange(const char *fpath) POOLMEM *spoolFilename = get_pool_memory(PM_FNAME); if (strcmp(fpath, _journal->_jPath) == 0) { - Dmsg0(0, "Change on Journal File ignored.\n"); + Dmsg0(10, "Change on Journal File ignored.\n"); goto bail_out; } @@ -109,11 +109,11 @@ void BackupService::onChange(const char *fpath) Mmsg(spoolFilename, "%s/%s_%s", _spoolPath, str_mtime, fname); if (copyfile(fpath, spoolFilename) == 0) { - Dmsg2(0, "Copied file %s into %s\n", fpath, spoolFilename); + Dmsg2(10, "Copied file %s into %s\n", fpath, spoolFilename); rec.sname = bstrdup(spoolFilename); _journal->writeFileRecord(rec); } else { - Dmsg2(0, "Could not copy file %s into %s\n", fpath, spoolFilename); + Dmsg2(10, "Could not copy file %s into %s\n", fpath, spoolFilename); } bail_out: diff --git a/bacula/src/tools/cdp-client/cdp-client.cpp b/bacula/src/tools/cdp-client/cdp-client.cpp index 75de4823d..8d0dac9c6 100644 --- a/bacula/src/tools/cdp-client/cdp-client.cpp +++ b/bacula/src/tools/cdp-client/cdp-client.cpp @@ -46,7 +46,7 @@ static void waitForChanges(BackupService *bservice) { pthread_join(watcher->_watcherThread, NULL); #endif } else { - Dmsg0(0, "No folders te be watched. Terminating Client.\n"); + Dmsg0(10, "No folders te be watched. Terminating Client.\n"); } } @@ -95,7 +95,7 @@ static void writeFolders(Journal *journal, alist *newFolders) { rec.path = bstrdup(folder); if(!journal->writeFolderRecord(rec)) { - Dmsg1(0, "ERROR: Could not write folder %s", rec.path); + Pmsg1(0, "ERROR: Could not write folder %s", rec.path); exit(-1); } } @@ -105,11 +105,11 @@ static void writeFolders(Journal *journal, alist *newFolders) { static void makeJournalFile(Journal *journal, const char *journal_path, const char *spool_dir) { if (!journal->setJournalPath(journal_path, spool_dir)) { - Dmsg1(0, "Could not set journal file to: %s\n", journal_path); + Pmsg1(0, "Could not set journal file to: %s\n", journal_path); exit(1); } - Dmsg1(0, "Set journal file to: %s\n", journal_path); + Dmsg1(10, "Set journal file to: %s\n", journal_path); } static void makeSpoolDir(const char *spool_dir) { @@ -144,11 +144,11 @@ static void makeSpoolDir(const char *spool_dir) { } if (error != NULL) { - Dmsg2(0, "(ERROR) - could not set spool directory to %s. %s\n", spool_dir, error); + Pmsg2(0, "(ERROR) - could not set spool directory to %s. %s\n", spool_dir, error); exit(-1); } - Dmsg1(0, "Set spool directory to: %s\n", spool_dir); + Dmsg1(10, "Set spool directory to: %s\n", spool_dir); } static void printHelp() diff --git a/bacula/src/tools/cdp-client/folderwatcher.cpp b/bacula/src/tools/cdp-client/folderwatcher.cpp index ec44980ec..15108ad6b 100644 --- a/bacula/src/tools/cdp-client/folderwatcher.cpp +++ b/bacula/src/tools/cdp-client/folderwatcher.cpp @@ -123,7 +123,7 @@ POOLMEM *FolderWatcher::watchDirRecursive(const char *dir) goto bail_out; } - Dmsg1(0, "Started Watching: %s\n", dir); + Dmsg1(10, "Started Watching: %s\n", dir); _watchedDirs[wd] = bstrdup(dir); dirReader = opendir(dir); @@ -244,7 +244,7 @@ FolderWatcher::~FolderWatcher() std::map::iterator it; for(it = _watchedDirs.begin(); it != _watchedDirs.end(); it++) { inotify_rm_watch(_fd, it->first); - Dmsg1(0, "Stopped Watching: %s\n", it->second); + Dmsg1(10, "Stopped Watching: %s\n", it->second); free(it->second); } } @@ -288,9 +288,9 @@ void *thread_watcher(void *arg) { DWORD errorCode = GetLastError(); if (errorCode == ERROR_NOTIFY_ENUM_DIR) { - Dmsg0(0, "WinNotify buffer overflow\n"); + Dmsg0(10, "WinNotify buffer overflow\n"); } else { - Dmsg0(0, "Generic ReadDirectoryChangesW error\n"); + Dmsg0(10, "Generic ReadDirectoryChangesW error\n"); } continue; } @@ -302,12 +302,12 @@ void *thread_watcher(void *arg) { INFINITE); if (result == 1) { - Dmsg0(0, "Received stop event, aborting folder watcher thread\n"); + Dmsg0(10, "Received stop event, aborting folder watcher thread\n"); continue; } if (result != 0) { - Dmsg1(0, "WaitForMultipleObjects failed. Error: %ld\n", GetLastError()); + Dmsg1(10, "WaitForMultipleObjects failed. Error: %ld\n", GetLastError()); continue; } @@ -316,9 +316,9 @@ void *thread_watcher(void *arg) { if (!ok) { DWORD errorCode = GetLastError(); if (errorCode == ERROR_NOTIFY_ENUM_DIR) { - Dmsg0(0, "WinNotify buffer overflow\n"); + Dmsg0(10, "WinNotify buffer overflow\n"); } else { - Dmsg0(0, "Generic GetOverlappedResult error\n"); + Dmsg0(10, "Generic GetOverlappedResult error\n"); } continue; } @@ -335,8 +335,8 @@ void *thread_watcher(void *arg) { watcher->_watchedDirPath, fsubpath); CDP::winToUnixPath(fpath); - Dmsg1(0, "WinNotify Event: 0x%08x\n", curEntry->Action); - Dmsg1(0, "Event for file: %s\n", fpath); + Dmsg1(10, "WinNotify Event: 0x%08x\n", curEntry->Action); + Dmsg1(10, "Event for file: %s\n", fpath); #ifdef UNICODE const size_t fpathSize = strlen(fpath) + 1; @@ -360,7 +360,7 @@ void *thread_watcher(void *arg) { fp = fopen(fpath, "r"); if (fp) { - Dmsg1(0, "Change detected in file: %s\n", fpath); + Dmsg1(10, "Change detected in file: %s\n", fpath); watcher->_changeHandler->onChange(fpath); fclose(fp); break; @@ -426,7 +426,7 @@ POOLMEM *FolderWatcher::watch(const char *folder) } delete wfolder; - Dmsg1(0, "Started watching: %s\n", folder); + Dmsg1(10, "Started watching: %s\n", folder); return NULL; } @@ -438,7 +438,7 @@ FolderWatcher::~FolderWatcher() CancelIo(_dirHandle); CloseHandle(_dirHandle); _dirHandle = NULL; - Dmsg1(0, "Stopped watching: %s\n", _watchedDirPath); + Dmsg1(10, "Stopped watching: %s\n", _watchedDirPath); free(_watchedDirPath); } #endif