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;
}
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;
}
_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;
}
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;
}
}
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);
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 {
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 {
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;
}
}
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;
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;
}
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;
}
}
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;
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;
}
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;
}
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;
}
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;
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");
}
}
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;
}
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;
}
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);
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;
_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;
}
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;
}
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:
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");
}
}
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);
}
}
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) {
}
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()
goto bail_out;
}
- Dmsg1(0, "Started Watching: %s\n", dir);
+ Dmsg1(10, "Started Watching: %s\n", dir);
_watchedDirs[wd] = bstrdup(dir);
dirReader = opendir(dir);
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);
}
}
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;
}
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;
}
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;
}
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;
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;
}
delete wfolder;
- Dmsg1(0, "Started watching: %s\n", folder);
+ Dmsg1(10, "Started watching: %s\n", folder);
return NULL;
}
CancelIo(_dirHandle);
CloseHandle(_dirHandle);
_dirHandle = NULL;
- Dmsg1(0, "Stopped watching: %s\n", _watchedDirPath);
+ Dmsg1(10, "Stopped watching: %s\n", _watchedDirPath);
free(_watchedDirPath);
}
#endif