]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Tweak debug levels for CDP
authorEric Bollengier <eric@baculasystems.com>
Tue, 11 Oct 2022 20:10:12 +0000 (22:10 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:59 +0000 (13:56 +0200)
bacula/src/plugins/fd/file-record.h
bacula/src/plugins/fd/journal.c
bacula/src/tools/cdp-client/backupservice.cpp
bacula/src/tools/cdp-client/cdp-client.cpp
bacula/src/tools/cdp-client/folderwatcher.cpp

index ec4e27cdddbb6e54149451082fd4966d5102f87d..6a52527cadd2266711a6f4eb0cf9f329e8597e84 100644 (file)
@@ -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;
          }
 
index 5f4930e2cabd0f96569b0a0899925c2349779a09..fe7d0b1b23615635a97336a4685de565c15a99e0 100644 (file)
@@ -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);
index d2a28e57e04305fa79bc34309b6ecc91886e952a..0b938c49f45d26e11d3cfd11bc0584af73eb76c1 100644 (file)
@@ -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:
index 75de4823d6146d3b94248e164625c6eb77395236..8d0dac9c668729fc610fd4857239e51906501696 100644 (file)
@@ -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()
index ec44980ec1716804852965d2d712f7dd48edf03f..15108ad6b4ef8ba434070d05bd311edec5410e1a 100644 (file)
@@ -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<int, char *>::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