Indicate log location in some indexer error messages which will be displayed in the GUI

This commit is contained in:
Jean-Francois Dockes 2020-11-19 11:16:51 +01:00
parent 3e72a11932
commit 8111320a22
2 changed files with 58 additions and 47 deletions

View File

@ -156,7 +156,14 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags)
addIdxReason("indexer", m_db.getReason()); addIdxReason("indexer", m_db.getReason());
return false; return false;
} }
std::string logloc;
if (Logger::getTheLog()->logisstderr()) {
logloc = "program error output.";
} else {
logloc = std::string(" log in ") +
Logger::getTheLog()->getlogfilename() + ".";
}
m_config->setKeyDir(cstr_null); m_config->setKeyDir(cstr_null);
if (typestorun & IxTFs) { if (typestorun & IxTFs) {
if (runFirstIndexing()) { if (runFirstIndexing()) {
@ -168,7 +175,7 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags)
if (stopindexing) { if (stopindexing) {
addIdxReason("indexer", "Indexing was interrupted."); addIdxReason("indexer", "Indexing was interrupted.");
} else { } else {
addIdxReason("indexer", "Index creation failed. See log."); addIdxReason("indexer", "Index creation failed. See" + logloc);
} }
m_db.close(); m_db.close();
return false; return false;
@ -181,7 +188,7 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags)
m_webindexer = new WebQueueIndexer(m_config, &m_db, m_updater); m_webindexer = new WebQueueIndexer(m_config, &m_db, m_updater);
if (!m_webindexer || !m_webindexer->index()) { if (!m_webindexer || !m_webindexer->index()) {
m_db.close(); m_db.close();
addIdxReason("indexer", "Web index creation failed. See log"); addIdxReason("indexer", "Web index creation failed. See" + logloc);
return false; return false;
} }
} }
@ -191,7 +198,7 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags)
// filesystem anymore. Only if all *configured* indexers ran. // filesystem anymore. Only if all *configured* indexers ran.
if (m_updater && !m_updater->update(DbIxStatus::DBIXS_PURGE, "")) { if (m_updater && !m_updater->update(DbIxStatus::DBIXS_PURGE, "")) {
m_db.close(); m_db.close();
addIdxReason("indexer", "Index purge failed. See log"); addIdxReason("indexer", "Index purge failed. See" + logloc);
return false; return false;
} }
m_db.purge(); m_db.purge();
@ -205,7 +212,7 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags)
if (!m_db.close()) { if (!m_db.close()) {
LOGERR("ConfIndexer::index: error closing database in " << LOGERR("ConfIndexer::index: error closing database in " <<
m_config->getDbDir() << "\n"); m_config->getDbDir() << "\n");
addIdxReason("indexer", "Index close/flush failed. See log"); addIdxReason("indexer", "Index close/flush failed. See" +logloc);
return false; return false;
} }

View File

@ -396,7 +396,8 @@ static bool checktopdirs(RclConfig *config, vector<string>& nonexist)
} }
} }
} }
bool onegood{false};
for (auto& dir : o_topdirs) { for (auto& dir : o_topdirs) {
dir = path_tildexpand(dir); dir = path_tildexpand(dir);
if (!dir.size() || !path_isabsolute(dir)) { if (!dir.size() || !path_isabsolute(dir)) {
@ -411,6 +412,8 @@ static bool checktopdirs(RclConfig *config, vector<string>& nonexist)
} }
if (!path_exists(dir)) { if (!path_exists(dir)) {
nonexist.push_back(dir); nonexist.push_back(dir);
} else {
onegood = true;
} }
} }
topdirs_state(o_topdirs_emptiness); topdirs_state(o_topdirs_emptiness);
@ -418,60 +421,60 @@ static bool checktopdirs(RclConfig *config, vector<string>& nonexist)
// We'd like to check skippedPaths too, but these are wildcard // We'd like to check skippedPaths too, but these are wildcard
// exprs, so reasonably can't // exprs, so reasonably can't
return true; return onegood;
} }
string thisprog; string thisprog;
static const char usage [] = static const char usage [] =
"\n" "\n"
"recollindex [-h] \n" "recollindex [-h] \n"
" Print help\n" " Print help\n"
"recollindex [-z|-Z] [-k]\n" "recollindex [-z|-Z] [-k]\n"
" Index everything according to configuration file\n" " Index everything according to configuration file\n"
" -z : reset database before starting indexing\n" " -z : reset database before starting indexing\n"
" -Z : in place reset: consider all documents as changed. Can also\n" " -Z : in place reset: consider all documents as changed. Can also\n"
" be combined with -i or -r but not -m\n" " be combined with -i or -r but not -m\n"
" -k : retry files on which we previously failed\n" " -k : retry files on which we previously failed\n"
#ifdef RCL_MONITOR #ifdef RCL_MONITOR
"recollindex -m [-w <secs>] -x [-D] [-C]\n" "recollindex -m [-w <secs>] -x [-D] [-C]\n"
" Perform real time indexing. Don't become a daemon if -D is set.\n" " Perform real time indexing. Don't become a daemon if -D is set.\n"
" -w sets number of seconds to wait before starting.\n" " -w sets number of seconds to wait before starting.\n"
" -C disables monitoring config for changes/reexecuting.\n" " -C disables monitoring config for changes/reexecuting.\n"
" -n disables initial incremental indexing (!and purge!).\n" " -n disables initial incremental indexing (!and purge!).\n"
#ifndef DISABLE_X11MON #ifndef DISABLE_X11MON
" -x disables exit on end of x11 session\n" " -x disables exit on end of x11 session\n"
#endif /* DISABLE_X11MON */ #endif /* DISABLE_X11MON */
#endif /* RCL_MONITOR */ #endif /* RCL_MONITOR */
"recollindex -e [<filepath [path ...]>]\n" "recollindex -e [<filepath [path ...]>]\n"
" Purge data for individual files. No stem database updates.\n" " Purge data for individual files. No stem database updates.\n"
" Reads paths on stdin if none is given as argument.\n" " Reads paths on stdin if none is given as argument.\n"
"recollindex -i [-f] [-Z] [<filepath [path ...]>]\n" "recollindex -i [-f] [-Z] [<filepath [path ...]>]\n"
" Index individual files. No database purge or stem database updates\n" " Index individual files. No database purge or stem database updates\n"
" Will read paths on stdin if none is given as argument\n" " Will read paths on stdin if none is given as argument\n"
" -f : ignore skippedPaths and skippedNames while doing this\n" " -f : ignore skippedPaths and skippedNames while doing this\n"
"recollindex -r [-K] [-f] [-Z] [-p pattern] <top> \n" "recollindex -r [-K] [-f] [-Z] [-p pattern] <top> \n"
" Recursive partial reindex. \n" " Recursive partial reindex. \n"
" -p : filter file names, multiple instances are allowed, e.g.: \n" " -p : filter file names, multiple instances are allowed, e.g.: \n"
" -p *.odt -p *.pdf\n" " -p *.odt -p *.pdf\n"
" -K : skip previously failed files (they are retried by default)\n" " -K : skip previously failed files (they are retried by default)\n"
"recollindex -l\n" "recollindex -l\n"
" List available stemming languages\n" " List available stemming languages\n"
"recollindex -s <lang>\n" "recollindex -s <lang>\n"
" Build stem database for additional language <lang>\n" " Build stem database for additional language <lang>\n"
"recollindex -E\n" "recollindex -E\n"
" Check configuration file for topdirs and other paths existence\n" " Check configuration file for topdirs and other paths existence\n"
#ifdef FUTURE_IMPROVEMENT #ifdef FUTURE_IMPROVEMENT
"recollindex -W\n" "recollindex -W\n"
" Process the Web queue\n" " Process the Web queue\n"
#endif #endif
#ifdef RCL_USE_ASPELL #ifdef RCL_USE_ASPELL
"recollindex -S\n" "recollindex -S\n"
" Build aspell spelling dictionary.>\n" " Build aspell spelling dictionary.>\n"
#endif #endif
"Common options:\n" "Common options:\n"
" -c <configdir> : specify config directory, overriding $RECOLL_CONFDIR\n" " -c <configdir> : specify config directory, overriding $RECOLL_CONFDIR\n"
; ;
static void Usage() static void Usage()
@ -708,7 +711,8 @@ int main(int argc, char *argv[])
vector<string> nonexist; vector<string> nonexist;
if (!checktopdirs(config, nonexist)) { if (!checktopdirs(config, nonexist)) {
addIdxReason("init", "topdirs not set"); std::cerr << "topdirs not set or only contains invalid paths.\n";
addIdxReason("init", "topdirs not set or only contains invalid paths.");
flushIdxReasons(); flushIdxReasons();
exit(1); exit(1);
} }