logging now uses c++ streams

This commit is contained in:
Jean-Francois Dockes 2016-07-12 09:41:04 +02:00
parent 8fc0043de2
commit 12de4bb102
123 changed files with 1974 additions and 2760 deletions

View file

@ -25,7 +25,7 @@ COMMONCPPFLAGS = -I. \
-I$(top_srcdir)/xaposix \ -I$(top_srcdir)/xaposix \
-DBUILDING_RECOLL -DBUILDING_RECOLL
AM_CPPFLAGS = -Wall -Wno-unused \ AM_CPPFLAGS = -Wall -Wno-unused -std=c++11 \
$(COMMONCPPFLAGS) \ $(COMMONCPPFLAGS) \
$(INCICONV) \ $(INCICONV) \
$(XAPIANCXXFLAGS) \ $(XAPIANCXXFLAGS) \
@ -198,8 +198,6 @@ utils/copyfile.cpp \
utils/copyfile.h \ utils/copyfile.h \
utils/cpuconf.cpp \ utils/cpuconf.cpp \
utils/cpuconf.h \ utils/cpuconf.h \
utils/debuglog.cpp \
utils/debuglog.h \
utils/ecrontab.cpp \ utils/ecrontab.cpp \
utils/ecrontab.h \ utils/ecrontab.h \
utils/execmd.cpp \ utils/execmd.cpp \
@ -212,6 +210,8 @@ utils/hldata.h \
utils/hldata.cpp \ utils/hldata.cpp \
utils/idfile.cpp \ utils/idfile.cpp \
utils/idfile.h \ utils/idfile.h \
utils/log.cpp \
utils/log.h \
utils/md5.cpp \ utils/md5.cpp \
utils/md5.h \ utils/md5.h \
utils/md5ut.cpp \ utils/md5ut.cpp \

View file

@ -30,7 +30,7 @@
#include "pathut.h" #include "pathut.h"
#include "execmd.h" #include "execmd.h"
#include "rclaspell.h" #include "rclaspell.h"
#include "debuglog.h" #include "log.h"
#include "unacpp.h" #include "unacpp.h"
#include "ptmutex.h" #include "ptmutex.h"
@ -84,7 +84,7 @@ public:
: m_handle(0), m_speller(0) : m_handle(0), m_speller(0)
{} {}
~AspellData() { ~AspellData() {
LOGDEB2(("~AspellData\n")); LOGDEB2("~AspellData\n" );
if (m_handle) { if (m_handle) {
dlclose(m_handle); dlclose(m_handle);
m_handle = 0; m_handle = 0;
@ -93,7 +93,7 @@ public:
// Dumps core if I do this?? // Dumps core if I do this??
//aapi.delete_aspell_speller(m_speller); //aapi.delete_aspell_speller(m_speller);
m_speller = 0; m_speller = 0;
LOGDEB2(("~AspellData: speller done\n")); LOGDEB2("~AspellData: speller done\n" );
} }
} }
@ -240,9 +240,9 @@ public:
{} {}
void newData() { void newData() {
while (m_db.termWalkNext(m_tit, *m_input)) { while (m_db.termWalkNext(m_tit, *m_input)) {
LOGDEB2(("Aspell::buildDict: term: [%s]\n", m_input->c_str())); LOGDEB2("Aspell::buildDict: term: [" << (m_input) << "]\n" );
if (!Rcl::Db::isSpellingCandidate(*m_input)) { if (!Rcl::Db::isSpellingCandidate(*m_input)) {
LOGDEB2(("Aspell::buildDict: SKIP\n")); LOGDEB2("Aspell::buildDict: SKIP\n" );
continue; continue;
} }
if (!o_index_stripchars) { if (!o_index_stripchars) {
@ -253,7 +253,7 @@ public:
} }
// Got a non-empty sort-of appropriate term, let's send it to // Got a non-empty sort-of appropriate term, let's send it to
// aspell // aspell
LOGDEB2(("Apell::buildDict: SEND\n")); LOGDEB2("Apell::buildDict: SEND\n" );
m_input->append("\n"); m_input->append("\n");
return; return;
} }
@ -370,7 +370,7 @@ bool Aspell::make_speller(string& reason)
bool Aspell::check(const string &iterm, string& reason) bool Aspell::check(const string &iterm, string& reason)
{ {
LOGDEB2(("Aspell::check [%s]\n", iterm.c_str())); LOGDEB2("Aspell::check [" << (iterm) << "]\n" );
string mterm(iterm); string mterm(iterm);
if (!ok() || !make_speller(reason)) if (!ok() || !make_speller(reason))
@ -381,7 +381,7 @@ bool Aspell::check(const string &iterm, string& reason)
if (!o_index_stripchars) { if (!o_index_stripchars) {
string lower; string lower;
if (!unacmaybefold(mterm, lower, "UTF-8", UNACOP_FOLD)) { if (!unacmaybefold(mterm, lower, "UTF-8", UNACOP_FOLD)) {
LOGERR(("Aspell::check : cant lowercase input\n")); LOGERR("Aspell::check : cant lowercase input\n" );
return false; return false;
} }
mterm.swap(lower); mterm.swap(lower);
@ -413,7 +413,7 @@ bool Aspell::suggest(Rcl::Db &db, const string &_term,
if (!o_index_stripchars) { if (!o_index_stripchars) {
string lower; string lower;
if (!unacmaybefold(mterm, lower, "UTF-8", UNACOP_FOLD)) { if (!unacmaybefold(mterm, lower, "UTF-8", UNACOP_FOLD)) {
LOGERR(("Aspell::check : cant lowercase input\n")); LOGERR("Aspell::check : cant lowercase input\n" );
return false; return false;
} }
mterm.swap(lower); mterm.swap(lower);
@ -584,3 +584,4 @@ int main(int argc, char **argv)
#endif // RCL_USE_ASPELL #endif // RCL_USE_ASPELL
#endif // TEST_RCLASPELL test driver #endif // TEST_RCLASPELL test driver

View file

@ -20,7 +20,7 @@
#include "cstr.h" #include "cstr.h"
#include "beaglequeuecache.h" #include "beaglequeuecache.h"
#include "circache.h" #include "circache.h"
#include "debuglog.h" #include "log.h"
#include "rclconfig.h" #include "rclconfig.h"
#include "pathut.h" #include "pathut.h"
#include "rcldoc.h" #include "rcldoc.h"
@ -34,12 +34,11 @@ BeagleQueueCache::BeagleQueueCache(RclConfig *cnf)
int maxmbs = 40; int maxmbs = 40;
cnf->getConfParam("webcachemaxmbs", &maxmbs); cnf->getConfParam("webcachemaxmbs", &maxmbs);
if ((m_cache = new CirCache(ccdir)) == 0) { if ((m_cache = new CirCache(ccdir)) == 0) {
LOGERR(("BeagleQueueCache: cant create CirCache object\n")); LOGERR("BeagleQueueCache: cant create CirCache object\n" );
return; return;
} }
if (!m_cache->create(off_t(maxmbs)*1000*1024, CirCache::CC_CRUNIQUE)) { if (!m_cache->create(off_t(maxmbs)*1000*1024, CirCache::CC_CRUNIQUE)) {
LOGERR(("BeagleQueueCache: cache file creation failed: %s\n", LOGERR("BeagleQueueCache: cache file creation failed: " << (m_cache->getReason()) << "\n" );
m_cache->getReason().c_str()));
delete m_cache; delete m_cache;
m_cache = 0; m_cache = 0;
return; return;
@ -59,11 +58,11 @@ bool BeagleQueueCache::getFromCache(const string& udi, Rcl::Doc &dotdoc,
string dict; string dict;
if (m_cache == 0) { if (m_cache == 0) {
LOGERR(("BeagleQueueCache::getFromCache: cache is null\n")); LOGERR("BeagleQueueCache::getFromCache: cache is null\n" );
return false; return false;
} }
if (!m_cache->get(udi, dict, &data)) { if (!m_cache->get(udi, dict, &data)) {
LOGDEB(("BeagleQueueCache::getFromCache: get failed\n")); LOGDEB("BeagleQueueCache::getFromCache: get failed\n" );
return false; return false;
} }
@ -86,3 +85,4 @@ bool BeagleQueueCache::getFromCache(const string& udi, Rcl::Doc &dotdoc,
dotdoc.meta[Rcl::Doc::keyudi] = udi; dotdoc.meta[Rcl::Doc::keyudi] = udi;
return true; return true;
} }

View file

@ -29,7 +29,6 @@
#ifdef _WIN32 #ifdef _WIN32
#include "safewindows.h" #include "safewindows.h"
#undef RCL_ICONV_INBUF_CONST
#ifdef _MSC_VER #ifdef _MSC_VER
// gmtime is supposedly thread-safe on windows // gmtime is supposedly thread-safe on windows
@ -47,15 +46,15 @@ typedef int mode_t;
#else // End _MSC_VER -> Gminw #else // End _MSC_VER -> Gminw
#define timegm portable_timegm
#undef RCL_ICONV_INBUF_CONST #undef RCL_ICONV_INBUF_CONST
#define timegm portable_timegm
#endif // GMinw only #endif // GMinw only
typedef int pid_t; typedef int pid_t;
inline int readlink(const char *cp, void *buf, int cnt) { inline int readlink(const char *cp, void *buf, int cnt)
return -1; {
return -1;
} }
#define MAXPATHLEN PATH_MAX #define MAXPATHLEN PATH_MAX
@ -72,9 +71,8 @@ typedef int ssize_t;
#ifndef X_OK #ifndef X_OK
#define X_OK 4 #define X_OK 4
#endif #endif
#define RECOLL_DATADIR "C:\\recoll\\"
#define S_ISLNK(X) false #define S_ISLNK(X) false
#define lstat stat #define lstat stat
#endif
#endif // _WIN32

View file

@ -42,7 +42,7 @@
#include "rclutil.h" #include "rclutil.h"
#include "rclconfig.h" #include "rclconfig.h"
#include "conftree.h" #include "conftree.h"
#include "debuglog.h" #include "log.h"
#include "smallut.h" #include "smallut.h"
#include "textsplit.h" #include "textsplit.h"
#include "readfile.h" #include "readfile.h"
@ -67,10 +67,9 @@ string RclConfig::o_origcwd;
bool ParamStale::needrecompute() bool ParamStale::needrecompute()
{ {
LOGDEB2(("ParamStale:: needrecompute. parent gen %d mine %d\n", LOGDEB2("ParamStale:: needrecompute. parent gen " << (parent->m_keydirgen) << " mine " << (savedkeydirgen) << "\n" );
parent->m_keydirgen, savedkeydirgen));
if (active && parent->m_keydirgen != savedkeydirgen) { if (active && parent->m_keydirgen != savedkeydirgen) {
LOGDEB2(("ParamState:: needrecompute. conffile %p\n", conffile)); LOGDEB2("ParamState:: needrecompute. conffile " << (conffile) << "\n" );
savedkeydirgen = parent->m_keydirgen; savedkeydirgen = parent->m_keydirgen;
string newvalue; string newvalue;
@ -79,8 +78,7 @@ bool ParamStale::needrecompute()
conffile->get(paramname, newvalue, parent->m_keydir); conffile->get(paramname, newvalue, parent->m_keydir);
if (newvalue.compare(savedvalue)) { if (newvalue.compare(savedvalue)) {
savedvalue = newvalue; savedvalue = newvalue;
LOGDEB2(("ParamState:: needrecompute. return true newvalue [%s]\n", LOGDEB2("ParamState:: needrecompute. return true newvalue [" << (newvalue) << "]\n" );
newvalue.c_str()));
return true; return true;
} }
} }
@ -216,8 +214,7 @@ RclConfig::RclConfig(const string *argcnf)
// interface, Windows will never use utf-8 // interface, Windows will never use utf-8
o_localecharset = "UTF-8"; o_localecharset = "UTF-8";
#endif #endif
LOGDEB1(("RclConfig::getDefCharset: localecharset [%s]\n", LOGDEB1("RclConfig::getDefCharset: localecharset [" << (o_localecharset) << "]\n" );
o_localecharset.c_str()));
} }
const char *cp; const char *cp;
@ -425,8 +422,7 @@ bool RclConfig::getConfParam(const string &name, vector<int> *vip,
char *ep; char *ep;
vip->push_back(strtol(vs[i].c_str(), &ep, 0)); vip->push_back(strtol(vs[i].c_str(), &ep, 0));
if (ep == vs[i].c_str()) { if (ep == vs[i].c_str()) {
LOGDEB(("RclConfig::getConfParam: bad int value in [%s]\n", LOGDEB("RclConfig::getConfParam: bad int value in [" << (name) << "]\n" );
name.c_str()));
return false; return false;
} }
} }
@ -442,16 +438,16 @@ void RclConfig::initThrConf()
vector<int> vq; vector<int> vq;
vector<int> vt; vector<int> vt;
if (!getConfParam("thrQSizes", &vq)) { if (!getConfParam("thrQSizes", &vq)) {
LOGINFO(("RclConfig::initThrConf: no thread info (queues)\n")); LOGINFO("RclConfig::initThrConf: no thread info (queues)\n" );
goto out; goto out;
} }
// If the first queue size is 0, autoconf is requested. // If the first queue size is 0, autoconf is requested.
if (vq.size() > 0 && vq[0] == 0) { if (vq.size() > 0 && vq[0] == 0) {
LOGDEB(("RclConfig::initThrConf: autoconf requested\n")); LOGDEB("RclConfig::initThrConf: autoconf requested\n" );
CpuConf cpus; CpuConf cpus;
if (!getCpuConf(cpus) || cpus.ncpus < 1) { if (!getCpuConf(cpus) || cpus.ncpus < 1) {
LOGERR(("RclConfig::initThrConf: could not retrieve cpu conf\n")); LOGERR("RclConfig::initThrConf: could not retrieve cpu conf\n" );
cpus.ncpus = 1; cpus.ncpus = 1;
} }
// Arbitrarily set threads config based on number of CPUS. This also // Arbitrarily set threads config based on number of CPUS. This also
@ -477,12 +473,12 @@ void RclConfig::initThrConf()
} }
if (!getConfParam("thrTCounts", &vt) ) { if (!getConfParam("thrTCounts", &vt) ) {
LOGINFO(("RclConfig::initThrConf: no thread info (threads)\n")); LOGINFO("RclConfig::initThrConf: no thread info (threads)\n" );
goto out; goto out;
} }
if (vq.size() != 3 || vt.size() != 3) { if (vq.size() != 3 || vt.size() != 3) {
LOGINFO(("RclConfig::initThrConf: bad thread info vector sizes\n")); LOGINFO("RclConfig::initThrConf: bad thread info vector sizes\n" );
goto out; goto out;
} }
@ -499,14 +495,13 @@ out:
") "; ") ";
} }
LOGDEB(("RclConfig::initThrConf: chosen config (ql,nt): %s\n", LOGDEB("RclConfig::initThrConf: chosen config (ql,nt): " << (sconf.str()) << "\n" );
sconf.str().c_str()));
} }
pair<int,int> RclConfig::getThrConf(ThrStage who) const pair<int,int> RclConfig::getThrConf(ThrStage who) const
{ {
if (m_thrConf.size() != 3) { if (m_thrConf.size() != 3) {
LOGERR(("RclConfig::getThrConf: bad data in rclconfig\n")); LOGERR("RclConfig::getThrConf: bad data in rclconfig\n" );
return pair<int,int>(-1,-1); return pair<int,int>(-1,-1);
} }
return m_thrConf[who]; return m_thrConf[who];
@ -516,8 +511,7 @@ vector<string> RclConfig::getTopdirs() const
{ {
vector<string> tdl; vector<string> tdl;
if (!getConfParam("topdirs", &tdl)) { if (!getConfParam("topdirs", &tdl)) {
LOGERR(("RclConfig::getTopdirs: no top directories in config or " LOGERR("RclConfig::getTopdirs: no top directories in config or bad list format\n" );
"bad list format\n"));
return tdl; return tdl;
} }
@ -601,7 +595,7 @@ typedef multiset<SfString, SuffCmp> SuffixStore;
bool RclConfig::inStopSuffixes(const string& fni) bool RclConfig::inStopSuffixes(const string& fni)
{ {
LOGDEB2(("RclConfig::inStopSuffixes(%s)\n", fni.c_str())); LOGDEB2("RclConfig::inStopSuffixes(" << (fni) << ")\n" );
// Beware: both needrecompute() need to be called always hence the // Beware: both needrecompute() need to be called always hence the
// bizarre way we do things // bizarre way we do things
bool needrecompute = m_stpsuffstate.needrecompute(); bool needrecompute = m_stpsuffstate.needrecompute();
@ -610,7 +604,7 @@ bool RclConfig::inStopSuffixes(const string& fni)
// Need to initialize the suffixes // Need to initialize the suffixes
delete STOPSUFFIXES; delete STOPSUFFIXES;
if ((m_stopsuffixes = new SuffixStore) == 0) { if ((m_stopsuffixes = new SuffixStore) == 0) {
LOGERR(("RclConfig::inStopSuffixes: out of memory\n")); LOGERR("RclConfig::inStopSuffixes: out of memory\n" );
return false; return false;
} }
// Let the old customisation have priority: if recoll_noindex // Let the old customisation have priority: if recoll_noindex
@ -637,11 +631,10 @@ bool RclConfig::inStopSuffixes(const string& fni)
stringtolower(fn); stringtolower(fn);
SuffixStore::const_iterator it = STOPSUFFIXES->find(fn); SuffixStore::const_iterator it = STOPSUFFIXES->find(fn);
if (it != STOPSUFFIXES->end()) { if (it != STOPSUFFIXES->end()) {
LOGDEB2(("RclConfig::inStopSuffixes: Found (%s) [%s]\n", LOGDEB2("RclConfig::inStopSuffixes: Found (" << (fni) << ") [" << ((*it).m_str) << "]\n" );
fni.c_str(), (*it).m_str.c_str()));
return true; return true;
} else { } else {
LOGDEB2(("RclConfig::inStopSuffixes: not found [%s]\n", fni.c_str())); LOGDEB2("RclConfig::inStopSuffixes: not found [" << (fni) << "]\n" );
return false; return false;
} }
} }
@ -718,18 +711,18 @@ string RclConfig::getMimeHandlerDef(const string &mtype, bool filtertypes)
} }
if (!m_restrictMTypes.empty() && if (!m_restrictMTypes.empty() &&
!m_restrictMTypes.count(stringtolower(mtype))) { !m_restrictMTypes.count(stringtolower(mtype))) {
LOGDEB2(("RclConfig::getMimeHandlerDef: not in mime type list\n")); LOGDEB2("RclConfig::getMimeHandlerDef: not in mime type list\n" );
return hs; return hs;
} }
if (!m_excludeMTypes.empty() && if (!m_excludeMTypes.empty() &&
m_excludeMTypes.count(stringtolower(mtype))) { m_excludeMTypes.count(stringtolower(mtype))) {
LOGDEB2(("RclConfig::getMimeHandlerDef: in excluded mime list\n")); LOGDEB2("RclConfig::getMimeHandlerDef: in excluded mime list\n" );
return hs; return hs;
} }
} }
if (!mimeconf->get(mtype, hs, "index")) { if (!mimeconf->get(mtype, hs, "index")) {
LOGDEB1(("getMimeHandler: no handler for '%s'\n", mtype.c_str())); LOGDEB1("getMimeHandler: no handler for '" << (mtype) << "'\n" );
} }
return hs; return hs;
} }
@ -820,7 +813,7 @@ void RclConfig::storeMissingHelperDesc(const string &s)
FILE *fp = fopen(fmiss.c_str(), "w"); FILE *fp = fopen(fmiss.c_str(), "w");
if (fp) { if (fp) {
if (s.size() > 0 && fwrite(s.c_str(), s.size(), 1, fp) != 1) { if (s.size() > 0 && fwrite(s.c_str(), s.size(), 1, fp) != 1) {
LOGERR(("storeMissingHelperDesc: fwrite failed\n")); LOGERR("storeMissingHelperDesc: fwrite failed\n" );
} }
fclose(fp); fclose(fp);
} }
@ -830,7 +823,7 @@ void RclConfig::storeMissingHelperDesc(const string &s)
// things for speed (theses are used a lot during indexing) // things for speed (theses are used a lot during indexing)
bool RclConfig::readFieldsConfig(const string& cnferrloc) bool RclConfig::readFieldsConfig(const string& cnferrloc)
{ {
LOGDEB2(("RclConfig::readFieldsConfig\n")); LOGDEB2("RclConfig::readFieldsConfig\n" );
m_fields = new ConfStack<ConfSimple>("fields", m_cdirs, true); m_fields = new ConfStack<ConfSimple>("fields", m_cdirs, true);
if (m_fields == 0 || !m_fields->ok()) { if (m_fields == 0 || !m_fields->ok()) {
m_reason = string("No/bad fields file in: ") + cnferrloc; m_reason = string("No/bad fields file in: ") + cnferrloc;
@ -848,8 +841,7 @@ bool RclConfig::readFieldsConfig(const string& cnferrloc)
ConfSimple attrs; ConfSimple attrs;
FieldTraits ft; FieldTraits ft;
if (!valueSplitAttributes(val, ft.pfx, attrs)) { if (!valueSplitAttributes(val, ft.pfx, attrs)) {
LOGERR(("readFieldsConfig: bad config line for [%s]: [%s]\n", LOGERR("readFieldsConfig: bad config line for [" << *it << "]: [" << (val) << "]\n" );
it->c_str(), val.c_str()));
return 0; return 0;
} }
string tval; string tval;
@ -862,8 +854,7 @@ bool RclConfig::readFieldsConfig(const string& cnferrloc)
if (attrs.get("noterms", tval)) if (attrs.get("noterms", tval))
ft.noterms = stringToBool(tval); ft.noterms = stringToBool(tval);
m_fldtotraits[stringtolower(*it)] = ft; m_fldtotraits[stringtolower(*it)] = ft;
LOGDEB2(("readFieldsConfig: [%s] -> [%s] %d %.1f\n", LOGDEB2("readFieldsConfig: [" << *it << "] -> [" << (ft.pfx) << "] " << (ft.wdfinc) << " " << (ft.boost) << "\n" );
it->c_str(), ft.pfx.c_str(), ft.wdfinc, ft.boost));
} }
// Add prefixes for aliases and build alias-to-canonic map while // Add prefixes for aliases and build alias-to-canonic map while
@ -909,9 +900,7 @@ bool RclConfig::readFieldsConfig(const string& cnferrloc)
#if 0 #if 0
for (map<string, FieldTraits>::const_iterator it = m_fldtotraits.begin(); for (map<string, FieldTraits>::const_iterator it = m_fldtotraits.begin();
it != m_fldtotraits.end(); it++) { it != m_fldtotraits.end(); it++) {
LOGDEB(("readFieldsConfig: [%s] -> [%s] %d %.1f\n", LOGDEB("readFieldsConfig: [" << *it << "] -> [" << (it->second.pfx) << "] " << (it->second.wdfinc) << " " << (it->second.boost) << "\n" );
it->c_str(), it->second.pfx.c_str(), it->second.wdfinc,
it->second.boost));
} }
#endif #endif
@ -944,12 +933,10 @@ bool RclConfig::getFieldTraits(const string& _fld, const FieldTraits **ftpp,
map<string, FieldTraits>::const_iterator pit = m_fldtotraits.find(fld); map<string, FieldTraits>::const_iterator pit = m_fldtotraits.find(fld);
if (pit != m_fldtotraits.end()) { if (pit != m_fldtotraits.end()) {
*ftpp = &pit->second; *ftpp = &pit->second;
LOGDEB1(("RclConfig::getFieldTraits: [%s]->[%s]\n", LOGDEB1("RclConfig::getFieldTraits: [" << (_fld) << "]->[" << (pit->second.pfx) << "]\n" );
_fld.c_str(), pit->second.pfx.c_str()));
return true; return true;
} else { } else {
LOGDEB1(("RclConfig::getFieldTraits: no prefix for field [%s]\n", LOGDEB1("RclConfig::getFieldTraits: no prefix for field [" << (fld) << "]\n" );
fld.c_str()));
*ftpp = 0; *ftpp = 0;
return false; return false;
} }
@ -971,11 +958,10 @@ string RclConfig::fieldCanon(const string& f) const
string fld = stringtolower(f); string fld = stringtolower(f);
map<string, string>::const_iterator it = m_aliastocanon.find(fld); map<string, string>::const_iterator it = m_aliastocanon.find(fld);
if (it != m_aliastocanon.end()) { if (it != m_aliastocanon.end()) {
LOGDEB1(("RclConfig::fieldCanon: [%s] -> [%s]\n", LOGDEB1("RclConfig::fieldCanon: [" << (f) << "] -> [" << (it->second) << "]\n" );
f.c_str(), it->second.c_str()));
return it->second; return it->second;
} }
LOGDEB1(("RclConfig::fieldCanon: [%s] -> [%s]\n", f.c_str(), fld.c_str())); LOGDEB1("RclConfig::fieldCanon: [" << (f) << "] -> [" << (fld) << "]\n" );
return fld; return fld;
} }
@ -984,8 +970,7 @@ string RclConfig::fieldQCanon(const string& f) const
string fld = stringtolower(f); string fld = stringtolower(f);
map<string, string>::const_iterator it = m_aliastoqcanon.find(fld); map<string, string>::const_iterator it = m_aliastoqcanon.find(fld);
if (it != m_aliastoqcanon.end()) { if (it != m_aliastoqcanon.end()) {
LOGDEB1(("RclConfig::fieldQCanon: [%s] -> [%s]\n", LOGDEB1("RclConfig::fieldQCanon: [" << (f) << "] -> [" << (it->second) << "]\n" );
f.c_str(), it->second.c_str()));
return it->second; return it->second;
} }
return fieldCanon(f); return fieldCanon(f);
@ -1031,8 +1016,7 @@ bool RclConfig::setMimeViewerAllEx(const string& allex)
string RclConfig::getMimeViewerDef(const string &mtype, const string& apptag, string RclConfig::getMimeViewerDef(const string &mtype, const string& apptag,
bool useall) const bool useall) const
{ {
LOGDEB2(("RclConfig::getMimeViewerDef: mtype [%s] apptag [%s]\n", LOGDEB2("RclConfig::getMimeViewerDef: mtype [" << (mtype) << "] apptag [" << (apptag) << "]\n" );
mtype.c_str(), apptag.c_str()));
string hs; string hs;
if (mimeview == 0) if (mimeview == 0)
return hs; return hs;
@ -1216,19 +1200,17 @@ string RclConfig::getPidfile() const
void RclConfig::urlrewrite(const string& dbdir, string& url) const void RclConfig::urlrewrite(const string& dbdir, string& url) const
{ {
LOGDEB2(("RclConfig::urlrewrite: dbdir [%s] url [%s]\n", LOGDEB2("RclConfig::urlrewrite: dbdir [" << (dbdir) << "] url [" << (url) << "]\n" );
dbdir.c_str(), url.c_str()));
// Do path translations exist for this index ? // Do path translations exist for this index ?
if (m_ptrans == 0 || !m_ptrans->hasSubKey(dbdir)) { if (m_ptrans == 0 || !m_ptrans->hasSubKey(dbdir)) {
LOGDEB2(("RclConfig::urlrewrite: no paths translations (m_ptrans %p)\n", LOGDEB2("RclConfig::urlrewrite: no paths translations (m_ptrans " << (m_ptrans) << ")\n" );
m_ptrans));
return; return;
} }
string path = fileurltolocalpath(url); string path = fileurltolocalpath(url);
if (path.empty()) { if (path.empty()) {
LOGDEB2(("RclConfig::urlrewrite: not file url\n")); LOGDEB2("RclConfig::urlrewrite: not file url\n" );
return; return;
} }
@ -1387,7 +1369,7 @@ bool RclConfig::getUncompressor(const string &mtype, vector<string>& cmd) const
vector<string> tokens; vector<string> tokens;
stringToStrings(hs, tokens); stringToStrings(hs, tokens);
if (tokens.empty()) { if (tokens.empty()) {
LOGERR(("getUncompressor: empty spec for mtype %s\n", mtype.c_str())); LOGERR("getUncompressor: empty spec for mtype " << (mtype) << "\n" );
return false; return false;
} }
vector<string>::iterator it = tokens.begin(); vector<string>::iterator it = tokens.begin();
@ -1405,7 +1387,7 @@ bool RclConfig::getUncompressor(const string &mtype, vector<string>& cmd) const
if (!stringlowercmp("python", *it) || !stringlowercmp("perl", *it)) { if (!stringlowercmp("python", *it) || !stringlowercmp("perl", *it)) {
it++; it++;
if (tokens.size() < 3) { if (tokens.size() < 3) {
LOGERR(("getUncpressor: python/perl cmd: no script?. [%s]\n", mtype.c_str())); LOGERR("getUncpressor: python/perl cmd: no script?. [" << (mtype) << "]\n" );
} else { } else {
*it = findFilter(*it); *it = findFilter(*it);
} }
@ -1552,7 +1534,8 @@ void RclConfig::initParamStale(ConfNull *cnf, ConfNull *mimemap)
using namespace std; using namespace std;
#include "debuglog.h" #include "log.h"
#include "rclinit.h" #include "rclinit.h"
#include "rclconfig.h" #include "rclconfig.h"
#include "cstr.h" #include "cstr.h"
@ -1727,3 +1710,4 @@ int main(int argc, char **argv)
} }
#endif // TEST_RCLCONFIG #endif // TEST_RCLCONFIG

View file

@ -315,7 +315,7 @@ class RclConfig {
string findFilter(const string& cmd) const; string findFilter(const string& cmd) const;
/** Thread config init is not done automatically because not all /** Thread config init is not done automatically because not all
programs need it and it uses debuglog so that it's better to programs need it and it uses the debug log so that it's better to
call it after primary init */ call it after primary init */
void initThrConf(); void initThrConf();

View file

@ -28,7 +28,7 @@
#include <string.h> #include <string.h>
#endif #endif
#include "debuglog.h" #include "log.h"
#include "rclconfig.h" #include "rclconfig.h"
#include "rclinit.h" #include "rclinit.h"
#include "pathut.h" #include "pathut.h"
@ -60,7 +60,7 @@ static pthread_t mainthread_id;
static void siglogreopen(int) static void siglogreopen(int)
{ {
if (recoll_ismainthread()) if (recoll_ismainthread())
DebugLog::reopen(); Logger::getTheLog("")->reopen("");
} }
// We would like to block SIGCHLD globally, but we can't because // We would like to block SIGCHLD globally, but we can't because
@ -258,10 +258,7 @@ RclConfig *recollinit(RclInitFlags flags,
// to utf8 for indexing. // to utf8 for indexing.
setlocale(LC_CTYPE, ""); setlocale(LC_CTYPE, "");
DebugLog::getdbl()->setloglevel(DEBDEB1); Logger::getTheLog("")->setLogLevel(Logger::LLDEB1);
DebugLog::setfilename("stderr");
if (getenv("RECOLL_LOGDATE"))
DebugLog::getdbl()->logdate(1);
initAsyncSigs(sigcleanup); initAsyncSigs(sigcleanup);
@ -297,15 +294,15 @@ RclConfig *recollinit(RclInitFlags flags,
if (!logfilename.empty()) { if (!logfilename.empty()) {
logfilename = path_tildexpand(logfilename); logfilename = path_tildexpand(logfilename);
// If not an absolute path or , compute relative to config dir // If not an absolute path or , compute relative to config dir
if (!path_isabsolute(logfilename) && if (!path_isabsolute(logfilename) &&
!DebugLog::DebugLog::isspecialname(logfilename.c_str())) { logfilename.compare("stderr")) {
logfilename = path_cat(config->getConfDir(), logfilename); logfilename = path_cat(config->getConfDir(), logfilename);
} }
DebugLog::setfilename(logfilename.c_str()); Logger::getTheLog("")->reopen(logfilename);
} }
if (!loglevel.empty()) { if (!loglevel.empty()) {
int lev = atoi(loglevel.c_str()); int lev = atoi(loglevel.c_str());
DebugLog::getdbl()->setloglevel(lev); Logger::getTheLog("")->setLogLevel(Logger::LogLevel(lev));
} }
// Make sure the locale charset is initialized (so that multiple // Make sure the locale charset is initialized (so that multiple

View file

@ -19,7 +19,7 @@
#include "syngroups.h" #include "syngroups.h"
#include "debuglog.h" #include "log.h"
#include "smallut.h" #include "smallut.h"
#include <errno.h> #include <errno.h>
@ -68,11 +68,11 @@ SynGroups::SynGroups()
bool SynGroups::setfile(const string& fn) bool SynGroups::setfile(const string& fn)
{ {
LOGDEB(("SynGroups::setfile(%s)\n", fn.c_str())); LOGDEB("SynGroups::setfile(" << (fn) << ")\n" );
if (!m) { if (!m) {
m = new Internal; m = new Internal;
if (!m) { if (!m) {
LOGERR(("SynGroups:setfile:: new Internal failed: no mem ?\n")); LOGERR("SynGroups:setfile:: new Internal failed: no mem ?\n" );
return false; return false;
} }
} }
@ -86,8 +86,7 @@ bool SynGroups::setfile(const string& fn)
ifstream input; ifstream input;
input.open(fn.c_str(), ios::in); input.open(fn.c_str(), ios::in);
if (!input.is_open()) { if (!input.is_open()) {
LOGERR(("SynGroups:setfile:: could not open %s errno %d\n", LOGERR("SynGroups:setfile:: could not open " << (fn) << " errno " << (errno) << "\n" );
fn.c_str(), errno));
return false; return false;
} }
@ -102,8 +101,7 @@ bool SynGroups::setfile(const string& fn)
getline(input, cline); getline(input, cline);
if (!input.good()) { if (!input.good()) {
if (input.bad()) { if (input.bad()) {
LOGERR(("Syngroup::setfile(%s):Parse: input.bad()\n", LOGERR("Syngroup::setfile(" << (fn) << "):Parse: input.bad()\n" );
fn.c_str()));
return false; return false;
} }
// Must be eof ? But maybe we have a partial line which // Must be eof ? But maybe we have a partial line which
@ -144,16 +142,14 @@ bool SynGroups::setfile(const string& fn)
vector<string> words; vector<string> words;
if (!stringToStrings(line, words)) { if (!stringToStrings(line, words)) {
LOGERR(("SynGroups:setfile: %s: bad line %d: %s\n", LOGERR("SynGroups:setfile: " << (fn) << ": bad line " << (lnum) << ": " << (line) << "\n" );
fn.c_str(), lnum, line.c_str()));
continue; continue;
} }
if (words.empty()) if (words.empty())
continue; continue;
if (words.size() == 1) { if (words.size() == 1) {
LOGERR(("Syngroup::setfile(%s):single term group at line %d ??\n", LOGERR("Syngroup::setfile(" << (fn) << "):single term group at line " << (lnum) << " ??\n" );
fn.c_str(), lnum));
continue; continue;
} }
@ -162,8 +158,7 @@ bool SynGroups::setfile(const string& fn)
it != words.end(); it++) { it != words.end(); it++) {
m->terms[*it] = m->groups.size()-1; m->terms[*it] = m->groups.size()-1;
} }
LOGDEB1(("SynGroups::setfile: group: [%s]\n", LOGDEB1("SynGroups::setfile: group: [" << (stringsToString(m->groups.back())) << "]\n" );
stringsToString(m->groups.back()).c_str()));
} }
m->ok = true; m->ok = true;
return true; return true;
@ -178,14 +173,13 @@ vector<string> SynGroups::getgroup(const string& term)
STD_UNORDERED_MAP<string, unsigned int>::const_iterator it1 = STD_UNORDERED_MAP<string, unsigned int>::const_iterator it1 =
m->terms.find(term); m->terms.find(term);
if (it1 == m->terms.end()) { if (it1 == m->terms.end()) {
LOGDEB1(("SynGroups::getgroup: [%s] not found in direct map\n", LOGDEB1("SynGroups::getgroup: [" << (term) << "] not found in direct map\n" );
term.c_str()));
return ret; return ret;
} }
unsigned int idx = it1->second; unsigned int idx = it1->second;
if (idx >= m->groups.size()) { if (idx >= m->groups.size()) {
LOGERR(("SynGroups::getgroup: line index higher than line count !\n")); LOGERR("SynGroups::getgroup: line index higher than line count !\n" );
return ret; return ret;
} }
return m->groups[idx]; return m->groups[idx];
@ -194,7 +188,8 @@ vector<string> SynGroups::getgroup(const string& term)
#else #else
#include "syngroups.h" #include "syngroups.h"
#include "debuglog.h" #include "log.h"
#include <string> #include <string>
#include <iostream> #include <iostream>
@ -252,3 +247,4 @@ int main(int argc, char **argv)
} }
#endif #endif

View file

@ -27,7 +27,7 @@
#include UNORDERED_SET_INCLUDE #include UNORDERED_SET_INCLUDE
#include "textsplit.h" #include "textsplit.h"
#include "debuglog.h" #include "log.h"
//#define UTF8ITER_CHECK //#define UTF8ITER_CHECK
#include "utf8iter.h" #include "utf8iter.h"
#include "uproplist.h" #include "uproplist.h"
@ -221,7 +221,7 @@ bool TextSplit::o_deHyphenate = false;
inline bool TextSplit::emitterm(bool isspan, string &w, int pos, inline bool TextSplit::emitterm(bool isspan, string &w, int pos,
size_t btstart, size_t btend) size_t btstart, size_t btend)
{ {
LOGDEB2(("TextSplit::emitterm: [%s] pos %d\n", w.c_str(), pos)); LOGDEB2("TextSplit::emitterm: [" << (w) << "] pos " << (pos) << "\n" );
int l = int(w.length()); int l = int(w.length());
@ -252,7 +252,7 @@ inline bool TextSplit::emitterm(bool isspan, string &w, int pos,
m_prevlen = int(w.length()); m_prevlen = int(w.length());
return ret; return ret;
} }
LOGDEB2(("TextSplit::emitterm:dup: [%s] pos %d\n", w.c_str(), pos)); LOGDEB2("TextSplit::emitterm:dup: [" << (w) << "] pos " << (pos) << "\n" );
} }
return true; return true;
} }
@ -369,10 +369,7 @@ bool TextSplit::words_from_span(size_t bp)
inline bool TextSplit::doemit(bool spanerase, size_t _bp) inline bool TextSplit::doemit(bool spanerase, size_t _bp)
{ {
int bp = int(_bp); int bp = int(_bp);
LOGDEB2(("TextSplit::doemit: sper %d bp %d spp %d spanwords %u wS %d wL %d " LOGDEB2("TextSplit::doemit: sper " << (spanerase) << " bp " << (bp) << " spp " << (m_spanpos) << " spanwords " << (m_words_in_span.size()) << " wS " << (m_wordStart) << " wL " << (m_wordLen) << " inn " << (m_inNumber) << " span [" << (m_span) << "]\n" );
"inn %d span [%s]\n",
spanerase, bp, m_spanpos, m_words_in_span.size(),
m_wordStart, m_wordLen, m_inNumber, m_span.c_str()));
if (m_wordLen) { if (m_wordLen) {
// We have a current word. Remember it // We have a current word. Remember it
@ -468,12 +465,12 @@ static inline bool isdigit(int what, unsigned int flgs)
*/ */
bool TextSplit::text_to_words(const string &in) bool TextSplit::text_to_words(const string &in)
{ {
LOGDEB1(("TextSplit::text_to_words: docjk %d (%d) %s%s%s [%s]\n", LOGDEB1("TextSplit::text_to_words: docjk " << o_processCJK << "(" <<
o_processCJK, o_CJKNgramLen, o_CJKNgramLen << ")" <<
m_flags & TXTS_NOSPANS ? " nospans" : "", (m_flags & TXTS_NOSPANS ? " nospans" : "") <<
m_flags & TXTS_ONLYSPANS ? " onlyspans" : "", (m_flags & TXTS_ONLYSPANS ? " onlyspans" : "") <<
m_flags & TXTS_KEEPWILD ? " keepwild" : "", (m_flags & TXTS_KEEPWILD ? " keepwild" : "") <<
in.substr(0,50).c_str())); "[" << in.substr(0,50) << "]\n");
if (in.empty()) if (in.empty())
return true; return true;
@ -495,7 +492,7 @@ bool TextSplit::text_to_words(const string &in)
nonalnumcnt++; nonalnumcnt++;
if (c == (unsigned int)-1) { if (c == (unsigned int)-1) {
LOGERR(("Textsplit: error occured while scanning UTF-8 string\n")); LOGERR("Textsplit: error occured while scanning UTF-8 string\n" );
return false; return false;
} }
@ -509,7 +506,7 @@ bool TextSplit::text_to_words(const string &in)
// Hand off situation to the cjk routine. // Hand off situation to the cjk routine.
if (!cjk_to_words(&it, &c)) { if (!cjk_to_words(&it, &c)) {
LOGERR(("Textsplit: scan error in cjk handler\n")); LOGERR("Textsplit: scan error in cjk handler\n" );
return false; return false;
} }
@ -805,7 +802,7 @@ bool TextSplit::text_to_words(const string &in)
// be better off converting the whole buffer to utf32 on entry... // be better off converting the whole buffer to utf32 on entry...
bool TextSplit::cjk_to_words(Utf8Iter *itp, unsigned int *cp) bool TextSplit::cjk_to_words(Utf8Iter *itp, unsigned int *cp)
{ {
LOGDEB1(("cjk_to_words: m_wordpos %d\n", m_wordpos)); LOGDEB1("cjk_to_words: m_wordpos " << (m_wordpos) << "\n" );
Utf8Iter &it = *itp; Utf8Iter &it = *itp;
// We use an offset buffer to remember the starts of the utf-8 // We use an offset buffer to remember the starts of the utf-8
@ -908,9 +905,8 @@ bool TextSplit::hasVisibleWhite(const string &in)
Utf8Iter it(in); Utf8Iter it(in);
for (; !it.eof(); it++) { for (; !it.eof(); it++) {
unsigned int c = (unsigned char)*it; unsigned int c = (unsigned char)*it;
LOGDEB3(("TextSplit::hasVisibleWhite: testing 0x%04x\n", c));
if (c == (unsigned int)-1) { if (c == (unsigned int)-1) {
LOGERR(("hasVisibleWhite: error while scanning UTF-8 string\n")); LOGERR("hasVisibleWhite: error while scanning UTF-8 string\n" );
return false; return false;
} }
if (visiblewhite.find(c) != visiblewhite.end()) if (visiblewhite.find(c) != visiblewhite.end())
@ -931,10 +927,8 @@ template <class T> bool u8stringToStrings(const string &s, T &tokens)
unsigned int c = *it; unsigned int c = *it;
if (visiblewhite.find(c) != visiblewhite.end()) if (visiblewhite.find(c) != visiblewhite.end())
c = ' '; c = ' ';
LOGDEB3(("TextSplit::stringToStrings: 0x%04x\n", c));
if (c == (unsigned int)-1) { if (c == (unsigned int)-1) {
LOGERR(("TextSplit::stringToStrings: error while " LOGERR("TextSplit::stringToStrings: error while scanning UTF-8 string\n" );
"scanning UTF-8 string\n"));
return false; return false;
} }
@ -1011,7 +1005,8 @@ bool TextSplit::stringToStrings(const string &s, vector<string> &tokens)
#include "textsplit.h" #include "textsplit.h"
#include "readfile.h" #include "readfile.h"
#include "debuglog.h" #include "log.h"
#include "transcode.h" #include "transcode.h"
#include "unacpp.h" #include "unacpp.h"
#include "termproc.h" #include "termproc.h"
@ -1244,3 +1239,4 @@ int main(int argc, char **argv)
} }
} }
#endif // TEST #endif // TEST

View file

@ -24,7 +24,7 @@
#include "unacpp.h" #include "unacpp.h"
#include "unac.h" #include "unac.h"
#include "debuglog.h" #include "log.h"
#include "utf8iter.h" #include "utf8iter.h"
bool unacmaybefold(const string &in, string &out, bool unacmaybefold(const string &in, string &out,
@ -68,7 +68,7 @@ bool unacmaybefold(const string &in, string &out,
// testing user-entered terms, so we don't really care. // testing user-entered terms, so we don't really care.
bool unaciscapital(const string& in) bool unaciscapital(const string& in)
{ {
LOGDEB2(("unaciscapital: [%s]\n", in.c_str())); LOGDEB2("unaciscapital: [" << (in) << "]\n" );
if (in.empty()) if (in.empty())
return false; return false;
Utf8Iter it(in); Utf8Iter it(in);
@ -77,7 +77,7 @@ bool unaciscapital(const string& in)
string lower; string lower;
if (!unacmaybefold(shorter, lower, "UTF-8", UNACOP_FOLD)) { if (!unacmaybefold(shorter, lower, "UTF-8", UNACOP_FOLD)) {
LOGINFO(("unaciscapital: unac/fold failed for [%s]\n", in.c_str())); LOGINFO("unaciscapital: unac/fold failed for [" << (in) << "]\n" );
return false; return false;
} }
Utf8Iter it1(lower); Utf8Iter it1(lower);
@ -88,13 +88,13 @@ bool unaciscapital(const string& in)
} }
bool unachasuppercase(const string& in) bool unachasuppercase(const string& in)
{ {
LOGDEB2(("unachasuppercase: [%s]\n", in.c_str())); LOGDEB2("unachasuppercase: [" << (in) << "]\n" );
if (in.empty()) if (in.empty())
return false; return false;
string lower; string lower;
if (!unacmaybefold(in, lower, "UTF-8", UNACOP_FOLD)) { if (!unacmaybefold(in, lower, "UTF-8", UNACOP_FOLD)) {
LOGINFO(("unachasuppercase: unac/fold failed for [%s]\n", in.c_str())); LOGINFO("unachasuppercase: unac/fold failed for [" << (in) << "]\n" );
return false; return false;
} }
if (lower != in) if (lower != in)
@ -104,13 +104,13 @@ bool unachasuppercase(const string& in)
} }
bool unachasaccents(const string& in) bool unachasaccents(const string& in)
{ {
LOGDEB2(("unachasaccents: [%s]\n", in.c_str())); LOGDEB2("unachasaccents: [" << (in) << "]\n" );
if (in.empty()) if (in.empty())
return false; return false;
string noac; string noac;
if (!unacmaybefold(in, noac, "UTF-8", UNACOP_UNAC)) { if (!unacmaybefold(in, noac, "UTF-8", UNACOP_UNAC)) {
LOGINFO(("unachasaccents: unac/unac failed for [%s]\n", in.c_str())); LOGINFO("unachasaccents: unac/unac failed for [" << (in) << "]\n" );
return false; return false;
} }
if (noac != in) if (noac != in)
@ -247,3 +247,4 @@ int main(int argc, char **argv)
} }
#endif #endif

View file

@ -24,7 +24,7 @@
#include "cstr.h" #include "cstr.h"
#include "pathut.h" #include "pathut.h"
#include "rclutil.h" #include "rclutil.h"
#include "debuglog.h" #include "log.h"
#include "fstreewalk.h" #include "fstreewalk.h"
#include "beaglequeue.h" #include "beaglequeue.h"
#include "beaglequeuecache.h" #include "beaglequeuecache.h"
@ -62,7 +62,7 @@ public:
m_input.getline(cline, LL-1); m_input.getline(cline, LL-1);
if (!m_input.good()) { if (!m_input.good()) {
if (m_input.bad()) { if (m_input.bad()) {
LOGERR(("beagleDotFileRead: input.bad()\n")); LOGERR("beagleDotFileRead: input.bad()\n" );
} }
return false; return false;
} }
@ -72,7 +72,7 @@ public:
ll--; ll--;
} }
line.assign(cline, ll); line.assign(cline, ll);
LOGDEB2(("BeagleDotFile:readLine: [%s]\n", line.c_str())); LOGDEB2("BeagleDotFile:readLine: [" << (line) << "]\n" );
return true; return true;
} }
@ -83,7 +83,7 @@ public:
m_input.open(m_fn.c_str(), ios::in); m_input.open(m_fn.c_str(), ios::in);
if (!m_input.good()) { if (!m_input.good()) {
LOGERR(("BeagleDotFile: open failed for [%s]\n", m_fn.c_str())); LOGERR("BeagleDotFile: open failed for [" << (m_fn) << "]\n" );
return false; return false;
} }
@ -185,7 +185,7 @@ BeagleQueueIndexer::BeagleQueueIndexer(RclConfig *cnf, Rcl::Db *db,
BeagleQueueIndexer::~BeagleQueueIndexer() BeagleQueueIndexer::~BeagleQueueIndexer()
{ {
LOGDEB(("BeagleQueueIndexer::~\n")); LOGDEB("BeagleQueueIndexer::~\n" );
deleteZ(m_cache); deleteZ(m_cache);
} }
@ -202,12 +202,12 @@ bool BeagleQueueIndexer::indexFromCache(const string& udi)
string hittype; string hittype;
if (!m_cache || !m_cache->getFromCache(udi, dotdoc, data, &hittype)) { if (!m_cache || !m_cache->getFromCache(udi, dotdoc, data, &hittype)) {
LOGERR(("BeagleQueueIndexer::indexFromCache: cache failed\n")); LOGERR("BeagleQueueIndexer::indexFromCache: cache failed\n" );
return false; return false;
} }
if (hittype.empty()) { if (hittype.empty()) {
LOGERR(("BeagleIndexer::index: cc entry has no hit type\n")); LOGERR("BeagleIndexer::index: cc entry has no hit type\n" );
return false; return false;
} }
@ -224,11 +224,11 @@ bool BeagleQueueIndexer::indexFromCache(const string& udi)
try { try {
fis = interner.internfile(doc); fis = interner.internfile(doc);
} catch (CancelExcept) { } catch (CancelExcept) {
LOGERR(("BeagleQueueIndexer: interrupted\n")); LOGERR("BeagleQueueIndexer: interrupted\n" );
return false; return false;
} }
if (fis != FileInterner::FIDone) { if (fis != FileInterner::FIDone) {
LOGERR(("BeagleQueueIndexer: bad status from internfile\n")); LOGERR("BeagleQueueIndexer: bad status from internfile\n" );
return false; return false;
} }
@ -257,15 +257,14 @@ bool BeagleQueueIndexer::index()
{ {
if (!m_db) if (!m_db)
return false; return false;
LOGDEB(("BeagleQueueIndexer::processqueue: [%s]\n", m_queuedir.c_str())); LOGDEB("BeagleQueueIndexer::processqueue: [" << (m_queuedir) << "]\n" );
m_config->setKeyDir(m_queuedir); m_config->setKeyDir(m_queuedir);
if (!path_makepath(m_queuedir, 0700)) { if (!path_makepath(m_queuedir, 0700)) {
LOGERR(("BeagleQueueIndexer:: can't create queuedir [%s] errno %d\n", LOGERR("BeagleQueueIndexer:: can't create queuedir [" << (m_queuedir) << "] errno " << (errno) << "\n" );
m_queuedir.c_str(), errno));
return false; return false;
} }
if (!m_cache || !m_cache->cc()) { if (!m_cache || !m_cache->cc()) {
LOGERR(("BeagleQueueIndexer: cache initialization failed\n")); LOGERR("BeagleQueueIndexer: cache initialization failed\n" );
return false; return false;
} }
CirCache *cc = m_cache->cc(); CirCache *cc = m_cache->cc();
@ -283,7 +282,7 @@ bool BeagleQueueIndexer::index()
do { do {
string udi; string udi;
if (!cc->getCurrentUdi(udi)) { if (!cc->getCurrentUdi(udi)) {
LOGERR(("BeagleQueueIndexer:: cache file damaged\n")); LOGERR("BeagleQueueIndexer:: cache file damaged\n" );
break; break;
} }
if (udi.empty()) if (udi.empty())
@ -296,7 +295,7 @@ bool BeagleQueueIndexer::index()
indexFromCache(udi); indexFromCache(udi);
updstatus(udi); updstatus(udi);
} catch (CancelExcept) { } catch (CancelExcept) {
LOGERR(("BeagleQueueIndexer: interrupted\n")); LOGERR("BeagleQueueIndexer: interrupted\n" );
return false; return false;
} }
} }
@ -308,17 +307,17 @@ bool BeagleQueueIndexer::index()
FsTreeWalker walker(FsTreeWalker::FtwNoRecurse); FsTreeWalker walker(FsTreeWalker::FtwNoRecurse);
walker.addSkippedName(".*"); walker.addSkippedName(".*");
FsTreeWalker::Status status = walker.walk(m_queuedir, *this); FsTreeWalker::Status status = walker.walk(m_queuedir, *this);
LOGDEB(("BeagleQueueIndexer::processqueue: done: status %d\n", status)); LOGDEB("BeagleQueueIndexer::processqueue: done: status " << (status) << "\n" );
return true; return true;
} }
// Index a list of files (sent by the real time monitor) // Index a list of files (sent by the real time monitor)
bool BeagleQueueIndexer::indexFiles(list<string>& files) bool BeagleQueueIndexer::indexFiles(list<string>& files)
{ {
LOGDEB(("BeagleQueueIndexer::indexFiles\n")); LOGDEB("BeagleQueueIndexer::indexFiles\n" );
if (!m_db) { if (!m_db) {
LOGERR(("BeagleQueueIndexer::indexfiles no db??\n")); LOGERR("BeagleQueueIndexer::indexfiles no db??\n" );
return false; return false;
} }
for (list<string>::iterator it = files.begin(); it != files.end();) { for (list<string>::iterator it = files.begin(); it != files.end();) {
@ -327,8 +326,7 @@ bool BeagleQueueIndexer::indexFiles(list<string>& files)
} }
string father = path_getfather(*it); string father = path_getfather(*it);
if (father.compare(m_queuedir)) { if (father.compare(m_queuedir)) {
LOGDEB(("BeagleQueueIndexer::indexfiles: skipping [%s] (nq)\n", LOGDEB("BeagleQueueIndexer::indexfiles: skipping [" << *it << "] (nq)\n" );
it->c_str()));
it++; continue; it++; continue;
} }
// Pb: we are often called with the dot file, before the // Pb: we are often called with the dot file, before the
@ -344,13 +342,11 @@ bool BeagleQueueIndexer::indexFiles(list<string>& files)
} }
struct stat st; struct stat st;
if (path_fileprops(*it, &st) != 0) { if (path_fileprops(*it, &st) != 0) {
LOGERR(("BeagleQueueIndexer::indexfiles: cant stat [%s]\n", LOGERR("BeagleQueueIndexer::indexfiles: cant stat [" << *it << "]\n" );
it->c_str()));
it++; continue; it++; continue;
} }
if (!S_ISREG(st.st_mode)) { if (!S_ISREG(st.st_mode)) {
LOGDEB(("BeagleQueueIndexer::indexfiles: skipping [%s] (nr)\n", LOGDEB("BeagleQueueIndexer::indexfiles: skipping [" << *it << "] (nr)\n" );
it->c_str()));
it++; continue; it++; continue;
} }
@ -378,7 +374,7 @@ BeagleQueueIndexer::processone(const string &path,
string dotpath = path_cat(path_getfather(path), string dotpath = path_cat(path_getfather(path),
string(".") + path_getsimple(path)); string(".") + path_getsimple(path));
LOGDEB(("BeagleQueueIndexer: prc1: [%s]\n", path.c_str())); LOGDEB("BeagleQueueIndexer: prc1: [" << (path) << "]\n" );
BeagleDotFile dotfile(m_config, dotpath); BeagleDotFile dotfile(m_config, dotpath);
Rcl::Doc dotdoc; Rcl::Doc dotdoc;
@ -392,7 +388,7 @@ BeagleQueueIndexer::processone(const string &path,
udipath = path_cat(dotdoc.meta[Rcl::Doc::keybght], url_gpath(dotdoc.url)); udipath = path_cat(dotdoc.meta[Rcl::Doc::keybght], url_gpath(dotdoc.url));
make_udi(udipath, cstr_null, udi); make_udi(udipath, cstr_null, udi);
LOGDEB(("BeagleQueueIndexer: prc1: udi [%s]\n", udi.c_str())); LOGDEB("BeagleQueueIndexer: prc1: udi [" << (udi) << "]\n" );
char ascdate[30]; char ascdate[30];
sprintf(ascdate, "%ld", long(stp->st_mtime)); sprintf(ascdate, "%ld", long(stp->st_mtime));
@ -424,11 +420,11 @@ BeagleQueueIndexer::processone(const string &path,
try { try {
fis = interner.internfile(doc); fis = interner.internfile(doc);
} catch (CancelExcept) { } catch (CancelExcept) {
LOGERR(("BeagleQueueIndexer: interrupted\n")); LOGERR("BeagleQueueIndexer: interrupted\n" );
goto out; goto out;
} }
if (fis != FileInterner::FIDone && fis != FileInterner::FIAgain) { if (fis != FileInterner::FIDone && fis != FileInterner::FIAgain) {
LOGERR(("BeagleQueueIndexer: bad status from internfile\n")); LOGERR("BeagleQueueIndexer: bad status from internfile\n" );
// TOBEDONE: internfile can return FIAgain here if it is // TOBEDONE: internfile can return FIAgain here if it is
// paging a big text file, we should loop. Means we're // paging a big text file, we should loop. Means we're
// only indexing the first page for text/plain files // only indexing the first page for text/plain files
@ -461,12 +457,11 @@ BeagleQueueIndexer::processone(const string &path,
string fdata; string fdata;
file_to_string(path, fdata); file_to_string(path, fdata);
if (!m_cache || !m_cache->cc()) { if (!m_cache || !m_cache->cc()) {
LOGERR(("BeagleQueueIndexer: cache initialization failed\n")); LOGERR("BeagleQueueIndexer: cache initialization failed\n" );
goto out; goto out;
} }
if (!m_cache->cc()->put(udi, &dotfile.m_fields, fdata, 0)) { if (!m_cache->cc()->put(udi, &dotfile.m_fields, fdata, 0)) {
LOGERR(("BeagleQueueIndexer::prc1: cache_put failed; %s\n", LOGERR("BeagleQueueIndexer::prc1: cache_put failed; " << (m_cache->cc()->getReason()) << "\n" );
m_cache->cc()->getReason().c_str()));
goto out; goto out;
} }
} }
@ -479,3 +474,4 @@ out:
} }
return FsTreeWalker::FtwOk; return FsTreeWalker::FtwOk;
} }

View file

@ -16,11 +16,10 @@
*/ */
#include "autoconfig.h" #include "autoconfig.h"
#include "debuglog.h"
#include "rcldoc.h" #include "rcldoc.h"
#include "fetcher.h" #include "fetcher.h"
#include "bglfetcher.h" #include "bglfetcher.h"
#include "debuglog.h" #include "log.h"
#include "ptmutex.h" #include "ptmutex.h"
#include "beaglequeuecache.h" #include "beaglequeuecache.h"
@ -32,7 +31,7 @@ bool BGLDocFetcher::fetch(RclConfig* cnf, const Rcl::Doc& idoc, RawDoc& out)
{ {
string udi; string udi;
if (!idoc.getmeta(Rcl::Doc::keyudi, &udi) || udi.empty()) { if (!idoc.getmeta(Rcl::Doc::keyudi, &udi) || udi.empty()) {
LOGERR(("BGLDocFetcher:: no udi in idoc\n")); LOGERR("BGLDocFetcher:: no udi in idoc\n" );
return false; return false;
} }
Rcl::Doc dotdoc; Rcl::Doc dotdoc;
@ -43,13 +42,12 @@ bool BGLDocFetcher::fetch(RclConfig* cnf, const Rcl::Doc& idoc, RawDoc& out)
// deleted when the program exits. // deleted when the program exits.
static BeagleQueueCache o_beagler(cnf); static BeagleQueueCache o_beagler(cnf);
if (!o_beagler.getFromCache(udi, dotdoc, out.data)) { if (!o_beagler.getFromCache(udi, dotdoc, out.data)) {
LOGINFO(("BGLDocFetcher::fetch: failed for [%s]\n", udi.c_str())); LOGINFO("BGLDocFetcher::fetch: failed for [" << (udi) << "]\n" );
return false; return false;
} }
} }
if (dotdoc.mimetype.compare(idoc.mimetype)) { if (dotdoc.mimetype.compare(idoc.mimetype)) {
LOGINFO(("BGLDocFetcher:: udi [%s], mimetp mismatch: in: [%s], bgl " LOGINFO("BGLDocFetcher:: udi [" << (udi) << "], mimetp mismatch: in: [" << (idoc.mimetype) << "], bgl [" << (dotdoc.mimetype) << "]\n" );
"[%s]\n", idoc.mimetype.c_str(), dotdoc.mimetype.c_str()));
} }
out.kind = RawDoc::RDK_DATA; out.kind = RawDoc::RDK_DATA;
return true; return true;
@ -62,3 +60,4 @@ bool BGLDocFetcher::makesig(RclConfig* cnf, const Rcl::Doc& idoc, string& sig)
return true; return true;
} }

View file

@ -21,7 +21,7 @@
#include "rclconfig.h" #include "rclconfig.h"
#include "execmd.h" #include "execmd.h"
#include "debuglog.h" #include "log.h"
#include "checkretryfailed.h" #include "checkretryfailed.h"
using namespace std; using namespace std;
@ -34,8 +34,7 @@ bool checkRetryFailed(RclConfig *conf, bool record)
string cmd; string cmd;
if (!conf->getConfParam("checkneedretryindexscript", cmd)) { if (!conf->getConfParam("checkneedretryindexscript", cmd)) {
LOGDEB(("checkRetryFailed: 'checkneedretryindexscript' " LOGDEB("checkRetryFailed: 'checkneedretryindexscript' not set in config\n" );
"not set in config\n"));
// We could toss a dice ? Say no retry in this case. // We could toss a dice ? Say no retry in this case.
return false; return false;
} }
@ -56,3 +55,4 @@ bool checkRetryFailed(RclConfig *conf, bool record)
return false; return false;
#endif #endif
} }

View file

@ -22,7 +22,7 @@
#include "exefetcher.h" #include "exefetcher.h"
#include "debuglog.h" #include "log.h"
#include "pathut.h" #include "pathut.h"
#include "rclconfig.h" #include "rclconfig.h"
#include "execmd.h" #include "execmd.h"
@ -47,12 +47,10 @@ public:
args.push_back(idoc.ipath); args.push_back(idoc.ipath);
int status = ecmd.doexec1(args, 0, &out); int status = ecmd.doexec1(args, 0, &out);
if (status == 0) { if (status == 0) {
LOGDEB(("EXEDocFetcher::Internal: got [%s]\n", out.c_str())); LOGDEB("EXEDocFetcher::Internal: got [" << (out) << "]\n" );
return true; return true;
} else { } else {
LOGERR(("EXEDOcFetcher::fetch: %s: %s failed for %s %s %s 0x%u\n", LOGERR("EXEDOcFetcher::fetch: " << (bckid) << ": " << (stringsToString(cmd)) << " failed for " << (udi) << " " << (idoc.url) << " " << (idoc.ipath) << "\n" );
bckid.c_str(), stringsToString(cmd).c_str(), udi.c_str(),
idoc.url.c_str(), idoc.ipath.c_str()));
return false; return false;
} }
} }
@ -61,8 +59,7 @@ public:
EXEDocFetcher::EXEDocFetcher(const EXEDocFetcher::Internal& _m) EXEDocFetcher::EXEDocFetcher(const EXEDocFetcher::Internal& _m)
{ {
m = new Internal(_m); m = new Internal(_m);
LOGDEB(("EXEDocFetcher::EXEDocFetcher: fetch is %s\n", LOGDEB("EXEDocFetcher::EXEDocFetcher: fetch is " << (stringsToString(m->sfetch)) << "\n" );
stringsToString(m->sfetch).c_str()));
} }
bool EXEDocFetcher::fetch(RclConfig* cnf, const Rcl::Doc& idoc, RawDoc& out) bool EXEDocFetcher::fetch(RclConfig* cnf, const Rcl::Doc& idoc, RawDoc& out)
@ -85,13 +82,12 @@ EXEDocFetcher *exeDocFetcherMake(RclConfig *config, const string& bckid)
static ConfSimple *bconf; static ConfSimple *bconf;
if (!bconf) { if (!bconf) {
string bconfname = path_cat(config->getConfDir(), "backends"); string bconfname = path_cat(config->getConfDir(), "backends");
LOGDEB(("exeDocFetcherMake: using config in %s\n", bconfname.c_str())); LOGDEB("exeDocFetcherMake: using config in " << (bconfname) << "\n" );
bconf = new ConfSimple(bconfname.c_str(), true); bconf = new ConfSimple(bconfname.c_str(), true);
if (!bconf->ok()) { if (!bconf->ok()) {
delete bconf; delete bconf;
bconf = 0; bconf = 0;
LOGDEB(("exeDocFetcherMake: bad/no config: %s\n", LOGDEB("exeDocFetcherMake: bad/no config: " << (bconfname) << "\n" );
bconfname.c_str()));
return 0; return 0;
} }
} }
@ -101,29 +97,28 @@ EXEDocFetcher *exeDocFetcherMake(RclConfig *config, const string& bckid)
string sfetch; string sfetch;
if (!bconf->get("fetch", sfetch, bckid) || sfetch.empty()) { if (!bconf->get("fetch", sfetch, bckid) || sfetch.empty()) {
LOGERR(("exeDocFetcherMake: no 'fetch' for [%s]\n", bckid.c_str())); LOGERR("exeDocFetcherMake: no 'fetch' for [" << (bckid) << "]\n" );
return 0; return 0;
} }
stringToStrings(sfetch, m.sfetch); stringToStrings(sfetch, m.sfetch);
// We look up the command as we do for filters for now // We look up the command as we do for filters for now
m.sfetch[0] = config->findFilter(m.sfetch[0]); m.sfetch[0] = config->findFilter(m.sfetch[0]);
if (!path_isabsolute(m.sfetch[0])) { if (!path_isabsolute(m.sfetch[0])) {
LOGERR(("exeDocFetcherMake: %s not found in exec path or filters dir\n", LOGERR("exeDocFetcherMake: " << (m.sfetch[0]) << " not found in exec path or filters dir\n" );
m.sfetch[0].c_str()));
return 0; return 0;
} }
string smkid; string smkid;
if (!bconf->get("makesig", smkid, bckid) || smkid.empty()) { if (!bconf->get("makesig", smkid, bckid) || smkid.empty()) {
LOGDEB(("exeDocFetcherMake: no 'makesig' for [%s]\n", bckid.c_str())); LOGDEB("exeDocFetcherMake: no 'makesig' for [" << (bckid) << "]\n" );
return 0; return 0;
} }
stringToStrings(smkid, m.smkid); stringToStrings(smkid, m.smkid);
m.smkid[0] = config->findFilter(m.smkid[0]); m.smkid[0] = config->findFilter(m.smkid[0]);
if (!path_isabsolute(m.smkid[0])) { if (!path_isabsolute(m.smkid[0])) {
LOGERR(("exeDocFetcherMake: %s not found in exec path or filters dir\n", LOGERR("exeDocFetcherMake: " << (m.smkid[0]) << " not found in exec path or filters dir\n" );
m.smkid[0].c_str()));
return 0; return 0;
} }
return new EXEDocFetcher(m); return new EXEDocFetcher(m);
} }

View file

@ -17,7 +17,7 @@
#include "autoconfig.h" #include "autoconfig.h"
#include "debuglog.h" #include "log.h"
#include "rclconfig.h" #include "rclconfig.h"
#include "fetcher.h" #include "fetcher.h"
@ -28,7 +28,7 @@
DocFetcher *docFetcherMake(RclConfig *config, const Rcl::Doc& idoc) DocFetcher *docFetcherMake(RclConfig *config, const Rcl::Doc& idoc)
{ {
if (idoc.url.empty()) { if (idoc.url.empty()) {
LOGERR(("docFetcherMakeg:: no url in doc!\n")); LOGERR("docFetcherMakeg:: no url in doc!\n" );
return 0; return 0;
} }
string backend; string backend;
@ -42,9 +42,9 @@ DocFetcher *docFetcherMake(RclConfig *config, const Rcl::Doc& idoc)
} else { } else {
DocFetcher *f = exeDocFetcherMake(config, backend); DocFetcher *f = exeDocFetcherMake(config, backend);
if (!f) { if (!f) {
LOGERR(("DocFetcherFactory: unknown backend [%s]\n", LOGERR("DocFetcherFactory: unknown backend [" << (backend) << "]\n" );
backend.c_str()));
} }
return f; return f;
} }
} }

View file

@ -19,12 +19,11 @@
#include <errno.h> #include <errno.h>
#include "safesysstat.h" #include "safesysstat.h"
#include "debuglog.h" #include "log.h"
#include "cstr.h" #include "cstr.h"
#include "fetcher.h" #include "fetcher.h"
#include "fsfetcher.h" #include "fsfetcher.h"
#include "fsindexer.h" #include "fsindexer.h"
#include "debuglog.h"
#include "pathut.h" #include "pathut.h"
using std::string; using std::string;
@ -35,8 +34,7 @@ static bool urltopath(RclConfig* cnf,
// The url has to be like file:// // The url has to be like file://
fn = fileurltolocalpath(idoc.url); fn = fileurltolocalpath(idoc.url);
if (fn.empty()) { if (fn.empty()) {
LOGERR(("FSDocFetcher::fetch/sig: non fs url: [%s]\n", LOGERR("FSDocFetcher::fetch/sig: non fs url: [" << (idoc.url) << "]\n" );
idoc.url.c_str()));
return false; return false;
} }
cnf->setKeyDir(path_getfather(fn)); cnf->setKeyDir(path_getfather(fn));
@ -44,8 +42,7 @@ static bool urltopath(RclConfig* cnf,
cnf->getConfParam("followLinks", &follow); cnf->getConfParam("followLinks", &follow);
if (path_fileprops(fn, &st, follow) < 0) { if (path_fileprops(fn, &st, follow) < 0) {
LOGERR(("FSDocFetcher::fetch: stat errno %d for [%s]\n", LOGERR("FSDocFetcher::fetch: stat errno " << (errno) << " for [" << (fn) << "]\n" );
errno, fn.c_str()));
return false; return false;
} }
return true; return true;
@ -71,3 +68,4 @@ bool FSDocFetcher::makesig(RclConfig* cnf, const Rcl::Doc& idoc, string& sig)
return true; return true;
} }

View file

@ -37,7 +37,7 @@
#include "indexer.h" #include "indexer.h"
#include "fsindexer.h" #include "fsindexer.h"
#include "transcode.h" #include "transcode.h"
#include "debuglog.h" #include "log.h"
#include "internfile.h" #include "internfile.h"
#include "smallut.h" #include "smallut.h"
#include "chrono.h" #include "chrono.h"
@ -106,19 +106,18 @@ FsIndexer::FsIndexer(RclConfig *cnf, Rcl::Db *db, DbIxStatusUpdater *updfunc)
m_dwqueue("Split", cnf->getThrConf(RclConfig::ThrSplit).first) m_dwqueue("Split", cnf->getThrConf(RclConfig::ThrSplit).first)
#endif // IDX_THREADS #endif // IDX_THREADS
{ {
LOGDEB1(("FsIndexer::FsIndexer\n")); LOGDEB1("FsIndexer::FsIndexer\n" );
m_havelocalfields = m_config->hasNameAnywhere("localfields"); m_havelocalfields = m_config->hasNameAnywhere("localfields");
m_config->getConfParam("detectxattronly", &m_detectxattronly); m_config->getConfParam("detectxattronly", &m_detectxattronly);
#ifdef IDX_THREADS #ifdef IDX_THREADS
m_stableconfig = new RclConfig(*m_config); m_stableconfig = new RclConfig(*m_config);
m_loglevel = DebugLog::getdbl()->getlevel();
m_haveInternQ = m_haveSplitQ = false; m_haveInternQ = m_haveSplitQ = false;
int internqlen = cnf->getThrConf(RclConfig::ThrIntern).first; int internqlen = cnf->getThrConf(RclConfig::ThrIntern).first;
int internthreads = cnf->getThrConf(RclConfig::ThrIntern).second; int internthreads = cnf->getThrConf(RclConfig::ThrIntern).second;
if (internqlen >= 0) { if (internqlen >= 0) {
if (!m_iwqueue.start(internthreads, FsIndexerInternfileWorker, this)) { if (!m_iwqueue.start(internthreads, FsIndexerInternfileWorker, this)) {
LOGERR(("FsIndexer::FsIndexer: intern worker start failed\n")); LOGERR("FsIndexer::FsIndexer: intern worker start failed\n" );
return; return;
} }
m_haveInternQ = true; m_haveInternQ = true;
@ -127,30 +126,28 @@ FsIndexer::FsIndexer(RclConfig *cnf, Rcl::Db *db, DbIxStatusUpdater *updfunc)
int splitthreads = cnf->getThrConf(RclConfig::ThrSplit).second; int splitthreads = cnf->getThrConf(RclConfig::ThrSplit).second;
if (splitqlen >= 0) { if (splitqlen >= 0) {
if (!m_dwqueue.start(splitthreads, FsIndexerDbUpdWorker, this)) { if (!m_dwqueue.start(splitthreads, FsIndexerDbUpdWorker, this)) {
LOGERR(("FsIndexer::FsIndexer: split worker start failed\n")); LOGERR("FsIndexer::FsIndexer: split worker start failed\n" );
return; return;
} }
m_haveSplitQ = true; m_haveSplitQ = true;
} }
LOGDEB(("FsIndexer: threads: haveIQ %d iql %d iqts %d " LOGDEB("FsIndexer: threads: haveIQ " << (m_haveInternQ) << " iql " << (internqlen) << " iqts " << (internthreads) << " haveSQ " << (m_haveSplitQ) << " sql " << (splitqlen) << " sqts " << (splitthreads) << "\n" );
"haveSQ %d sql %d sqts %d\n", m_haveInternQ, internqlen,
internthreads, m_haveSplitQ, splitqlen, splitthreads));
#endif // IDX_THREADS #endif // IDX_THREADS
} }
FsIndexer::~FsIndexer() FsIndexer::~FsIndexer()
{ {
LOGDEB1(("FsIndexer::~FsIndexer()\n")); LOGDEB1("FsIndexer::~FsIndexer()\n" );
#ifdef IDX_THREADS #ifdef IDX_THREADS
void *status; void *status;
if (m_haveInternQ) { if (m_haveInternQ) {
status = m_iwqueue.setTerminateAndWait(); status = m_iwqueue.setTerminateAndWait();
LOGDEB0(("FsIndexer: internfile wrkr status: %p (1->ok)\n", status)); LOGDEB0("FsIndexer: internfile wrkr status: " << (status) << " (1->ok)\n" );
} }
if (m_haveSplitQ) { if (m_haveSplitQ) {
status = m_dwqueue.setTerminateAndWait(); status = m_dwqueue.setTerminateAndWait();
LOGDEB0(("FsIndexer: dbupd worker status: %p (1->ok)\n", status)); LOGDEB0("FsIndexer: dbupd worker status: " << (status) << " (1->ok)\n" );
} }
delete m_stableconfig; delete m_stableconfig;
#endif // IDX_THREADS #endif // IDX_THREADS
@ -163,7 +160,7 @@ bool FsIndexer::init()
if (m_tdl.empty()) { if (m_tdl.empty()) {
m_tdl = m_config->getTopdirs(); m_tdl = m_config->getTopdirs();
if (m_tdl.empty()) { if (m_tdl.empty()) {
LOGERR(("FsIndexers: no topdirs list defined\n")); LOGERR("FsIndexers: no topdirs list defined\n" );
return false; return false;
} }
} }
@ -194,8 +191,8 @@ bool FsIndexer::index(int flags)
for (vector<string>::const_iterator it = m_tdl.begin(); for (vector<string>::const_iterator it = m_tdl.begin();
it != m_tdl.end(); it++) { it != m_tdl.end(); it++) {
LOGDEB(("FsIndexer::index: Indexing %s into %s\n", it->c_str(), LOGDEB("FsIndexer::index: Indexing " << *it << " into " <<
getDbDir().c_str())); getDbDir() << "\n");
// Set the current directory in config so that subsequent // Set the current directory in config so that subsequent
// getConfParams() will get local values // getConfParams() will get local values
@ -217,8 +214,8 @@ bool FsIndexer::index(int flags)
// Walk the directory tree // Walk the directory tree
if (m_walker.walk(*it, *this) != FsTreeWalker::FtwOk) { if (m_walker.walk(*it, *this) != FsTreeWalker::FtwOk) {
LOGERR(("FsIndexer::index: error while indexing %s: %s\n", LOGERR("FsIndexer::index: error while indexing " << *it <<
it->c_str(), m_walker.getReason().c_str())); ": " << m_walker.getReason() << "\n");
return false; return false;
} }
} }
@ -235,12 +232,11 @@ bool FsIndexer::index(int flags)
string missing; string missing;
m_missing->getMissingDescription(missing); m_missing->getMissingDescription(missing);
if (!missing.empty()) { if (!missing.empty()) {
LOGINFO(("FsIndexer::index missing helper program(s):\n%s\n", LOGINFO("FsIndexer::index missing helper program(s):\n" << (missing) << "\n" );
missing.c_str()));
} }
m_config->storeMissingHelperDesc(missing); m_config->storeMissingHelperDesc(missing);
} }
LOGINFO(("fsindexer index time: %d mS\n", chron.millis())); LOGINFO("fsindexer index time: " << (chron.millis()) << " mS\n" );
return true; return true;
} }
@ -261,8 +257,7 @@ static bool matchesSkipped(const vector<string>& tdl,
for (vector<string>::const_iterator it = tdl.begin(); for (vector<string>::const_iterator it = tdl.begin();
it != tdl.end(); it++) { it != tdl.end(); it++) {
// the topdirs members are already canonized. // the topdirs members are already canonized.
LOGDEB2(("matchesSkipped: comparing ancestor [%s] to " LOGDEB2("matchesSkipped: comparing ancestor [" << (mpath) << "] to topdir [" << (it) << "]\n" );
"topdir [%s]\n", mpath.c_str(), it->c_str()));
if (!mpath.compare(*it)) { if (!mpath.compare(*it)) {
topdir = *it; topdir = *it;
goto goodpath; goto goodpath;
@ -270,8 +265,7 @@ static bool matchesSkipped(const vector<string>& tdl,
} }
if (walker.inSkippedPaths(mpath, false)) { if (walker.inSkippedPaths(mpath, false)) {
LOGDEB(("FsIndexer::indexFiles: skipping [%s] (skpp)\n", LOGDEB("FsIndexer::indexFiles: skipping [" << (path) << "] (skpp)\n" );
path.c_str()));
return true; return true;
} }
@ -285,13 +279,12 @@ static bool matchesSkipped(const vector<string>& tdl,
// path did not shorten, something is seriously amiss // path did not shorten, something is seriously amiss
// (could be an assert actually) // (could be an assert actually)
if (mpath.length() >= len) { if (mpath.length() >= len) {
LOGERR(("FsIndexer::indexFile: internal Error: path [%s] did not " LOGERR("FsIndexer::indexFile: internal Error: path [" << (mpath) << "] did not shorten\n" );
"shorten\n", mpath.c_str()));
return true; return true;
} }
} }
// We get there if neither topdirs nor skippedPaths tests matched // We get there if neither topdirs nor skippedPaths tests matched
LOGDEB(("FsIndexer::indexFiles: skipping [%s] (ntd)\n", path.c_str())); LOGDEB("FsIndexer::indexFiles: skipping [" << (path) << "] (ntd)\n" );
return true; return true;
goodpath: goodpath:
@ -301,8 +294,7 @@ goodpath:
while (mpath.length() >= topdir.length() && mpath.length() > 1) { while (mpath.length() >= topdir.length() && mpath.length() > 1) {
string fn = path_getsimple(mpath); string fn = path_getsimple(mpath);
if (walker.inSkippedNames(fn)) { if (walker.inSkippedNames(fn)) {
LOGDEB(("FsIndexer::indexFiles: skipping [%s] (skpn)\n", LOGDEB("FsIndexer::indexFiles: skipping [" << (path) << "] (skpn)\n" );
path.c_str()));
return true; return true;
} }
@ -326,7 +318,7 @@ goodpath:
*/ */
bool FsIndexer::indexFiles(list<string>& files, int flags) bool FsIndexer::indexFiles(list<string>& files, int flags)
{ {
LOGDEB(("FsIndexer::indexFiles\n")); LOGDEB("FsIndexer::indexFiles\n" );
m_noretryfailed = (flags & ConfIndexer::IxFNoRetryFailed) != 0; m_noretryfailed = (flags & ConfIndexer::IxFNoRetryFailed) != 0;
bool ret = false; bool ret = false;
@ -344,7 +336,7 @@ bool FsIndexer::indexFiles(list<string>& files, int flags)
walker.setSkippedPaths(m_config->getSkippedPaths()); walker.setSkippedPaths(m_config->getSkippedPaths());
for (list<string>::iterator it = files.begin(); it != files.end(); ) { for (list<string>::iterator it = files.begin(); it != files.end(); ) {
LOGDEB2(("FsIndexer::indexFiles: [%s]\n", it->c_str())); LOGDEB2("FsIndexer::indexFiles: [" << (it) << "]\n" );
m_config->setKeyDir(path_getfather(*it)); m_config->setKeyDir(path_getfather(*it));
if (m_havelocalfields) if (m_havelocalfields)
@ -364,15 +356,15 @@ bool FsIndexer::indexFiles(list<string>& files, int flags)
struct stat stb; struct stat stb;
int ststat = path_fileprops(*it, &stb, follow); int ststat = path_fileprops(*it, &stb, follow);
if (ststat != 0) { if (ststat != 0) {
LOGERR(("FsIndexer::indexFiles: (l)stat %s: %s", it->c_str(), LOGERR("FsIndexer::indexFiles: (l)stat " << *it << ": " <<
strerror(errno))); strerror(errno) << "\n");
it++; it++;
continue; continue;
} }
if (processone(*it, &stb, FsTreeWalker::FtwRegular) != if (processone(*it, &stb, FsTreeWalker::FtwRegular) !=
FsTreeWalker::FtwOk) { FsTreeWalker::FtwOk) {
LOGERR(("FsIndexer::indexFiles: processone failed\n")); LOGERR("FsIndexer::indexFiles: processone failed\n" );
goto out; goto out;
} }
it = files.erase(it); it = files.erase(it);
@ -390,11 +382,11 @@ out:
// Purge possible orphan documents // Purge possible orphan documents
if (ret == true) { if (ret == true) {
LOGDEB(("Indexfiles: purging orphans\n")); LOGDEB("Indexfiles: purging orphans\n" );
const vector<string>& purgecandidates = m_purgeCandidates.getCandidates(); const vector<string>& purgecandidates = m_purgeCandidates.getCandidates();
for (vector<string>::const_iterator it = purgecandidates.begin(); for (vector<string>::const_iterator it = purgecandidates.begin();
it != purgecandidates.end(); it++) { it != purgecandidates.end(); it++) {
LOGDEB(("Indexfiles: purging orphans for %s\n", it->c_str())); LOGDEB("Indexfiles: purging orphans for " << *it << "\n");
m_db->purgeOrphans(*it); m_db->purgeOrphans(*it);
} }
#ifdef IDX_THREADS #ifdef IDX_THREADS
@ -402,7 +394,7 @@ out:
#endif // IDX_THREADS #endif // IDX_THREADS
} }
LOGDEB(("FsIndexer::indexFiles: done\n")); LOGDEB("FsIndexer::indexFiles: done\n" );
return ret; return ret;
} }
@ -410,7 +402,7 @@ out:
/** Purge docs for given files out of the database */ /** Purge docs for given files out of the database */
bool FsIndexer::purgeFiles(list<string>& files) bool FsIndexer::purgeFiles(list<string>& files)
{ {
LOGDEB(("FsIndexer::purgeFiles\n")); LOGDEB("FsIndexer::purgeFiles\n" );
bool ret = false; bool ret = false;
if (!init()) if (!init())
return false; return false;
@ -422,7 +414,7 @@ bool FsIndexer::purgeFiles(list<string>& files)
// found or deleted, false only in case of actual error // found or deleted, false only in case of actual error
bool existed; bool existed;
if (!m_db->purgeFile(udi, &existed)) { if (!m_db->purgeFile(udi, &existed)) {
LOGERR(("FsIndexer::purgeFiles: Database error\n")); LOGERR("FsIndexer::purgeFiles: Database error\n" );
goto out; goto out;
} }
// If we actually deleted something, take it off the list // If we actually deleted something, take it off the list
@ -442,14 +434,14 @@ out:
m_dwqueue.waitIdle(); m_dwqueue.waitIdle();
m_db->waitUpdIdle(); m_db->waitUpdIdle();
#endif // IDX_THREADS #endif // IDX_THREADS
LOGDEB(("FsIndexer::purgeFiles: done\n")); LOGDEB("FsIndexer::purgeFiles: done\n" );
return ret; return ret;
} }
// Local fields can be set for fs subtrees in the configuration file // Local fields can be set for fs subtrees in the configuration file
void FsIndexer::localfieldsfromconf() void FsIndexer::localfieldsfromconf()
{ {
LOGDEB1(("FsIndexer::localfieldsfromconf\n")); LOGDEB1("FsIndexer::localfieldsfromconf\n" );
string sfields; string sfields;
m_config->getConfParam("localfields", sfields); m_config->getConfParam("localfields", sfields);
@ -469,8 +461,7 @@ void FsIndexer::localfieldsfromconf()
it != nmlst.end(); it++) { it != nmlst.end(); it++) {
string nm = m_config->fieldCanon(*it); string nm = m_config->fieldCanon(*it);
attrs.get(*it, m_localfields[nm]); attrs.get(*it, m_localfields[nm]);
LOGDEB2(("FsIndexer::localfieldsfromconf: [%s]->[%s]\n", LOGDEB2("FsIndexer::localfieldsfromconf: [" << (nm) << "]->[" << (m_localfields[nm]) << "]\n" );
nm.c_str(), m_localfields[nm].c_str()));
} }
} }
@ -501,7 +492,6 @@ void *FsIndexerDbUpdWorker(void * fsp)
recoll_threadinit(); recoll_threadinit();
FsIndexer *fip = (FsIndexer*)fsp; FsIndexer *fip = (FsIndexer*)fsp;
WorkQueue<DbUpdTask*> *tqp = &fip->m_dwqueue; WorkQueue<DbUpdTask*> *tqp = &fip->m_dwqueue;
DebugLog::getdbl()->setloglevel(fip->m_loglevel);
DbUpdTask *tsk; DbUpdTask *tsk;
for (;;) { for (;;) {
@ -510,9 +500,9 @@ void *FsIndexerDbUpdWorker(void * fsp)
tqp->workerExit(); tqp->workerExit();
return (void*)1; return (void*)1;
} }
LOGDEB0(("FsIndexerDbUpdWorker: task ql %d\n", int(qsz))); LOGDEB0("FsIndexerDbUpdWorker: task ql " << (int(qsz)) << "\n" );
if (!fip->m_db->addOrUpdate(tsk->udi, tsk->parent_udi, tsk->doc)) { if (!fip->m_db->addOrUpdate(tsk->udi, tsk->parent_udi, tsk->doc)) {
LOGERR(("FsIndexerDbUpdWorker: addOrUpdate failed\n")); LOGERR("FsIndexerDbUpdWorker: addOrUpdate failed\n" );
tqp->workerExit(); tqp->workerExit();
return (void*)0; return (void*)0;
} }
@ -525,7 +515,6 @@ void *FsIndexerInternfileWorker(void * fsp)
recoll_threadinit(); recoll_threadinit();
FsIndexer *fip = (FsIndexer*)fsp; FsIndexer *fip = (FsIndexer*)fsp;
WorkQueue<InternfileTask*> *tqp = &fip->m_iwqueue; WorkQueue<InternfileTask*> *tqp = &fip->m_iwqueue;
DebugLog::getdbl()->setloglevel(fip->m_loglevel);
RclConfig myconf(*(fip->m_stableconfig)); RclConfig myconf(*(fip->m_stableconfig));
InternfileTask *tsk = 0; InternfileTask *tsk = 0;
@ -534,15 +523,15 @@ void *FsIndexerInternfileWorker(void * fsp)
tqp->workerExit(); tqp->workerExit();
return (void*)1; return (void*)1;
} }
LOGDEB0(("FsIndexerInternfileWorker: task fn %s\n", tsk->fn.c_str())); LOGDEB0("FsIndexerInternfileWorker: task fn " << (tsk->fn) << "\n" );
if (fip->processonefile(&myconf, tsk->fn, &tsk->statbuf, if (fip->processonefile(&myconf, tsk->fn, &tsk->statbuf,
tsk->localfields) != tsk->localfields) !=
FsTreeWalker::FtwOk) { FsTreeWalker::FtwOk) {
LOGERR(("FsIndexerInternfileWorker: processone failed\n")); LOGERR("FsIndexerInternfileWorker: processone failed\n" );
tqp->workerExit(); tqp->workerExit();
return (void*)0; return (void*)0;
} }
LOGDEB1(("FsIndexerInternfileWorker: done fn %s\n", tsk->fn.c_str())); LOGDEB1("FsIndexerInternfileWorker: done fn " << (tsk->fn) << "\n" );
delete tsk; delete tsk;
} }
} }
@ -613,15 +602,11 @@ static string compute_utf8fn(RclConfig *config, const string& fn)
string utf8fn; string utf8fn;
int ercnt; int ercnt;
if (!transcode(path_getsimple(fn), utf8fn, charset, "UTF-8", &ercnt)) { if (!transcode(path_getsimple(fn), utf8fn, charset, "UTF-8", &ercnt)) {
LOGERR(("processone: fn transcode failure from [%s] to UTF-8: %s\n", LOGERR("processone: fn transcode failure from [" << (charset) << "] to UTF-8: " << (path_getsimple(fn)) << "\n" );
charset.c_str(), path_getsimple(fn).c_str()));
} else if (ercnt) { } else if (ercnt) {
LOGDEB(("processone: fn transcode %d errors from [%s] to UTF-8: %s\n", LOGDEB("processone: fn transcode " << (ercnt) << " errors from [" << (charset) << "] to UTF-8: " << (path_getsimple(fn)) << "\n" );
ercnt, charset.c_str(), path_getsimple(fn).c_str()));
} }
LOGDEB2(("processone: fn transcoded from [%s] to [%s] (%s->%s)\n", LOGDEB2("processone: fn transcoded from [" << (path_getsimple(fn)) << "] to [" << (utf8fn) << "] (" << (charset) << "->" << ("UTF-8") << ")\n" );
path_getsimple(fn).c_str(), utf8fn.c_str(), charset.c_str(),
"UTF-8"));
return utf8fn; return utf8fn;
} }
@ -663,8 +648,7 @@ FsIndexer::processonefile(RclConfig *config,
bool xattronly = m_detectxattronly && !m_db->inFullReset() && bool xattronly = m_detectxattronly && !m_db->inFullReset() &&
existingDoc && needupdate && (stp->st_mtime < stp->st_ctime); existingDoc && needupdate && (stp->st_mtime < stp->st_ctime);
LOGDEB(("processone: needupdate %d noretry %d existing %d oldsig [%s]\n", LOGDEB("processone: needupdate " << (needupdate) << " noretry " << (m_noretryfailed) << " existing " << (existingDoc) << " oldsig [" << (oldsig) << "]\n" );
needupdate, m_noretryfailed, existingDoc, oldsig.c_str()));
// If noretryfailed is set, check for a file which previously // If noretryfailed is set, check for a file which previously
// failed to index, and avoid re-processing it // failed to index, and avoid re-processing it
@ -674,14 +658,14 @@ FsIndexer::processonefile(RclConfig *config,
// actually changed, we always retry (maybe it was fixed) // actually changed, we always retry (maybe it was fixed)
string nold = oldsig.substr(0, oldsig.size()-1); string nold = oldsig.substr(0, oldsig.size()-1);
if (!nold.compare(sig)) { if (!nold.compare(sig)) {
LOGDEB(("processone: not retrying previously failed file\n")); LOGDEB("processone: not retrying previously failed file\n" );
m_db->setExistingFlags(udi, existingDoc); m_db->setExistingFlags(udi, existingDoc);
needupdate = false; needupdate = false;
} }
} }
if (!needupdate) { if (!needupdate) {
LOGDEB0(("processone: up to date: %s\n", fn.c_str())); LOGDEB0("processone: up to date: " << (fn) << "\n" );
if (m_updater) { if (m_updater) {
#ifdef IDX_THREADS #ifdef IDX_THREADS
PTMutexLocker locker(m_updater->m_mutex); PTMutexLocker locker(m_updater->m_mutex);
@ -696,8 +680,7 @@ FsIndexer::processonefile(RclConfig *config,
return FsTreeWalker::FtwOk; return FsTreeWalker::FtwOk;
} }
LOGDEB0(("processone: processing: [%s] %s\n", LOGDEB0("processone: processing: [" << (displayableBytes(off_t(stp->st_size))) << "] " << (fn) << "\n" );
displayableBytes(off_t(stp->st_size)).c_str(), fn.c_str()));
string utf8fn = compute_utf8fn(config, fn); string utf8fn = compute_utf8fn(config, fn);
@ -729,7 +712,7 @@ FsIndexer::processonefile(RclConfig *config,
try { try {
fis = interner.internfile(doc); fis = interner.internfile(doc);
} catch (CancelExcept) { } catch (CancelExcept) {
LOGERR(("fsIndexer::processone: interrupted\n")); LOGERR("fsIndexer::processone: interrupted\n" );
return FsTreeWalker::FtwStop; return FsTreeWalker::FtwStop;
} }
@ -800,7 +783,7 @@ FsIndexer::processonefile(RclConfig *config,
DbUpdTask *tp = new DbUpdTask(udi, doc.ipath.empty() ? DbUpdTask *tp = new DbUpdTask(udi, doc.ipath.empty() ?
cstr_null : parent_udi, doc); cstr_null : parent_udi, doc);
if (!m_dwqueue.put(tp)) { if (!m_dwqueue.put(tp)) {
LOGERR(("processonefile: wqueue.put failed\n")); LOGERR("processonefile: wqueue.put failed\n" );
return FsTreeWalker::FtwError; return FsTreeWalker::FtwError;
} }
} else { } else {
@ -839,8 +822,7 @@ FsIndexer::processonefile(RclConfig *config,
// If this doc existed and it's a container, recording for // If this doc existed and it's a container, recording for
// possible subdoc purge (this will be used only if we don't do a // possible subdoc purge (this will be used only if we don't do a
// db-wide purge, e.g. if we're called from indexfiles()). // db-wide purge, e.g. if we're called from indexfiles()).
LOGDEB2(("processOnefile: existingDoc %d hadNonNullIpath %d\n", LOGDEB2("processOnefile: existingDoc " << (existingDoc) << " hadNonNullIpath " << (hadNonNullIpath) << "\n" );
existingDoc, hadNonNullIpath));
if (existingDoc && hadNonNullIpath) { if (existingDoc && hadNonNullIpath) {
m_purgeCandidates.record(parent_udi); m_purgeCandidates.record(parent_udi);
} }
@ -853,7 +835,7 @@ FsIndexer::processonefile(RclConfig *config,
// If xattronly is set, ONLY the extattr metadata is valid and will be used // If xattronly is set, ONLY the extattr metadata is valid and will be used
// by the following step. // by the following step.
if (xattronly || hadNullIpath == false) { if (xattronly || hadNullIpath == false) {
LOGDEB(("Creating empty doc for file or pure xattr update\n")); LOGDEB("Creating empty doc for file or pure xattr update\n" );
Rcl::Doc fileDoc; Rcl::Doc fileDoc;
if (xattronly) { if (xattronly) {
map<string, string> xfields; map<string, string> xfields;
@ -889,3 +871,4 @@ FsIndexer::processonefile(RclConfig *config,
return FsTreeWalker::FtwOk; return FsTreeWalker::FtwOk;
} }

View file

@ -142,7 +142,6 @@ class FsIndexer : public FsTreeWalkerCB {
#ifdef IDX_THREADS #ifdef IDX_THREADS
friend void *FsIndexerDbUpdWorker(void*); friend void *FsIndexerDbUpdWorker(void*);
friend void *FsIndexerInternfileWorker(void*); friend void *FsIndexerInternfileWorker(void*);
int m_loglevel;
WorkQueue<InternfileTask*> m_iwqueue; WorkQueue<InternfileTask*> m_iwqueue;
WorkQueue<DbUpdTask*> m_dwqueue; WorkQueue<DbUpdTask*> m_dwqueue;
bool m_haveInternQ; bool m_haveInternQ;

View file

@ -22,7 +22,7 @@
#include <algorithm> #include <algorithm>
#include "cstr.h" #include "cstr.h"
#include "debuglog.h" #include "log.h"
#include "indexer.h" #include "indexer.h"
#include "fsindexer.h" #include "fsindexer.h"
#ifndef DISABLE_WEB_INDEXER #ifndef DISABLE_WEB_INDEXER
@ -60,13 +60,13 @@ bool ConfIndexer::runFirstIndexing()
{ {
// Indexing status file existing and not empty ? // Indexing status file existing and not empty ?
if (path_filesize(m_config->getIdxStatusFile()) > 0) { if (path_filesize(m_config->getIdxStatusFile()) > 0) {
LOGDEB0(("ConfIndexer::runFirstIndexing: no: status file not empty\n")); LOGDEB0("ConfIndexer::runFirstIndexing: no: status file not empty\n" );
return false; return false;
} }
// And only do this if the user has kept the default topdirs (~). // And only do this if the user has kept the default topdirs (~).
vector<string> tdl = m_config->getTopdirs(); vector<string> tdl = m_config->getTopdirs();
if (tdl.size() != 1 || tdl[0].compare(path_canon(path_tildexpand("~")))) { if (tdl.size() != 1 || tdl[0].compare(path_canon(path_tildexpand("~")))) {
LOGDEB0(("ConfIndexer::runFirstIndexing: no: not home only\n")); LOGDEB0("ConfIndexer::runFirstIndexing: no: not home only\n" );
return false; return false;
} }
return true; return true;
@ -74,7 +74,7 @@ bool ConfIndexer::runFirstIndexing()
bool ConfIndexer::firstFsIndexingSequence() bool ConfIndexer::firstFsIndexingSequence()
{ {
LOGDEB(("ConfIndexer::firstFsIndexingSequence\n")); LOGDEB("ConfIndexer::firstFsIndexingSequence\n" );
deleteZ(m_fsindexer); deleteZ(m_fsindexer);
m_fsindexer = new FsIndexer(m_config, &m_db, m_updater); m_fsindexer = new FsIndexer(m_config, &m_db, m_updater);
if (!m_fsindexer) { if (!m_fsindexer) {
@ -92,8 +92,7 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags)
{ {
Rcl::Db::OpenMode mode = resetbefore ? Rcl::Db::DbTrunc : Rcl::Db::DbUpd; Rcl::Db::OpenMode mode = resetbefore ? Rcl::Db::DbTrunc : Rcl::Db::DbUpd;
if (!m_db.open(mode)) { if (!m_db.open(mode)) {
LOGERR(("ConfIndexer: error opening database %s : %s\n", LOGERR("ConfIndexer: error opening database " << (m_config->getDbDir()) << " : " << (m_db.getReason()) << "\n" );
m_config->getDbDir().c_str(), m_db.getReason().c_str()));
return false; return false;
} }
@ -135,8 +134,7 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags)
if (m_updater) if (m_updater)
m_updater->update(DbIxStatus::DBIXS_CLOSING, string()); m_updater->update(DbIxStatus::DBIXS_CLOSING, string());
if (!m_db.close()) { if (!m_db.close()) {
LOGERR(("ConfIndexer::index: error closing database in %s\n", LOGERR("ConfIndexer::index: error closing database in " << (m_config->getDbDir()) << "\n" );
m_config->getDbDir().c_str()));
return false; return false;
} }
@ -163,8 +161,7 @@ bool ConfIndexer::indexFiles(list<string>& ifiles, int flag)
myfiles.sort(); myfiles.sort();
if (!m_db.open(Rcl::Db::DbUpd)) { if (!m_db.open(Rcl::Db::DbUpd)) {
LOGERR(("ConfIndexer: indexFiles error opening database %s\n", LOGERR("ConfIndexer: indexFiles error opening database " << (m_config->getDbDir()) << "\n" );
m_config->getDbDir().c_str()));
return false; return false;
} }
m_config->setKeyDir(cstr_null); m_config->setKeyDir(cstr_null);
@ -173,8 +170,7 @@ bool ConfIndexer::indexFiles(list<string>& ifiles, int flag)
m_fsindexer = new FsIndexer(m_config, &m_db, m_updater); m_fsindexer = new FsIndexer(m_config, &m_db, m_updater);
if (m_fsindexer) if (m_fsindexer)
ret = m_fsindexer->indexFiles(myfiles, flag); ret = m_fsindexer->indexFiles(myfiles, flag);
LOGDEB2(("ConfIndexer::indexFiles: fsindexer returned %d, " LOGDEB2("ConfIndexer::indexFiles: fsindexer returned " << (ret) << ", " << (myfiles.size()) << " files remainining\n" );
"%d files remainining\n", ret, myfiles.size()));
#ifndef DISABLE_WEB_INDEXER #ifndef DISABLE_WEB_INDEXER
if (m_dobeagle && !myfiles.empty() && !(flag & IxFNoWeb)) { if (m_dobeagle && !myfiles.empty() && !(flag & IxFNoWeb)) {
@ -189,8 +185,7 @@ bool ConfIndexer::indexFiles(list<string>& ifiles, int flag)
#endif #endif
// The close would be done in our destructor, but we want status here // The close would be done in our destructor, but we want status here
if (!m_db.close()) { if (!m_db.close()) {
LOGERR(("ConfIndexer::index: error closing database in %s\n", LOGERR("ConfIndexer::index: error closing database in " << (m_config->getDbDir()) << "\n" );
m_config->getDbDir().c_str()));
return false; return false;
} }
ifiles = myfiles; ifiles = myfiles;
@ -214,8 +209,7 @@ bool ConfIndexer::docsToPaths(vector<Rcl::Doc> &docs, vector<string> &paths)
// Filesystem document. The url has to be like file:// // Filesystem document. The url has to be like file://
if (idoc.url.find(cstr_fileu) != 0) { if (idoc.url.find(cstr_fileu) != 0) {
LOGERR(("idx::docsToPaths: FS backend and non fs url: [%s]\n", LOGERR("idx::docsToPaths: FS backend and non fs url: [" << (idoc.url) << "]\n" );
idoc.url.c_str()));
continue; continue;
} }
paths.push_back(idoc.url.substr(7, string::npos)); paths.push_back(idoc.url.substr(7, string::npos));
@ -247,8 +241,7 @@ bool ConfIndexer::purgeFiles(std::list<string> &files, int flag)
myfiles.sort(); myfiles.sort();
if (!m_db.open(Rcl::Db::DbUpd)) { if (!m_db.open(Rcl::Db::DbUpd)) {
LOGERR(("ConfIndexer: purgeFiles error opening database %s\n", LOGERR("ConfIndexer: purgeFiles error opening database " << (m_config->getDbDir()) << "\n" );
m_config->getDbDir().c_str()));
return false; return false;
} }
bool ret = false; bool ret = false;
@ -272,8 +265,7 @@ bool ConfIndexer::purgeFiles(std::list<string> &files, int flag)
// The close would be done in our destructor, but we want status here // The close would be done in our destructor, but we want status here
if (!m_db.close()) { if (!m_db.close()) {
LOGERR(("ConfIndexer::purgefiles: error closing database in %s\n", LOGERR("ConfIndexer::purgefiles: error closing database in " << (m_config->getDbDir()) << "\n" );
m_config->getDbDir().c_str()));
return false; return false;
} }
return ret; return ret;
@ -286,7 +278,7 @@ bool ConfIndexer::createStemmingDatabases()
string slangs; string slangs;
if (m_config->getConfParam("indexstemminglanguages", slangs)) { if (m_config->getConfParam("indexstemminglanguages", slangs)) {
if (!m_db.open(Rcl::Db::DbUpd)) { if (!m_db.open(Rcl::Db::DbUpd)) {
LOGERR(("ConfIndexer::createStemmingDb: could not open db\n")) LOGERR("ConfIndexer::createStemmingDb: could not open db\n" );
return false; return false;
} }
vector<string> langs; vector<string> langs;
@ -319,7 +311,7 @@ bool ConfIndexer::createStemDb(const string &lang)
// module, either from a configuration variable or the NLS environment. // module, either from a configuration variable or the NLS environment.
bool ConfIndexer::createAspellDict() bool ConfIndexer::createAspellDict()
{ {
LOGDEB2(("ConfIndexer::createAspellDict()\n")); LOGDEB2("ConfIndexer::createAspellDict()\n" );
#ifdef RCL_USE_ASPELL #ifdef RCL_USE_ASPELL
// For the benefit of the real-time indexer, we only initialize // For the benefit of the real-time indexer, we only initialize
// noaspell from the configuration once. It can then be set to // noaspell from the configuration once. It can then be set to
@ -334,22 +326,20 @@ bool ConfIndexer::createAspellDict()
return true; return true;
if (!m_db.open(Rcl::Db::DbRO)) { if (!m_db.open(Rcl::Db::DbRO)) {
LOGERR(("ConfIndexer::createAspellDict: could not open db\n")); LOGERR("ConfIndexer::createAspellDict: could not open db\n" );
return false; return false;
} }
Aspell aspell(m_config); Aspell aspell(m_config);
string reason; string reason;
if (!aspell.init(reason)) { if (!aspell.init(reason)) {
LOGERR(("ConfIndexer::createAspellDict: aspell init failed: %s\n", LOGERR("ConfIndexer::createAspellDict: aspell init failed: " << (reason) << "\n" );
reason.c_str()));
noaspell = true; noaspell = true;
return false; return false;
} }
LOGDEB(("ConfIndexer::createAspellDict: creating dictionary\n")); LOGDEB("ConfIndexer::createAspellDict: creating dictionary\n" );
if (!aspell.buildDict(m_db, reason)) { if (!aspell.buildDict(m_db, reason)) {
LOGERR(("ConfIndexer::createAspellDict: aspell buildDict failed: %s\n", LOGERR("ConfIndexer::createAspellDict: aspell buildDict failed: " << (reason) << "\n" );
reason.c_str()));
noaspell = true; noaspell = true;
return false; return false;
} }
@ -361,3 +351,4 @@ vector<string> ConfIndexer::getStemmerNames()
{ {
return Rcl::Db::getStemmerNames(); return Rcl::Db::getStemmerNames();
} }

View file

@ -26,7 +26,7 @@
using namespace std; using namespace std;
#include "mimetype.h" #include "mimetype.h"
#include "debuglog.h" #include "log.h"
#include "execmd.h" #include "execmd.h"
#include "rclconfig.h" #include "rclconfig.h"
#include "smallut.h" #include "smallut.h"
@ -64,7 +64,7 @@ static string mimetypefromdata(RclConfig *cfg, const string &fn, bool usfc)
vector<string> cmd; vector<string> cmd;
string scommand; string scommand;
if (cfg->getConfParam("systemfilecommand", scommand)) { if (cfg->getConfParam("systemfilecommand", scommand)) {
LOGDEB2(("mimetype: syscmd from config: %s\n", scommand.c_str())); LOGDEB2("mimetype: syscmd from config: " << (scommand) << "\n" );
stringToStrings(scommand, cmd); stringToStrings(scommand, cmd);
string exe; string exe;
if (cmd.empty()) { if (cmd.empty()) {
@ -76,19 +76,17 @@ static string mimetypefromdata(RclConfig *cfg, const string &fn, bool usfc)
} }
cmd.push_back(fn); cmd.push_back(fn);
} else { } else {
LOGDEB(("mimetype:systemfilecommand not found, using %s\n", LOGDEB("mimetype:systemfilecommand not found, using " << (stringsToString(tradfilecmd)) << "\n" );
stringsToString(tradfilecmd).c_str()));
cmd = tradfilecmd; cmd = tradfilecmd;
} }
string result; string result;
if (!ExecCmd::backtick(cmd, result)) { if (!ExecCmd::backtick(cmd, result)) {
LOGERR(("mimetypefromdata: exec %s failed\n", LOGERR("mimetypefromdata: exec " << (stringsToString(cmd)) << " failed\n" );
stringsToString(cmd).c_str()));
return string(); return string();
} }
trimstring(result, " \t\n\r"); trimstring(result, " \t\n\r");
LOGDEB2(("mimetype: systemfilecommand output [%s]\n", result.c_str())); LOGDEB2("mimetype: systemfilecommand output [" << (result) << "]\n" );
// The normal output from "file -i" looks like the following: // The normal output from "file -i" looks like the following:
// thefilename.xxx: text/plain; charset=us-ascii // thefilename.xxx: text/plain; charset=us-ascii
@ -109,8 +107,7 @@ static string mimetypefromdata(RclConfig *cfg, const string &fn, bool usfc)
if (result.find(fn) != 0) { if (result.find(fn) != 0) {
// Garbage "file" output. Maybe the result of a charset // Garbage "file" output. Maybe the result of a charset
// conversion attempt? // conversion attempt?
LOGERR(("mimetype: can't interpret 'file' output: [%s]\n", LOGERR("mimetype: can't interpret 'file' output: [" << (result) << "]\n" );
result.c_str()));
return string(); return string();
} }
result = result.substr(fn.size()); result = result.substr(fn.size());
@ -164,9 +161,9 @@ string mimetype(const string &fn, const struct stat *stp,
// Extended attribute has priority on everything, as per: // Extended attribute has priority on everything, as per:
// http://freedesktop.org/wiki/CommonExtendedAttributes // http://freedesktop.org/wiki/CommonExtendedAttributes
if (pxattr::get(fn, "mime_type", &mtype)) { if (pxattr::get(fn, "mime_type", &mtype)) {
LOGDEB0(("Mimetype: 'mime_type' xattr : [%s]\n", mtype.c_str())); LOGDEB0("Mimetype: 'mime_type' xattr : [" << (mtype) << "]\n" );
if (mtype.empty()) { if (mtype.empty()) {
LOGDEB0(("Mimetype: getxattr() returned empty mime type !\n")); LOGDEB0("Mimetype: getxattr() returned empty mime type !\n" );
} else { } else {
return mtype; return mtype;
} }
@ -174,12 +171,12 @@ string mimetype(const string &fn, const struct stat *stp,
#endif #endif
if (cfg == 0) { if (cfg == 0) {
LOGERR(("Mimetype: null config ??\n")); LOGERR("Mimetype: null config ??\n" );
return mtype; return mtype;
} }
if (cfg->inStopSuffixes(fn)) { if (cfg->inStopSuffixes(fn)) {
LOGDEB(("mimetype: fn [%s] in stopsuffixes\n", fn.c_str())); LOGDEB("mimetype: fn [" << (fn) << "] in stopsuffixes\n" );
return mtype; return mtype;
} }
@ -211,7 +208,8 @@ string mimetype(const string &fn, const struct stat *stp,
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
#include "debuglog.h" #include "log.h"
#include "rclconfig.h" #include "rclconfig.h"
#include "rclinit.h" #include "rclinit.h"
#include "mimetype.h" #include "mimetype.h"
@ -245,3 +243,4 @@ int main(int argc, const char **argv)
#endif // TEST #endif // TEST

View file

@ -37,9 +37,10 @@
using std::list; using std::list;
using std::vector; using std::vector;
#include "debuglog.h" #include "log.h"
#include "rclmon.h" #include "rclmon.h"
#include "debuglog.h" #include "log.h"
#include "execmd.h" #include "execmd.h"
#include "recollindex.h" #include "recollindex.h"
#include "pathut.h" #include "pathut.h"
@ -167,7 +168,7 @@ void RclEQData::readDelayPats(int dfltsecs)
vector<string> dplist; vector<string> dplist;
if (!stringToStrings(patstring, dplist)) { if (!stringToStrings(patstring, dplist)) {
LOGERR(("rclEQData: bad pattern list: [%s]\n", patstring.c_str())); LOGERR("rclEQData: bad pattern list: [" << (patstring) << "]\n" );
return; return;
} }
@ -182,8 +183,7 @@ void RclEQData::readDelayPats(int dfltsecs)
dp.seconds = dfltsecs; dp.seconds = dfltsecs;
} }
m_delaypats.push_back(dp); m_delaypats.push_back(dp);
LOGDEB2(("rclmon::readDelayPats: add [%s] %d\n", LOGDEB2("rclmon::readDelayPats: add [" << (dp.pattern) << "] " << (dp.seconds) << "\n" );
dp.pattern.c_str(), dp.seconds));
} }
} }
@ -246,14 +246,12 @@ bool RclMonEventQueue::wait(int seconds, bool *top)
MONDEB(("RclMonEventQueue:: timeout\n")); MONDEB(("RclMonEventQueue:: timeout\n"));
return true; return true;
} }
LOGERR(("RclMonEventQueue::wait:pthread_cond_timedwait failed" LOGERR("RclMonEventQueue::wait:pthread_cond_timedwait failedwith err " << (err) << "\n" );
"with err %d\n", err));
return false; return false;
} }
} else { } else {
if ((err = pthread_cond_wait(&m_data->m_cond, &m_data->m_mutex))) { if ((err = pthread_cond_wait(&m_data->m_cond, &m_data->m_mutex))) {
LOGERR(("RclMonEventQueue::wait: pthread_cond_wait failed" LOGERR("RclMonEventQueue::wait: pthread_cond_wait failedwith err " << (err) << "\n" );
"with err %d\n", err));
return false; return false;
} }
} }
@ -265,7 +263,7 @@ bool RclMonEventQueue::lock()
{ {
MONDEB(("RclMonEventQueue:: lock\n")); MONDEB(("RclMonEventQueue:: lock\n"));
if (pthread_mutex_lock(&m_data->m_mutex)) { if (pthread_mutex_lock(&m_data->m_mutex)) {
LOGERR(("RclMonEventQueue::lock: pthread_mutex_lock failed\n")); LOGERR("RclMonEventQueue::lock: pthread_mutex_lock failed\n" );
return false; return false;
} }
MONDEB(("RclMonEventQueue:: lock return\n")); MONDEB(("RclMonEventQueue:: lock return\n"));
@ -276,7 +274,7 @@ bool RclMonEventQueue::unlock()
{ {
MONDEB(("RclMonEventQueue:: unlock\n")); MONDEB(("RclMonEventQueue:: unlock\n"));
if (pthread_mutex_unlock(&m_data->m_mutex)) { if (pthread_mutex_unlock(&m_data->m_mutex)) {
LOGERR(("RclMonEventQueue::lock: pthread_mutex_unlock failed\n")); LOGERR("RclMonEventQueue::lock: pthread_mutex_unlock failed\n" );
return false; return false;
} }
return true; return true;
@ -298,15 +296,15 @@ RclConfig *RclMonEventQueue::getConfig()
bool RclMonEventQueue::ok() bool RclMonEventQueue::ok()
{ {
if (m_data == 0) { if (m_data == 0) {
LOGINFO(("RclMonEventQueue: not ok: bad state\n")); LOGINFO("RclMonEventQueue: not ok: bad state\n" );
return false; return false;
} }
if (stopindexing) { if (stopindexing) {
LOGINFO(("RclMonEventQueue: not ok: stop request\n")); LOGINFO("RclMonEventQueue: not ok: stop request\n" );
return false; return false;
} }
if (!m_data->m_ok) { if (!m_data->m_ok) {
LOGINFO(("RclMonEventQueue: not ok: queue terminated\n")); LOGINFO("RclMonEventQueue: not ok: queue terminated\n" );
return false; return false;
} }
return true; return true;
@ -489,15 +487,15 @@ bool startMonitor(RclConfig *conf, int opts)
rclEQ.setopts(opts); rclEQ.setopts(opts);
if (pthread_create(&rcv_thrid, 0, &rclMonRcvRun, &rclEQ) != 0) { if (pthread_create(&rcv_thrid, 0, &rclMonRcvRun, &rclEQ) != 0) {
LOGERR(("startMonitor: cant create event-receiving thread\n")); LOGERR("startMonitor: cant create event-receiving thread\n" );
return false; return false;
} }
if (!rclEQ.lock()) { if (!rclEQ.lock()) {
LOGERR(("startMonitor: cant lock queue ???\n")); LOGERR("startMonitor: cant lock queue ???\n" );
return false; return false;
} }
LOGDEB(("start_monitoring: entering main loop\n")); LOGDEB("start_monitoring: entering main loop\n" );
bool timedout; bool timedout;
time_t lastauxtime = time(0); time_t lastauxtime = time(0);
@ -515,7 +513,7 @@ bool startMonitor(RclConfig *conf, int opts)
#ifndef _WIN32 #ifndef _WIN32
bool x11dead = !(opts & RCLMON_NOX11) && !x11IsAlive(); bool x11dead = !(opts & RCLMON_NOX11) && !x11IsAlive();
if (x11dead) if (x11dead)
LOGDEB(("RclMonprc: x11 is dead\n")); LOGDEB("RclMonprc: x11 is dead\n" );
#else #else
bool x11dead = false; bool x11dead = false;
#endif #endif
@ -533,11 +531,11 @@ bool startMonitor(RclConfig *conf, int opts)
switch (ev.evtype()) { switch (ev.evtype()) {
case RclMonEvent::RCLEVT_MODIFY: case RclMonEvent::RCLEVT_MODIFY:
case RclMonEvent::RCLEVT_DIRCREATE: case RclMonEvent::RCLEVT_DIRCREATE:
LOGDEB0(("Monitor: Modify/Check on %s\n", ev.m_path.c_str())); LOGDEB0("Monitor: Modify/Check on " << (ev.m_path) << "\n" );
modified.push_back(ev.m_path); modified.push_back(ev.m_path);
break; break;
case RclMonEvent::RCLEVT_DELETE: case RclMonEvent::RCLEVT_DELETE:
LOGDEB0(("Monitor: Delete on %s\n", ev.m_path.c_str())); LOGDEB0("Monitor: Delete on " << (ev.m_path) << "\n" );
// If this is for a directory (which the caller should // If this is for a directory (which the caller should
// tell us because he knows), we should purge the db // tell us because he knows), we should purge the db
// of all the subtree, because on a directory rename, // of all the subtree, because on a directory rename,
@ -556,7 +554,7 @@ bool startMonitor(RclConfig *conf, int opts)
} }
break; break;
default: default:
LOGDEB(("Monitor: got Other on [%s]\n", ev.m_path.c_str())); LOGDEB("Monitor: got Other on [" << (ev.m_path) << "]\n" );
} }
} }
// Unlock queue before processing lists // Unlock queue before processing lists
@ -603,7 +601,7 @@ bool startMonitor(RclConfig *conf, int opts)
// Check for a config change // Check for a config change
if (!(opts & RCLMON_NOCONFCHECK) && o_reexec && conf->sourceChanged()) { if (!(opts & RCLMON_NOCONFCHECK) && o_reexec && conf->sourceChanged()) {
LOGDEB(("Rclmonprc: config changed, reexecuting myself\n")); LOGDEB("Rclmonprc: config changed, reexecuting myself\n" );
// We never want to have a -n option after a config // We never want to have a -n option after a config
// change. -n was added by the reexec after the initial // change. -n was added by the reexec after the initial
// pass even if it was not given on the command line // pass even if it was not given on the command line
@ -613,7 +611,7 @@ bool startMonitor(RclConfig *conf, int opts)
// Lock queue before waiting again // Lock queue before waiting again
rclEQ.lock(); rclEQ.lock();
} }
LOGDEB(("Rclmonprc: calling queue setTerminate\n")); LOGDEB("Rclmonprc: calling queue setTerminate\n" );
rclEQ.setTerminate(); rclEQ.setTerminate();
// We used to wait for the receiver thread here before returning, // We used to wait for the receiver thread here before returning,
@ -622,8 +620,9 @@ bool startMonitor(RclConfig *conf, int opts)
// we ever need several monitor invocations in the same process // we ever need several monitor invocations in the same process
// (can't foresee any reason why we'd want to do this). // (can't foresee any reason why we'd want to do this).
// pthread_join(rcv_thrid, 0); // pthread_join(rcv_thrid, 0);
LOGDEB(("Monitor: returning\n")); LOGDEB("Monitor: returning\n" );
return true; return true;
} }
#endif // RCL_MONITOR #endif // RCL_MONITOR

View file

@ -24,7 +24,7 @@
#include "safesysstat.h" #include "safesysstat.h"
#include "safeunistd.h" #include "safeunistd.h"
#include "debuglog.h" #include "log.h"
#include "rclmon.h" #include "rclmon.h"
#include "rclinit.h" #include "rclinit.h"
#include "fstreewalk.h" #include "fstreewalk.h"
@ -148,26 +148,17 @@ void *rclMonRcvRun(void *q)
{ {
RclMonEventQueue *queue = (RclMonEventQueue *)q; RclMonEventQueue *queue = (RclMonEventQueue *)q;
LOGDEB(("rclMonRcvRun: running\n")); LOGDEB("rclMonRcvRun: running\n" );
recoll_threadinit(); recoll_threadinit();
// Make a local copy of the configuration as it doesn't like // Make a local copy of the configuration as it doesn't like
// concurrent accesses. It's ok to copy it here as the other // concurrent accesses. It's ok to copy it here as the other
// thread will not work before we have sent events. // thread will not work before we have sent events.
RclConfig lconfig(*queue->getConfig()); RclConfig lconfig(*queue->getConfig());
string loglevel;
lconfig.getConfParam(string("daemloglevel"), loglevel);
if (loglevel.empty())
lconfig.getConfParam(string("loglevel"), loglevel);
if (!loglevel.empty()) {
int lev = atoi(loglevel.c_str());
DebugLog::getdbl()->setloglevel(lev);
}
// Create the fam/whatever interface object // Create the fam/whatever interface object
RclMonitor *mon; RclMonitor *mon;
if ((mon = makeMonitor()) == 0) { if ((mon = makeMonitor()) == 0) {
LOGERR(("rclMonRcvRun: makeMonitor failed\n")); LOGERR("rclMonRcvRun: makeMonitor failed\n" );
queue->setTerminate(); queue->setTerminate();
return 0; return 0;
} }
@ -176,8 +167,7 @@ void *rclMonRcvRun(void *q)
// Get top directories from config // Get top directories from config
vector<string> tdl = lconfig.getTopdirs(); vector<string> tdl = lconfig.getTopdirs();
if (tdl.empty()) { if (tdl.empty()) {
LOGERR(("rclMonRcvRun:: top directory list (topdirs param.) not" LOGERR("rclMonRcvRun:: top directory list (topdirs param.) notfound in config or Directory list parse error" );
"found in config or Directory list parse error"));
queue->setTerminate(); queue->setTerminate();
return 0; return 0;
} }
@ -196,14 +186,13 @@ void *rclMonRcvRun(void *q)
} else { } else {
walker.setOpts(FsTreeWalker::FtwOptNone); walker.setOpts(FsTreeWalker::FtwOptNone);
} }
LOGDEB(("rclMonRcvRun: walking %s\n", it->c_str())); LOGDEB("rclMonRcvRun: walking " << *it << "\n" );
if (walker.walk(*it, walkcb) != FsTreeWalker::FtwOk) { if (walker.walk(*it, walkcb) != FsTreeWalker::FtwOk) {
LOGERR(("rclMonRcvRun: tree walk failed\n")); LOGERR("rclMonRcvRun: tree walk failed\n" );
goto terminate; goto terminate;
} }
if (walker.getErrCnt() > 0) { if (walker.getErrCnt() > 0) {
LOGINFO(("rclMonRcvRun: fs walker errors: %s\n", LOGINFO("rclMonRcvRun: fs walker errors: " << (walker.getReason()) << "\n" );
walker.getReason().c_str()));
} }
} }
@ -213,7 +202,7 @@ void *rclMonRcvRun(void *q)
if (doweb) { if (doweb) {
string webqueuedir = lconfig.getWebQueueDir(); string webqueuedir = lconfig.getWebQueueDir();
if (!mon->addWatch(webqueuedir, true)) { if (!mon->addWatch(webqueuedir, true)) {
LOGERR(("rclMonRcvRun: addwatch (webqueuedir) failed\n")); LOGERR("rclMonRcvRun: addwatch (webqueuedir) failed\n" );
if (mon->saved_errno != EACCES && mon->saved_errno != ENOENT) if (mon->saved_errno != EACCES && mon->saved_errno != ENOENT)
goto terminate; goto terminate;
} }
@ -249,16 +238,13 @@ void *rclMonRcvRun(void *q)
// it seems that fam/gamin is doing the job for us so // it seems that fam/gamin is doing the job for us so
// that we are generating double events here (no big // that we are generating double events here (no big
// deal as prc will sort/merge). // deal as prc will sort/merge).
LOGDEB(("rclMonRcvRun: walking new dir %s\n", LOGDEB("rclMonRcvRun: walking new dir " << (ev.m_path) << "\n" );
ev.m_path.c_str()));
if (walker.walk(ev.m_path, walkcb) != FsTreeWalker::FtwOk) { if (walker.walk(ev.m_path, walkcb) != FsTreeWalker::FtwOk) {
LOGERR(("rclMonRcvRun: walking new dir %s: %s\n", LOGERR("rclMonRcvRun: walking new dir " << (ev.m_path) << ": " << (walker.getReason()) << "\n" );
ev.m_path.c_str(), walker.getReason().c_str()));
goto terminate; goto terminate;
} }
if (walker.getErrCnt() > 0) { if (walker.getErrCnt() > 0) {
LOGINFO(("rclMonRcvRun: fs walker errors: %s\n", LOGINFO("rclMonRcvRun: fs walker errors: " << (walker.getReason()) << "\n" );
walker.getReason().c_str()));
} }
} }
@ -269,7 +255,7 @@ void *rclMonRcvRun(void *q)
terminate: terminate:
queue->setTerminate(); queue->setTerminate();
LOGINFO(("rclMonRcvRun: monrcv thread routine returning\n")); LOGINFO("rclMonRcvRun: monrcv thread routine returning\n" );
return 0; return 0;
} }
@ -353,7 +339,7 @@ RclFAM::RclFAM()
: m_ok(false) : m_ok(false)
{ {
if (FAMOpen2(&m_conn, "Recoll")) { if (FAMOpen2(&m_conn, "Recoll")) {
LOGERR(("RclFAM::RclFAM: FAMOpen2 failed, errno %d\n", errno)); LOGERR("RclFAM::RclFAM: FAMOpen2 failed, errno " << (errno) << "\n" );
return; return;
} }
m_ok = true; m_ok = true;
@ -384,7 +370,7 @@ bool RclFAM::addWatch(const string& path, bool isdir)
// to unblock signals. SIGALRM is not used by the main thread, so at least // to unblock signals. SIGALRM is not used by the main thread, so at least
// ensure that we exit after gamin gets stuck. // ensure that we exit after gamin gets stuck.
if (setjmp(jbuf)) { if (setjmp(jbuf)) {
LOGERR(("RclFAM::addWatch: timeout talking to FAM\n")); LOGERR("RclFAM::addWatch: timeout talking to FAM\n" );
return false; return false;
} }
signal(SIGALRM, onalrm); signal(SIGALRM, onalrm);
@ -392,12 +378,12 @@ bool RclFAM::addWatch(const string& path, bool isdir)
FAMRequest req; FAMRequest req;
if (isdir) { if (isdir) {
if (FAMMonitorDirectory(&m_conn, path.c_str(), &req, 0) != 0) { if (FAMMonitorDirectory(&m_conn, path.c_str(), &req, 0) != 0) {
LOGERR(("RclFAM::addWatch: FAMMonitorDirectory failed\n")); LOGERR("RclFAM::addWatch: FAMMonitorDirectory failed\n" );
goto out; goto out;
} }
} else { } else {
if (FAMMonitorFile(&m_conn, path.c_str(), &req, 0) != 0) { if (FAMMonitorFile(&m_conn, path.c_str(), &req, 0) != 0) {
LOGERR(("RclFAM::addWatch: FAMMonitorFile failed\n")); LOGERR("RclFAM::addWatch: FAMMonitorFile failed\n" );
goto out; goto out;
} }
} }
@ -435,7 +421,7 @@ bool RclFAM::getEvent(RclMonEvent& ev, int msecs)
} }
int ret; int ret;
if ((ret=select(fam_fd+1, &readfds, 0, 0, msecs >= 0 ? &timeout : 0)) < 0) { if ((ret=select(fam_fd+1, &readfds, 0, 0, msecs >= 0 ? &timeout : 0)) < 0) {
LOGERR(("RclFAM::getEvent: select failed, errno %d\n", errno)); LOGERR("RclFAM::getEvent: select failed, errno " << (errno) << "\n" );
close(); close();
return false; return false;
} else if (ret == 0) { } else if (ret == 0) {
@ -462,7 +448,7 @@ bool RclFAM::getEvent(RclMonEvent& ev, int msecs)
MONDEB(("RclFAM::getEvent: call FAMNextEvent\n")); MONDEB(("RclFAM::getEvent: call FAMNextEvent\n"));
FAMEvent fe; FAMEvent fe;
if (FAMNextEvent(&m_conn, &fe) < 0) { if (FAMNextEvent(&m_conn, &fe) < 0) {
LOGERR(("RclFAM::getEvent: FAMNextEvent failed, errno %d\n", errno)); LOGERR("RclFAM::getEvent: FAMNextEvent failed, errno " << (errno) << "\n" );
close(); close();
return false; return false;
} }
@ -511,7 +497,7 @@ bool RclFAM::getEvent(RclMonEvent& ev, int msecs)
// Have to return something, this is different from an empty queue, // Have to return something, this is different from an empty queue,
// esp if we are trying to empty it... // esp if we are trying to empty it...
if (fe.code != FAMEndExist) if (fe.code != FAMEndExist)
LOGDEB(("RclFAM::getEvent: got other event %d!\n", fe.code)); LOGDEB("RclFAM::getEvent: got other event " << (fe.code) << "!\n" );
ev.m_etyp = RclMonEvent::RCLEVT_NONE; ev.m_etyp = RclMonEvent::RCLEVT_NONE;
break; break;
} }
@ -532,7 +518,7 @@ public:
: m_ok(false), m_fd(-1), m_evp(0), m_ep(0) : m_ok(false), m_fd(-1), m_evp(0), m_ep(0)
{ {
if ((m_fd = inotify_init()) < 0) { if ((m_fd = inotify_init()) < 0) {
LOGERR(("RclIntf:: inotify_init failed, errno %d\n", errno)); LOGERR("RclIntf:: inotify_init failed, errno " << (errno) << "\n" );
return; return;
} }
m_ok = true; m_ok = true;
@ -616,11 +602,9 @@ bool RclIntf::addWatch(const string& path, bool)
int wd; int wd;
if ((wd = inotify_add_watch(m_fd, path.c_str(), mask)) < 0) { if ((wd = inotify_add_watch(m_fd, path.c_str(), mask)) < 0) {
saved_errno = errno; saved_errno = errno;
LOGERR(("RclIntf::addWatch: inotify_add_watch failed. errno %d\n", LOGERR("RclIntf::addWatch: inotify_add_watch failed. errno " << (saved_errno) << "\n" );
saved_errno));
if (errno == ENOSPC) { if (errno == ENOSPC) {
LOGERR(("RclIntf::addWatch: ENOSPC error may mean that you need" LOGERR("RclIntf::addWatch: ENOSPC error may mean that you needincrease the inotify kernel constants. See inotify(7)\n" );
"increase the inotify kernel constants. See inotify(7)\n"));
} }
return false; return false;
} }
@ -649,7 +633,7 @@ bool RclIntf::getEvent(RclMonEvent& ev, int msecs)
int ret; int ret;
MONDEB(("RclIntf::getEvent: select\n")); MONDEB(("RclIntf::getEvent: select\n"));
if ((ret=select(m_fd + 1, &readfds, 0, 0, msecs >= 0 ? &timeout : 0)) < 0) { if ((ret=select(m_fd + 1, &readfds, 0, 0, msecs >= 0 ? &timeout : 0)) < 0) {
LOGERR(("RclIntf::getEvent: select failed, errno %d\n", errno)); LOGERR("RclIntf::getEvent: select failed, errno " << (errno) << "\n" );
close(); close();
return false; return false;
} else if (ret == 0) { } else if (ret == 0) {
@ -663,8 +647,7 @@ bool RclIntf::getEvent(RclMonEvent& ev, int msecs)
return false; return false;
int rret; int rret;
if ((rret=read(m_fd, m_evbuf, sizeof(m_evbuf))) <= 0) { if ((rret=read(m_fd, m_evbuf, sizeof(m_evbuf))) <= 0) {
LOGERR(("RclIntf::getEvent: read failed, %d->%d errno %d\n", LOGERR("RclIntf::getEvent: read failed, " << (sizeof(m_evbuf)) << "->" << (rret) << " errno " << (errno) << "\n" );
sizeof(m_evbuf), rret, errno));
close(); close();
return false; return false;
} }
@ -681,7 +664,7 @@ bool RclIntf::getEvent(RclMonEvent& ev, int msecs)
map<int,string>::const_iterator it; map<int,string>::const_iterator it;
if ((it = m_idtopath.find(evp->wd)) == m_idtopath.end()) { if ((it = m_idtopath.find(evp->wd)) == m_idtopath.end()) {
LOGERR(("RclIntf::getEvent: unknown wd %d\n", evp->wd)); LOGERR("RclIntf::getEvent: unknown wd " << (evp->wd) << "\n" );
return true; return true;
} }
ev.m_path = it->second; ev.m_path = it->second;
@ -721,13 +704,12 @@ bool RclIntf::getEvent(RclMonEvent& ev, int msecs)
} }
} else if (evp->mask & (IN_IGNORED)) { } else if (evp->mask & (IN_IGNORED)) {
if (!m_idtopath.erase(evp->wd)) { if (!m_idtopath.erase(evp->wd)) {
LOGDEB0(("Got IGNORE event for unknown watch\n")); LOGDEB0("Got IGNORE event for unknown watch\n" );
} else { } else {
eraseWatchSubTree(m_idtopath, ev.m_path); eraseWatchSubTree(m_idtopath, ev.m_path);
} }
} else { } else {
LOGDEB(("RclIntf::getEvent: unhandled event %s 0x%x %s\n", LOGDEB("RclIntf::getEvent: unhandled event " << (event_name(evp->mask)) << " 0x" << (evp->mask) << " " << (ev.m_path) << "\n" );
event_name(evp->mask), evp->mask, ev.m_path.c_str()));
return true; return true;
} }
return true; return true;
@ -748,8 +730,8 @@ static RclMonitor *makeMonitor()
return new RclFAM; return new RclFAM;
#endif #endif
#endif #endif
LOGINFO(("RclMonitor: neither Inotify nor Fam was compiled as " LOGINFO("RclMonitor: neither Inotify nor Fam was compiled as file system change notification interface\n" );
"file system change notification interface\n"));
return 0; return 0;
} }
#endif // RCL_MONITOR #endif // RCL_MONITOR

View file

@ -36,7 +36,7 @@
using namespace std; using namespace std;
#include "debuglog.h" #include "log.h"
#include "rclinit.h" #include "rclinit.h"
#include "indexer.h" #include "indexer.h"
#include "smallut.h" #include "smallut.h"
@ -148,7 +148,7 @@ class MyUpdater : public DbIxStatusUpdater {
// out and the indexing would go on, not good (ie: if the user // out and the indexing would go on, not good (ie: if the user
// logs in again, the new recollindex will fail). // logs in again, the new recollindex will fail).
if ((op_flags & OPT_m) && !(op_flags & OPT_x) && !x11IsAlive()) { if ((op_flags & OPT_m) && !(op_flags & OPT_x) && !x11IsAlive()) {
LOGDEB(("X11 session went away during initial indexing pass\n")); LOGDEB("X11 session went away during initial indexing pass\n" );
stopindexing = true; stopindexing = true;
return false; return false;
} }
@ -166,7 +166,7 @@ static MyUpdater *updater;
static void sigcleanup(int sig) static void sigcleanup(int sig)
{ {
fprintf(stderr, "Got signal, registering stop request\n"); fprintf(stderr, "Got signal, registering stop request\n");
LOGDEB(("Got signal, registering stop request\n")); LOGDEB("Got signal, registering stop request\n" );
CancelCheck::instance().setCancel(); CancelCheck::instance().setCancel();
stopindexing = 1; stopindexing = 1;
} }
@ -301,7 +301,7 @@ static bool checktopdirs(RclConfig *config, vector<string>& nonexist)
vector<string> tdl; vector<string> tdl;
if (!config->getConfParam("topdirs", &tdl)) { if (!config->getConfParam("topdirs", &tdl)) {
cerr << "No 'topdirs' parameter in configuration\n"; cerr << "No 'topdirs' parameter in configuration\n";
LOGERR(("recollindex:No 'topdirs' parameter in configuration\n"));; LOGERR("recollindex:No 'topdirs' parameter in configuration\n" );;
return false; return false;
} }
@ -310,12 +310,10 @@ static bool checktopdirs(RclConfig *config, vector<string>& nonexist)
if (!it->size() || !path_isabsolute(*it)) { if (!it->size() || !path_isabsolute(*it)) {
if ((*it)[0] == '~') { if ((*it)[0] == '~') {
cerr << "Tilde expansion failed: " << *it << endl; cerr << "Tilde expansion failed: " << *it << endl;
LOGERR(("recollindex: tilde expansion failed: %s\n", LOGERR("recollindex: tilde expansion failed: " << *it << "\n" );
it->c_str()));
} else { } else {
cerr << "Not an absolute path: " << *it << endl; cerr << "Not an absolute path: " << *it << endl;
LOGERR(("recollindex: not an absolute path: %s\n", LOGERR("recollindex: not an absolute path: " << *it << "\n" );
it->c_str()));
} }
return false; return false;
} }
@ -516,18 +514,14 @@ int main(int argc, char **argv)
string rundir; string rundir;
config->getConfParam("idxrundir", rundir); config->getConfParam("idxrundir", rundir);
if (!rundir.compare("tmp")) { if (!rundir.compare("tmp")) {
LOGINFO(("recollindex: changing current directory to [%s]\n", LOGINFO("recollindex: changing current directory to [" << (tmplocation()) << "]\n" );
tmplocation().c_str()));
if (chdir(tmplocation().c_str()) < 0) { if (chdir(tmplocation().c_str()) < 0) {
LOGERR(("chdir(%s) failed, errno %d\n", LOGERR("chdir(" << (tmplocation()) << ") failed, errno " << (errno) << "\n" );
tmplocation().c_str(), errno));
} }
} else if (!rundir.empty()) { } else if (!rundir.empty()) {
LOGINFO(("recollindex: changing current directory to [%s]\n", LOGINFO("recollindex: changing current directory to [" << (rundir) << "]\n" );
rundir.c_str()));
if (chdir(rundir.c_str()) < 0) { if (chdir(rundir.c_str()) < 0) {
LOGERR(("chdir(%s) failed, errno %d\n", LOGERR("chdir(" << (rundir) << ") failed, errno " << (errno) << "\n" );
rundir.c_str(), errno));
} }
} }
@ -550,10 +544,10 @@ int main(int argc, char **argv)
// Log something at LOGINFO to reset the trace file. Else at level // Log something at LOGINFO to reset the trace file. Else at level
// 3 it's not even truncated if all docs are up to date. // 3 it's not even truncated if all docs are up to date.
LOGINFO(("recollindex: starting up\n")); LOGINFO("recollindex: starting up\n" );
#ifndef _WIN32 #ifndef _WIN32
if (setpriority(PRIO_PROCESS, 0, 20) != 0) { if (setpriority(PRIO_PROCESS, 0, 20) != 0) {
LOGINFO(("recollindex: can't setpriority(), errno %d\n", errno)); LOGINFO("recollindex: can't setpriority(), errno " << (errno) << "\n" );
} }
// Try to ionice. This does not work on all platforms // Try to ionice. This does not work on all platforms
rclIxIonice(config); rclIxIonice(config);
@ -625,11 +619,11 @@ int main(int argc, char **argv)
Usage(); Usage();
lockorexit(&pidfile); lockorexit(&pidfile);
if (!(op_flags&OPT_D)) { if (!(op_flags&OPT_D)) {
LOGDEB(("recollindex: daemonizing\n")); LOGDEB("recollindex: daemonizing\n" );
#ifndef _WIN32 #ifndef _WIN32
if (daemon(0,0) != 0) { if (daemon(0,0) != 0) {
fprintf(stderr, "daemon() failed, errno %d\n", errno); fprintf(stderr, "daemon() failed, errno %d\n", errno);
LOGERR(("daemon() failed, errno %d\n", errno)); LOGERR("daemon() failed, errno " << (errno) << "\n" );
exit(1); exit(1);
} }
#endif #endif
@ -640,30 +634,29 @@ int main(int argc, char **argv)
// Not too sure if I have to redo the nice thing after daemon(), // Not too sure if I have to redo the nice thing after daemon(),
// can't hurt anyway (easier than testing on all platforms...) // can't hurt anyway (easier than testing on all platforms...)
if (setpriority(PRIO_PROCESS, 0, 20) != 0) { if (setpriority(PRIO_PROCESS, 0, 20) != 0) {
LOGINFO(("recollindex: can't setpriority(), errno %d\n", errno)); LOGINFO("recollindex: can't setpriority(), errno " << (errno) << "\n" );
} }
// Try to ionice. This does not work on all platforms // Try to ionice. This does not work on all platforms
rclIxIonice(config); rclIxIonice(config);
#endif #endif
if (sleepsecs > 0) { if (sleepsecs > 0) {
LOGDEB(("recollindex: sleeping %d\n", sleepsecs)); LOGDEB("recollindex: sleeping " << (sleepsecs) << "\n" );
for (int i = 0; i < sleepsecs; i++) { for (int i = 0; i < sleepsecs; i++) {
sleep(1); sleep(1);
// Check that x11 did not go away while we were sleeping. // Check that x11 did not go away while we were sleeping.
if (!(op_flags & OPT_x) && !x11IsAlive()) { if (!(op_flags & OPT_x) && !x11IsAlive()) {
LOGDEB(("X11 session went away during initial sleep period\n")); LOGDEB("X11 session went away during initial sleep period\n" );
exit(0); exit(0);
} }
} }
} }
if (!(op_flags & OPT_n)) { if (!(op_flags & OPT_n)) {
makeIndexerOrExit(config, inPlaceReset); makeIndexerOrExit(config, inPlaceReset);
LOGDEB(("Recollindex: initial indexing pass before monitoring\n")); LOGDEB("Recollindex: initial indexing pass before monitoring\n" );
if (!confindexer->index(rezero, ConfIndexer::IxTAll, indexerFlags) if (!confindexer->index(rezero, ConfIndexer::IxTAll, indexerFlags)
|| stopindexing) { || stopindexing) {
LOGERR(("recollindex, initial indexing pass failed, " LOGERR("recollindex, initial indexing pass failed, not going into monitor mode\n" );
"not going into monitor mode\n"));
exit(1); exit(1);
} else { } else {
// Record success of indexing pass with failed files retries. // Record success of indexing pass with failed files retries.
@ -674,7 +667,7 @@ int main(int argc, char **argv)
deleteZ(confindexer); deleteZ(confindexer);
#ifndef _WIN32 #ifndef _WIN32
o_reexec->insertArgs(vector<string>(1, "-n")); o_reexec->insertArgs(vector<string>(1, "-n"));
LOGINFO(("recollindex: reexecuting with -n after initial full pass\n")); LOGINFO("recollindex: reexecuting with -n after initial full pass\n" );
// Note that -n will be inside the reexec when we come // Note that -n will be inside the reexec when we come
// back, but the monitor will explicitely strip it before // back, but the monitor will explicitely strip it before
// starting a config change exec to ensure that we do a // starting a config change exec to ensure that we do a
@ -724,3 +717,4 @@ int main(int argc, char **argv)
return !status; return !status;
} }
} }

View file

@ -25,16 +25,15 @@
#include "searchdata.h" #include "searchdata.h"
#include "rclquery.h" #include "rclquery.h"
#include "subtreelist.h" #include "subtreelist.h"
#include "debuglog.h" #include "log.h"
bool subtreelist(RclConfig *config, const string& top, bool subtreelist(RclConfig *config, const string& top,
vector<string>& paths) vector<string>& paths)
{ {
LOGDEB(("subtreelist: top: [%s]\n", top.c_str())); LOGDEB("subtreelist: top: [" << (top) << "]\n" );
Rcl::Db rcldb(config); Rcl::Db rcldb(config);
if (!rcldb.open(Rcl::Db::DbRO)) { if (!rcldb.open(Rcl::Db::DbRO)) {
LOGERR(("subtreelist: can't open database in [%s]: %s\n", LOGERR("subtreelist: can't open database in [" << (config->getDbDir()) << "]: " << (rcldb.getReason()) << "\n" );
config->getDbDir().c_str(), rcldb.getReason().c_str()));
return false; return false;
} }
@ -129,3 +128,4 @@ int main(int argc, char **argv)
exit(0); exit(0);
} }
#endif #endif

View file

@ -21,7 +21,7 @@
#include "rclconfig.h" #include "rclconfig.h"
#include "pxattr.h" #include "pxattr.h"
#include "debuglog.h" #include "log.h"
#include "cstr.h" #include "cstr.h"
#include "rcldoc.h" #include "rcldoc.h"
#include "execmd.h" #include "execmd.h"
@ -33,8 +33,7 @@ static void docfieldfrommeta(RclConfig* cfg, const string& name,
const string &value, Rcl::Doc& doc) const string &value, Rcl::Doc& doc)
{ {
string fieldname = cfg->fieldCanon(name); string fieldname = cfg->fieldCanon(name);
LOGDEB0(("Internfile:: setting [%s] from cmd/xattr value [%s]\n", LOGDEB0("Internfile:: setting [" << (fieldname) << "] from cmd/xattr value [" << (value) << "]\n" );
fieldname.c_str(), value.c_str()));
if (fieldname == cstr_dj_keymd) { if (fieldname == cstr_dj_keymd) {
doc.dmtime = value; doc.dmtime = value;
} else { } else {
@ -45,17 +44,15 @@ static void docfieldfrommeta(RclConfig* cfg, const string& name,
void reapXAttrs(const RclConfig* cfg, const string& path, void reapXAttrs(const RclConfig* cfg, const string& path,
map<string, string>& xfields) map<string, string>& xfields)
{ {
LOGDEB2(("reapXAttrs: [%s]\n", path.c_str())); LOGDEB2("reapXAttrs: [" << (path) << "]\n" );
#ifndef _WIN32 #ifndef _WIN32
// Retrieve xattrs names from files and mapping table from config // Retrieve xattrs names from files and mapping table from config
vector<string> xnames; vector<string> xnames;
if (!pxattr::list(path, &xnames)) { if (!pxattr::list(path, &xnames)) {
if (errno == ENOTSUP) { if (errno == ENOTSUP) {
LOGDEB(("FileInterner::reapXattrs: pxattr::list: errno %d\n", LOGDEB("FileInterner::reapXattrs: pxattr::list: errno " << (errno) << "\n" );
errno));
} else { } else {
LOGERR(("FileInterner::reapXattrs: pxattr::list: errno %d\n", LOGERR("FileInterner::reapXattrs: pxattr::list: errno " << (errno) << "\n" );
errno));
} }
return; return;
} }
@ -77,13 +74,12 @@ void reapXAttrs(const RclConfig* cfg, const string& path,
} }
string value; string value;
if (!pxattr::get(path, *it, &value, pxattr::PXATTR_NOFOLLOW)) { if (!pxattr::get(path, *it, &value, pxattr::PXATTR_NOFOLLOW)) {
LOGERR(("FileInterner::reapXattrs: pxattr::get failed" LOGERR("FileInterner::reapXattrs: pxattr::get failedfor " << ((*it)) << ", errno " << (errno) << "\n" );
"for %s, errno %d\n", (*it).c_str(), errno));
continue; continue;
} }
// Encode should we ? // Encode should we ?
xfields[key] = value; xfields[key] = value;
LOGDEB2(("reapXAttrs: [%s] -> [%s]\n", key.c_str(), value.c_str())); LOGDEB2("reapXAttrs: [" << (key) << "] -> [" << (value) << "]\n" );
} }
#endif #endif
} }
@ -150,3 +146,4 @@ void docFieldsFromMetaCmds(RclConfig *cfg, const map<string, string>& cfields,
} }
} }
} }

View file

@ -18,9 +18,6 @@
#define _INDEXTEXT_H_INCLUDED_ #define _INDEXTEXT_H_INCLUDED_
/* Note: this only exists to help with using myhtmlparse.cc */ /* Note: this only exists to help with using myhtmlparse.cc */
// Minimize changes to myhtmlparse.cpp
#include "debuglog.h"
#include <string> #include <string>
// lets hope that the charset includes ascii values... // lets hope that the charset includes ascii values...

View file

@ -35,7 +35,7 @@ using namespace std;
#include "internfile.h" #include "internfile.h"
#include "rcldoc.h" #include "rcldoc.h"
#include "mimetype.h" #include "mimetype.h"
#include "debuglog.h" #include "log.h"
#include "mimehandler.h" #include "mimehandler.h"
#include "execmd.h" #include "execmd.h"
#include "pathut.h" #include "pathut.h"
@ -76,8 +76,7 @@ static string colon_restore(const string& in)
// (ie message having a given attachment) // (ie message having a given attachment)
bool FileInterner::getEnclosingUDI(const Rcl::Doc &doc, string& udi) bool FileInterner::getEnclosingUDI(const Rcl::Doc &doc, string& udi)
{ {
LOGDEB(("FileInterner::getEnclosingUDI(): url [%s] ipath [%s]\n", LOGDEB("FileInterner::getEnclosingUDI(): url [" << (doc.url) << "] ipath [" << (doc.ipath) << "]\n" );
doc.url.c_str(), doc.ipath.c_str()));
string eipath = doc.ipath; string eipath = doc.ipath;
string::size_type colon; string::size_type colon;
if (eipath.empty()) if (eipath.empty())
@ -119,9 +118,9 @@ FileInterner::FileInterner(const string &fn, const struct stat *stp,
RclConfig *cnf, int flags, const string *imime) RclConfig *cnf, int flags, const string *imime)
: m_ok(false), m_missingdatap(0), m_uncomp((flags & FIF_forPreview) != 0) : m_ok(false), m_missingdatap(0), m_uncomp((flags & FIF_forPreview) != 0)
{ {
LOGDEB0(("FileInterner::FileInterner(fn=%s)\n", fn.c_str())); LOGDEB0("FileInterner::FileInterner(fn=" << (fn) << ")\n" );
if (fn.empty()) { if (fn.empty()) {
LOGERR(("FileInterner::FileInterner: empty file name!\n")); LOGERR("FileInterner::FileInterner: empty file name!\n" );
return; return;
} }
initcommon(cnf, flags); initcommon(cnf, flags);
@ -132,7 +131,7 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
int flags, const string *imime) int flags, const string *imime)
{ {
if (f.empty()) { if (f.empty()) {
LOGERR(("FileInterner::init: empty file name!\n")); LOGERR("FileInterner::init: empty file name!\n" );
return; return;
} }
m_fn = f; m_fn = f;
@ -157,13 +156,14 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
// (e.g. the beagle indexer sets it). // (e.g. the beagle indexer sets it).
if (flags & FIF_doUseInputMimetype) { if (flags & FIF_doUseInputMimetype) {
if (!imime) { if (!imime) {
LOGERR(("FileInterner:: told to use null imime\n")); LOGERR("FileInterner:: told to use null imime\n" );
return; return;
} }
l_mime = *imime; l_mime = *imime;
} else { } else {
LOGDEB(("FileInterner::init fn [%s] mime [%s] preview %d\n", LOGDEB("FileInterner::init fn [" << f << "] mime [" <<
f.c_str(), imime?imime->c_str() : "(null)", m_forPreview)); (imime?imime->c_str() : "(null)") << "] preview " << m_forPreview
<< "\n" );
// Run mime type identification in any case (see comment above). // Run mime type identification in any case (see comment above).
l_mime = mimetype(m_fn, stp, m_cfg, usfci); l_mime = mimetype(m_fn, stp, m_cfg, usfci);
@ -190,14 +190,12 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
if (!m_uncomp.uncompressfile(m_fn, ucmd, m_tfile)) { if (!m_uncomp.uncompressfile(m_fn, ucmd, m_tfile)) {
return; return;
} }
LOGDEB1(("FileInterner:: after ucomp: tfile %s\n", LOGDEB1("FileInterner:: after ucomp: tfile " << (m_tfile) << "\n" );
m_tfile.c_str()));
m_fn = m_tfile; m_fn = m_tfile;
// Stat the uncompressed file, mainly to get the size // Stat the uncompressed file, mainly to get the size
struct stat ucstat; struct stat ucstat;
if (path_fileprops(m_fn, &ucstat) != 0) { if (path_fileprops(m_fn, &ucstat) != 0) {
LOGERR(("FileInterner: can't stat the uncompressed file" LOGERR("FileInterner: can't stat the uncompressed file[" << (m_fn) << "] errno " << (errno) << "\n" );
"[%s] errno %d\n", m_fn.c_str(), errno));
return; return;
} else { } else {
docsize = ucstat.st_size; docsize = ucstat.st_size;
@ -206,8 +204,7 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
if (l_mime.empty() && imime) if (l_mime.empty() && imime)
l_mime = *imime; l_mime = *imime;
} else { } else {
LOGINFO(("FileInterner:: %s over size limit %d kbs\n", LOGINFO("FileInterner:: " << (m_fn) << " over size limit " << (maxkbs) << " kbs\n" );
m_fn.c_str(), maxkbs));
} }
} }
} }
@ -215,7 +212,7 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
if (l_mime.empty()) { if (l_mime.empty()) {
// No mime type. We let it through as config may warrant that // No mime type. We let it through as config may warrant that
// we index all file names // we index all file names
LOGDEB0(("FileInterner:: no mime: [%s]\n", m_fn.c_str())); LOGDEB0("FileInterner:: no mime: [" << (m_fn) << "]\n" );
} }
// Look for appropriate handler (might still return empty) // Look for appropriate handler (might still return empty)
@ -224,8 +221,7 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
if (!df || df->is_unknown()) { if (!df || df->is_unknown()) {
// No real handler for this type, for now :( // No real handler for this type, for now :(
LOGDEB(("FileInterner:: unprocessed mime: [%s] [%s]\n", LOGDEB("FileInterner:: unprocessed mime: [" << (l_mime) << "] [" << (f) << "]\n" );
l_mime.c_str(), f.c_str()));
if (!df) if (!df)
return; return;
} }
@ -245,12 +241,12 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
df->set_docsize(docsize); df->set_docsize(docsize);
if (!df->set_document_file(l_mime, m_fn)) { if (!df->set_document_file(l_mime, m_fn)) {
delete df; delete df;
LOGERR(("FileInterner:: error converting %s\n", m_fn.c_str())); LOGERR("FileInterner:: error converting " << (m_fn) << "\n" );
return; return;
} }
m_handlers.push_back(df); m_handlers.push_back(df);
LOGDEB(("FileInterner:: init ok %s [%s]\n", l_mime.c_str(), m_fn.c_str())); LOGDEB("FileInterner:: init ok " << (l_mime) << " [" << (m_fn) << "]\n" );
m_ok = true; m_ok = true;
} }
@ -259,7 +255,7 @@ FileInterner::FileInterner(const string &data, RclConfig *cnf,
int flags, const string& imime) int flags, const string& imime)
: m_ok(false), m_missingdatap(0), m_uncomp((flags & FIF_forPreview) != 0) : m_ok(false), m_missingdatap(0), m_uncomp((flags & FIF_forPreview) != 0)
{ {
LOGDEB0(("FileInterner::FileInterner(data)\n")); LOGDEB0("FileInterner::FileInterner(data)\n" );
initcommon(cnf, flags); initcommon(cnf, flags);
init(data, cnf, flags, imime); init(data, cnf, flags, imime);
} }
@ -268,7 +264,7 @@ void FileInterner::init(const string &data, RclConfig *cnf,
int flags, const string& imime) int flags, const string& imime)
{ {
if (imime.empty()) { if (imime.empty()) {
LOGERR(("FileInterner: inmemory constructor needs input mime type\n")); LOGERR("FileInterner: inmemory constructor needs input mime type\n" );
return; return;
} }
m_mimetype = imime; m_mimetype = imime;
@ -279,7 +275,7 @@ void FileInterner::init(const string &data, RclConfig *cnf,
if (!df) { if (!df) {
// No handler for this type, for now :( if indexallfilenames // No handler for this type, for now :( if indexallfilenames
// is set in the config, this normally wont happen (we get mh_unknown) // is set in the config, this normally wont happen (we get mh_unknown)
LOGDEB(("FileInterner:: unprocessed mime [%s]\n", m_mimetype.c_str())); LOGDEB("FileInterner:: unprocessed mime [" << (m_mimetype) << "]\n" );
return; return;
} }
df->set_property(Dijon::Filter::OPERATING_MODE, df->set_property(Dijon::Filter::OPERATING_MODE,
@ -300,8 +296,7 @@ void FileInterner::init(const string &data, RclConfig *cnf,
} }
} }
if (!result) { if (!result) {
LOGINFO(("FileInterner:: set_doc failed inside for mtype %s\n", LOGINFO("FileInterner:: set_doc failed inside for mtype " << (m_mimetype) << "\n" );
m_mimetype.c_str()));
delete df; delete df;
return; return;
} }
@ -325,17 +320,17 @@ void FileInterner::initcommon(RclConfig *cnf, int flags)
FileInterner::FileInterner(const Rcl::Doc& idoc, RclConfig *cnf, int flags) FileInterner::FileInterner(const Rcl::Doc& idoc, RclConfig *cnf, int flags)
: m_ok(false), m_missingdatap(0), m_uncomp(((flags & FIF_forPreview) != 0)) : m_ok(false), m_missingdatap(0), m_uncomp(((flags & FIF_forPreview) != 0))
{ {
LOGDEB0(("FileInterner::FileInterner(idoc)\n")); LOGDEB0("FileInterner::FileInterner(idoc)\n" );
initcommon(cnf, flags); initcommon(cnf, flags);
DocFetcher *fetcher = docFetcherMake(cnf, idoc); DocFetcher *fetcher = docFetcherMake(cnf, idoc);
if (fetcher == 0) { if (fetcher == 0) {
LOGERR(("FileInterner:: no backend\n")); LOGERR("FileInterner:: no backend\n" );
return; return;
} }
DocFetcher::RawDoc rawdoc; DocFetcher::RawDoc rawdoc;
if (!fetcher->fetch(cnf, idoc, rawdoc)) { if (!fetcher->fetch(cnf, idoc, rawdoc)) {
LOGERR(("FileInterner:: fetcher failed\n")); LOGERR("FileInterner:: fetcher failed\n" );
return; return;
} }
switch (rawdoc.kind) { switch (rawdoc.kind) {
@ -350,7 +345,7 @@ FileInterner::FileInterner(const Rcl::Doc& idoc, RclConfig *cnf, int flags)
m_direct = true; m_direct = true;
break; break;
default: default:
LOGERR(("FileInterner::FileInterner(idoc): bad rawdoc kind ??\n")); LOGERR("FileInterner::FileInterner(idoc): bad rawdoc kind ??\n" );
} }
return; return;
} }
@ -359,7 +354,7 @@ bool FileInterner::makesig(RclConfig *cnf, const Rcl::Doc& idoc, string& sig)
{ {
DocFetcher *fetcher = docFetcherMake(cnf, idoc); DocFetcher *fetcher = docFetcherMake(cnf, idoc);
if (fetcher == 0) { if (fetcher == 0) {
LOGERR(("FileInterner::makesig no backend for doc\n")); LOGERR("FileInterner::makesig no backend for doc\n" );
return false; return false;
} }
@ -386,14 +381,12 @@ TempFile FileInterner::dataToTempFile(const string& dt, const string& mt)
// Create temp file with appropriate suffix for mime type // Create temp file with appropriate suffix for mime type
TempFile temp(new TempFileInternal(m_cfg->getSuffixFromMimeType(mt))); TempFile temp(new TempFileInternal(m_cfg->getSuffixFromMimeType(mt)));
if (!temp->ok()) { if (!temp->ok()) {
LOGERR(("FileInterner::dataToTempFile: cant create tempfile: %s\n", LOGERR("FileInterner::dataToTempFile: cant create tempfile: " << (temp->getreason()) << "\n" );
temp->getreason().c_str()));
return TempFile(); return TempFile();
} }
string reason; string reason;
if (!stringtofile(dt, temp->filename(), reason)) { if (!stringtofile(dt, temp->filename(), reason)) {
LOGERR(("FileInterner::dataToTempFile: stringtofile: %s\n", LOGERR("FileInterner::dataToTempFile: stringtofile: " << (reason) << "\n" );
reason.c_str()));
return TempFile(); return TempFile();
} }
return temp; return temp;
@ -404,7 +397,7 @@ TempFile FileInterner::dataToTempFile(const string& dt, const string& mt)
// RECFILTERROR HELPERNOTFOUND program1 [program2 ...] // RECFILTERROR HELPERNOTFOUND program1 [program2 ...]
void FileInterner::checkExternalMissing(const string& msg, const string& mt) void FileInterner::checkExternalMissing(const string& msg, const string& mt)
{ {
LOGDEB2(("checkExternalMissing: [%s]\n", msg.c_str())); LOGDEB2("checkExternalMissing: [" << (msg) << "]\n" );
if (m_missingdatap && msg.find("RECFILTERROR") == 0) { if (m_missingdatap && msg.find("RECFILTERROR") == 0) {
vector<string> verr; vector<string> verr;
stringToStrings(msg, verr); stringToStrings(msg, verr);
@ -496,10 +489,10 @@ static inline bool getKeyValue(const map<string, string>& docdata,
it = docdata.find(key); it = docdata.find(key);
if (it != docdata.end()) { if (it != docdata.end()) {
value = it->second; value = it->second;
LOGDEB2(("getKeyValue: [%s]->[%s]\n", key.c_str(), value.c_str())); LOGDEB2("getKeyValue: [" << (key) << "]->[" << (value) << "]\n" );
return true; return true;
} }
LOGDEB2(("getKeyValue: no value for [%s]\n", key.c_str())); LOGDEB2("getKeyValue: no value for [" << (key) << "]\n" );
return false; return false;
} }
@ -508,7 +501,7 @@ bool FileInterner::dijontorcl(Rcl::Doc& doc)
RecollFilter *df = m_handlers.back(); RecollFilter *df = m_handlers.back();
if (df == 0) { if (df == 0) {
//?? //??
LOGERR(("FileInterner::dijontorcl: null top handler ??\n")); LOGERR("FileInterner::dijontorcl: null top handler ??\n" );
return false; return false;
} }
const map<string, string>& docdata = df->get_meta_data(); const map<string, string>& docdata = df->get_meta_data();
@ -575,7 +568,7 @@ bool FileInterner::dijontorcl(Rcl::Doc& doc)
// actually complicated. // actually complicated.
void FileInterner::collectIpathAndMT(Rcl::Doc& doc) const void FileInterner::collectIpathAndMT(Rcl::Doc& doc) const
{ {
LOGDEB2(("FileInterner::collectIpathAndMT\n")); LOGDEB2("FileInterner::collectIpathAndMT\n" );
bool hasipath = false; bool hasipath = false;
if (!m_noxattrs) { if (!m_noxattrs) {
@ -624,7 +617,7 @@ void FileInterner::collectIpathAndMT(Rcl::Doc& doc) const
// Trim empty tail elements in ipath. // Trim empty tail elements in ipath.
if (hasipath) { if (hasipath) {
LOGDEB2(("IPATH [%s]\n", doc.ipath.c_str())); LOGDEB2("IPATH [" << (doc.ipath) << "]\n" );
string::size_type sit = doc.ipath.find_last_not_of(cstr_isep); string::size_type sit = doc.ipath.find_last_not_of(cstr_isep);
if (sit == string::npos) if (sit == string::npos)
doc.ipath.erase(); doc.ipath.erase();
@ -660,8 +653,7 @@ int FileInterner::addHandler()
getKeyValue(docdata, cstr_dj_keycharset, charset); getKeyValue(docdata, cstr_dj_keycharset, charset);
getKeyValue(docdata, cstr_dj_keymt, mimetype); getKeyValue(docdata, cstr_dj_keymt, mimetype);
LOGDEB(("FileInterner::addHandler: next_doc is %s target [%s]\n", LOGDEB("FileInterner::addHandler: next_doc is " << (mimetype) << " target [" << (m_targetMType) << "]\n" );
mimetype.c_str(), m_targetMType.c_str()));
// If we find a document of the target type (text/plain in // If we find a document of the target type (text/plain in
// general), we're done decoding. If we hit text/plain, we're done // general), we're done decoding. If we hit text/plain, we're done
@ -669,7 +661,7 @@ int FileInterner::addHandler()
if (!stringicmp(mimetype, m_targetMType) || if (!stringicmp(mimetype, m_targetMType) ||
!stringicmp(mimetype, cstr_textplain)) { !stringicmp(mimetype, cstr_textplain)) {
m_reachedMType = mimetype; m_reachedMType = mimetype;
LOGDEB1(("FileInterner::addHandler: target reached\n")); LOGDEB1("FileInterner::addHandler: target reached\n" );
return ADD_BREAK; return ADD_BREAK;
} }
@ -677,7 +669,7 @@ int FileInterner::addHandler()
if (m_handlers.size() >= MAXHANDLERS) { if (m_handlers.size() >= MAXHANDLERS) {
// Stack too big. Skip this and go on to check if there is // Stack too big. Skip this and go on to check if there is
// something else in the current back() // something else in the current back()
LOGERR(("FileInterner::addHandler: stack too high\n")); LOGERR("FileInterner::addHandler: stack too high\n" );
return ADD_CONTINUE; return ADD_CONTINUE;
} }
@ -685,8 +677,7 @@ int FileInterner::addHandler()
if (!newflt) { if (!newflt) {
// If we can't find a handler, this doc can't be handled // If we can't find a handler, this doc can't be handled
// but there can be other ones so we go on // but there can be other ones so we go on
LOGINFO(("FileInterner::addHandler: no filter for [%s]\n", LOGINFO("FileInterner::addHandler: no filter for [" << (mimetype) << "]\n" );
mimetype.c_str()));
return ADD_CONTINUE; return ADD_CONTINUE;
} }
newflt->set_property(Dijon::Filter::OPERATING_MODE, newflt->set_property(Dijon::Filter::OPERATING_MODE,
@ -725,8 +716,7 @@ int FileInterner::addHandler()
} }
} }
if (!setres) { if (!setres) {
LOGINFO(("FileInterner::addHandler: set_doc failed inside %s " LOGINFO("FileInterner::addHandler: set_doc failed inside " << (m_fn) << " for mtype " << (mimetype) << "\n" );
" for mtype %s\n", m_fn.c_str(), mimetype.c_str()));
delete newflt; delete newflt;
if (m_forPreview) if (m_forPreview)
return ADD_ERROR; return ADD_ERROR;
@ -734,7 +724,7 @@ int FileInterner::addHandler()
} }
// add handler and go on, maybe this one will give us text... // add handler and go on, maybe this one will give us text...
m_handlers.push_back(newflt); m_handlers.push_back(newflt);
LOGDEB1(("FileInterner::addHandler: added\n")); LOGDEB1("FileInterner::addHandler: added\n" );
return ADD_OK; return ADD_OK;
} }
@ -744,21 +734,19 @@ void FileInterner::processNextDocError(Rcl::Doc &doc)
collectIpathAndMT(doc); collectIpathAndMT(doc);
m_reason = m_handlers.back()->get_error(); m_reason = m_handlers.back()->get_error();
checkExternalMissing(m_reason, doc.mimetype); checkExternalMissing(m_reason, doc.mimetype);
LOGERR(("FileInterner::internfile: next_document error " LOGERR("FileInterner::internfile: next_document error [" << (m_fn) << "" << (doc.ipath.empty() ? "" : "|") << "" << (doc.ipath) << "] " << (doc.mimetype) << " " << (m_reason) << "\n" );
"[%s%s%s] %s %s\n", m_fn.c_str(), doc.ipath.empty() ? "" : "|",
doc.ipath.c_str(), doc.mimetype.c_str(), m_reason.c_str()));
} }
FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath) FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath)
{ {
LOGDEB(("FileInterner::internfile. ipath [%s]\n", ipath.c_str())); LOGDEB("FileInterner::internfile. ipath [" << (ipath) << "]\n" );
// Get rid of possible image tempfile from older call // Get rid of possible image tempfile from older call
m_imgtmp.reset(); m_imgtmp.reset();
if (m_handlers.size() < 1) { if (m_handlers.size() < 1) {
// Just means the constructor failed // Just means the constructor failed
LOGDEB(("FileInterner::internfile: no handler: constructor failed\n")); LOGDEB("FileInterner::internfile: no handler: constructor failed\n" );
return FIError; return FIError;
} }
@ -777,7 +765,7 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath
} }
vipath.insert(vipath.begin(), lipath.begin(), lipath.end()); vipath.insert(vipath.begin(), lipath.begin(), lipath.end());
if (!m_handlers.back()->skip_to_document(vipath[m_handlers.size()-1])){ if (!m_handlers.back()->skip_to_document(vipath[m_handlers.size()-1])){
LOGERR(("FileInterner::internfile: can't skip\n")); LOGERR("FileInterner::internfile: can't skip\n" );
return FIError; return FIError;
} }
} }
@ -793,7 +781,7 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath
while (!m_handlers.empty()) { while (!m_handlers.empty()) {
CancelCheck::instance().checkCancel(); CancelCheck::instance().checkCancel();
if (loop++ > 1000) { if (loop++ > 1000) {
LOGERR(("FileInterner:: looping!\n")); LOGERR("FileInterner:: looping!\n" );
return FIError; return FIError;
} }
// If there are no more docs at the current top level we pop and // If there are no more docs at the current top level we pop and
@ -805,7 +793,7 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath
if (m_forPreview) { if (m_forPreview) {
m_reason += "Requested document does not exist. "; m_reason += "Requested document does not exist. ";
m_reason += m_handlers.back()->get_error(); m_reason += m_handlers.back()->get_error();
LOGERR(("FileInterner: requested document does not exist\n")); LOGERR("FileInterner: requested document does not exist\n" );
return FIError; return FIError;
} }
popHandler(); popHandler();
@ -820,7 +808,7 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath
if (m_forPreview) { if (m_forPreview) {
m_reason += "Requested document does not exist. "; m_reason += "Requested document does not exist. ";
m_reason += m_handlers.back()->get_error(); m_reason += m_handlers.back()->get_error();
LOGERR(("FileInterner: requested document does not exist\n")); LOGERR("FileInterner: requested document does not exist\n" );
return FIError; return FIError;
} }
popHandler(); popHandler();
@ -831,20 +819,20 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath
// handler to stack. // handler to stack.
switch (addHandler()) { switch (addHandler()) {
case ADD_OK: // Just go through: handler has been stacked, use it case ADD_OK: // Just go through: handler has been stacked, use it
LOGDEB2(("addHandler returned OK\n")); LOGDEB2("addHandler returned OK\n" );
break; break;
case ADD_CONTINUE: case ADD_CONTINUE:
// forget this doc and retrieve next from current handler // forget this doc and retrieve next from current handler
// (ipath stays same) // (ipath stays same)
LOGDEB2(("addHandler returned CONTINUE\n")); LOGDEB2("addHandler returned CONTINUE\n" );
continue; continue;
case ADD_BREAK: case ADD_BREAK:
// Stop looping: doc type ok, need complete its processing // Stop looping: doc type ok, need complete its processing
// and return it // and return it
LOGDEB2(("addHandler returned BREAK\n")); LOGDEB2("addHandler returned BREAK\n" );
goto breakloop; // when you have to you have to goto breakloop; // when you have to you have to
case ADD_ERROR: case ADD_ERROR:
LOGDEB2(("addHandler returned ERROR\n")); LOGDEB2("addHandler returned ERROR\n" );
return FIError; return FIError;
} }
@ -858,14 +846,14 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath
if (!ipath.empty()) { if (!ipath.empty()) {
if (m_handlers.size() <= vipath.size() && if (m_handlers.size() <= vipath.size() &&
!m_handlers.back()->skip_to_document(vipath[m_handlers.size()-1])) { !m_handlers.back()->skip_to_document(vipath[m_handlers.size()-1])) {
LOGERR(("FileInterner::internfile: can't skip\n")); LOGERR("FileInterner::internfile: can't skip\n" );
return FIError; return FIError;
} }
} }
} }
breakloop: breakloop:
if (m_handlers.empty()) { if (m_handlers.empty()) {
LOGDEB(("FileInterner::internfile: conversion ended with no doc\n")); LOGDEB("FileInterner::internfile: conversion ended with no doc\n" );
return FIError; return FIError;
} }
@ -908,7 +896,7 @@ bool FileInterner::tempFileForMT(TempFile& otemp, RclConfig* cnf,
TempFile temp(new TempFileInternal( TempFile temp(new TempFileInternal(
cnf->getSuffixFromMimeType(mimetype))); cnf->getSuffixFromMimeType(mimetype)));
if (!temp->ok()) { if (!temp->ok()) {
LOGERR(("FileInterner::interntofile: can't create temp file\n")); LOGERR("FileInterner::interntofile: can't create temp file\n" );
return false; return false;
} }
otemp = temp; otemp = temp;
@ -934,7 +922,7 @@ bool FileInterner::tempFileForMT(TempFile& otemp, RclConfig* cnf,
bool FileInterner::idocToFile(TempFile& otemp, const string& tofile, bool FileInterner::idocToFile(TempFile& otemp, const string& tofile,
RclConfig *cnf, const Rcl::Doc& idoc) RclConfig *cnf, const Rcl::Doc& idoc)
{ {
LOGDEB(("FileInterner::idocToFile\n")); LOGDEB("FileInterner::idocToFile\n" );
if (idoc.ipath.empty()) { if (idoc.ipath.empty()) {
return topdocToFile(otemp, tofile, cnf, idoc); return topdocToFile(otemp, tofile, cnf, idoc);
@ -953,12 +941,12 @@ bool FileInterner::topdocToFile(TempFile& otemp, const string& tofile,
{ {
DocFetcher *fetcher = docFetcherMake(cnf, idoc); DocFetcher *fetcher = docFetcherMake(cnf, idoc);
if (fetcher == 0) { if (fetcher == 0) {
LOGERR(("FileInterner::idocToFile no backend\n")); LOGERR("FileInterner::idocToFile no backend\n" );
return false; return false;
} }
DocFetcher::RawDoc rawdoc; DocFetcher::RawDoc rawdoc;
if (!fetcher->fetch(cnf, idoc, rawdoc)) { if (!fetcher->fetch(cnf, idoc, rawdoc)) {
LOGERR(("FileInterner::idocToFile fetcher failed\n")); LOGERR("FileInterner::idocToFile fetcher failed\n" );
return false; return false;
} }
const char *filename = ""; const char *filename = "";
@ -975,20 +963,18 @@ bool FileInterner::topdocToFile(TempFile& otemp, const string& tofile,
switch (rawdoc.kind) { switch (rawdoc.kind) {
case DocFetcher::RawDoc::RDK_FILENAME: case DocFetcher::RawDoc::RDK_FILENAME:
if (!copyfile(rawdoc.data.c_str(), filename, reason)) { if (!copyfile(rawdoc.data.c_str(), filename, reason)) {
LOGERR(("FileInterner::idocToFile: copyfile: %s\n", LOGERR("FileInterner::idocToFile: copyfile: " << (reason) << "\n" );
reason.c_str()));
return false; return false;
} }
break; break;
case DocFetcher::RawDoc::RDK_DATA: case DocFetcher::RawDoc::RDK_DATA:
if (!stringtofile(rawdoc.data, filename, reason)) { if (!stringtofile(rawdoc.data, filename, reason)) {
LOGERR(("FileInterner::idocToFile: stringtofile: %s\n", LOGERR("FileInterner::idocToFile: stringtofile: " << (reason) << "\n" );
reason.c_str()));
return false; return false;
} }
break; break;
default: default:
LOGERR(("FileInterner::FileInterner(idoc): bad rawdoc kind ??\n")); LOGERR("FileInterner::FileInterner(idoc): bad rawdoc kind ??\n" );
} }
if (tofile.empty()) if (tofile.empty())
@ -1000,13 +986,13 @@ bool FileInterner::interntofile(TempFile& otemp, const string& tofile,
const string& ipath, const string& mimetype) const string& ipath, const string& mimetype)
{ {
if (!ok()) { if (!ok()) {
LOGERR(("FileInterner::interntofile: constructor failed\n")); LOGERR("FileInterner::interntofile: constructor failed\n" );
return false; return false;
} }
Rcl::Doc doc; Rcl::Doc doc;
Status ret = internfile(doc, ipath); Status ret = internfile(doc, ipath);
if (ret == FileInterner::FIError) { if (ret == FileInterner::FIError) {
LOGERR(("FileInterner::interntofile: internfile() failed\n")); LOGERR("FileInterner::interntofile: internfile() failed\n" );
return false; return false;
} }
@ -1033,8 +1019,7 @@ bool FileInterner::interntofile(TempFile& otemp, const string& tofile,
} }
string reason; string reason;
if (!stringtofile(doc.text, filename, reason)) { if (!stringtofile(doc.text, filename, reason)) {
LOGERR(("FileInterner::interntofile: stringtofile : %s\n", LOGERR("FileInterner::interntofile: stringtofile : " << (reason) << "\n" );
reason.c_str()));
return false; return false;
} }
@ -1045,16 +1030,15 @@ bool FileInterner::interntofile(TempFile& otemp, const string& tofile,
bool FileInterner::isCompressed(const string& fn, RclConfig *cnf) bool FileInterner::isCompressed(const string& fn, RclConfig *cnf)
{ {
LOGDEB(("FileInterner::isCompressed: [%s]\n", fn.c_str())); LOGDEB("FileInterner::isCompressed: [" << (fn) << "]\n" );
struct stat st; struct stat st;
if (path_fileprops(fn, &st) < 0) { if (path_fileprops(fn, &st) < 0) {
LOGERR(("FileInterner::isCompressed: can't stat [%s]\n", fn.c_str())); LOGERR("FileInterner::isCompressed: can't stat [" << (fn) << "]\n" );
return false; return false;
} }
string l_mime = mimetype(fn, &st, cnf, true); string l_mime = mimetype(fn, &st, cnf, true);
if (l_mime.empty()) { if (l_mime.empty()) {
LOGERR(("FileInterner::isUncompressed: can't get mime for [%s]\n", LOGERR("FileInterner::isUncompressed: can't get mime for [" << (fn) << "]\n" );
fn.c_str()));
return false; return false;
} }
@ -1069,17 +1053,15 @@ bool FileInterner::isCompressed(const string& fn, RclConfig *cnf)
bool FileInterner::maybeUncompressToTemp(TempFile& temp, const string& fn, bool FileInterner::maybeUncompressToTemp(TempFile& temp, const string& fn,
RclConfig *cnf, const Rcl::Doc& doc) RclConfig *cnf, const Rcl::Doc& doc)
{ {
LOGDEB(("FileInterner::maybeUncompressToTemp: [%s]\n", fn.c_str())); LOGDEB("FileInterner::maybeUncompressToTemp: [" << (fn) << "]\n" );
struct stat st; struct stat st;
if (path_fileprops(fn.c_str(), &st) < 0) { if (path_fileprops(fn.c_str(), &st) < 0) {
LOGERR(("FileInterner::maybeUncompressToTemp: can't stat [%s]\n", LOGERR("FileInterner::maybeUncompressToTemp: can't stat [" << (fn) << "]\n" );
fn.c_str()));
return false; return false;
} }
string l_mime = mimetype(fn, &st, cnf, true); string l_mime = mimetype(fn, &st, cnf, true);
if (l_mime.empty()) { if (l_mime.empty()) {
LOGERR(("FileInterner::maybeUncompress.: can't id. mime for [%s]\n", LOGERR("FileInterner::maybeUncompress.: can't id. mime for [" << (fn) << "]\n" );
fn.c_str()));
return false; return false;
} }
@ -1091,14 +1073,13 @@ bool FileInterner::maybeUncompressToTemp(TempFile& temp, const string& fn,
int maxkbs = -1; int maxkbs = -1;
if (cnf->getConfParam("compressedfilemaxkbs", &maxkbs) && if (cnf->getConfParam("compressedfilemaxkbs", &maxkbs) &&
maxkbs >= 0 && int(st.st_size / 1024) > maxkbs) { maxkbs >= 0 && int(st.st_size / 1024) > maxkbs) {
LOGINFO(("FileInterner:: %s over size limit %d kbs\n", LOGINFO("FileInterner:: " << (fn) << " over size limit " << (maxkbs) << " kbs\n" );
fn.c_str(), maxkbs));
return false; return false;
} }
temp = temp =
TempFile(new TempFileInternal(cnf->getSuffixFromMimeType(doc.mimetype))); TempFile(new TempFileInternal(cnf->getSuffixFromMimeType(doc.mimetype)));
if (!temp->ok()) { if (!temp->ok()) {
LOGERR(("FileInterner: cant create temporary file")); LOGERR("FileInterner: cant create temporary file" );
return false; return false;
} }
@ -1113,9 +1094,7 @@ bool FileInterner::maybeUncompressToTemp(TempFile& temp, const string& fn,
// uncompressed file, hopefully staying on the same dev. // uncompressed file, hopefully staying on the same dev.
string reason; string reason;
if (!renameormove(uncomped.c_str(), temp->filename(), reason)) { if (!renameormove(uncomped.c_str(), temp->filename(), reason)) {
LOGERR(("FileInterner::maybeUncompress: move [%s] -> [%s] " LOGERR("FileInterner::maybeUncompress: move [" << (uncomped) << "] -> [" << (temp->filename()) << "] failed: " << (reason) << "\n" );
"failed: %s\n",
uncomped.c_str(), temp->filename(), reason.c_str()));
return false; return false;
} }
return true; return true;
@ -1131,7 +1110,8 @@ bool FileInterner::maybeUncompressToTemp(TempFile& temp, const string& fn,
using namespace std; using namespace std;
#include "debuglog.h" #include "log.h"
#include "rclinit.h" #include "rclinit.h"
#include "internfile.h" #include "internfile.h"
#include "rclconfig.h" #include "rclconfig.h"
@ -1232,3 +1212,4 @@ int main(int argc, char **argv)
} }
#endif // TEST_INTERNFILE #endif // TEST_INTERNFILE

View file

@ -26,7 +26,7 @@
#include "execmd.h" #include "execmd.h"
#include "mh_exec.h" #include "mh_exec.h"
#include "mh_html.h" #include "mh_html.h"
#include "debuglog.h" #include "log.h"
#include "cancelcheck.h" #include "cancelcheck.h"
#include "smallut.h" #include "smallut.h"
#include "md5ut.h" #include "md5ut.h"
@ -55,11 +55,10 @@ void MEAdv::reset()
void MEAdv::newData(int n) void MEAdv::newData(int n)
{ {
LOGDEB2(("MHExec:newData(%d)\n", n)); LOGDEB2("MHExec:newData(" << (n) << ")\n" );
if (m_filtermaxseconds > 0 && if (m_filtermaxseconds > 0 &&
time(0L) - m_start > m_filtermaxseconds) { time(0L) - m_start > m_filtermaxseconds) {
LOGERR(("MimeHandlerExec: filter timeout (%d S)\n", LOGERR("MimeHandlerExec: filter timeout (" << (m_filtermaxseconds) << " S)\n" );
m_filtermaxseconds));
throw HandlerTimeout(); throw HandlerTimeout();
} }
// If a cancel request was set by the signal handler (or by us // If a cancel request was set by the signal handler (or by us
@ -70,7 +69,7 @@ void MEAdv::newData(int n)
bool MimeHandlerExec::skip_to_document(const string& ipath) bool MimeHandlerExec::skip_to_document(const string& ipath)
{ {
LOGDEB(("MimeHandlerExec:skip_to_document: [%s]\n", ipath.c_str())); LOGDEB("MimeHandlerExec:skip_to_document: [" << (ipath) << "]\n" );
m_ipath = ipath; m_ipath = ipath;
return true; return true;
} }
@ -83,13 +82,13 @@ bool MimeHandlerExec::next_document()
return false; return false;
m_havedoc = false; m_havedoc = false;
if (missingHelper) { if (missingHelper) {
LOGDEB(("MimeHandlerExec::next_document(): helper known missing\n")); LOGDEB("MimeHandlerExec::next_document(): helper known missing\n" );
return false; return false;
} }
if (params.empty()) { if (params.empty()) {
// Hu ho // Hu ho
LOGERR(("MimeHandlerExec::mkDoc: empty params\n")); LOGERR("MimeHandlerExec::mkDoc: empty params\n" );
m_reason = "RECFILTERROR BADCONFIG"; m_reason = "RECFILTERROR BADCONFIG";
return false; return false;
} }
@ -118,16 +117,15 @@ bool MimeHandlerExec::next_document()
try { try {
status = mexec.doexec(cmd, myparams, 0, &output); status = mexec.doexec(cmd, myparams, 0, &output);
} catch (HandlerTimeout) { } catch (HandlerTimeout) {
LOGERR(("MimeHandlerExec: handler timeout\n")); LOGERR("MimeHandlerExec: handler timeout\n" );
status = 0x110f; status = 0x110f;
} catch (CancelExcept) { } catch (CancelExcept) {
LOGERR(("MimeHandlerExec: cancelled\n")); LOGERR("MimeHandlerExec: cancelled\n" );
status = 0x110f; status = 0x110f;
} }
if (status) { if (status) {
LOGERR(("MimeHandlerExec: command status 0x%x for %s\n", LOGERR("MimeHandlerExec: command status 0x" << (status) << " for " << (cmd) << "\n" );
status, cmd.c_str()));
if (WIFEXITED(status) && WEXITSTATUS(status) == 127) { if (WIFEXITED(status) && WEXITSTATUS(status) == 127) {
// That's how execmd signals a failed exec (most probably // That's how execmd signals a failed exec (most probably
// a missing command). Let'hope no filter uses the same value as // a missing command). Let'hope no filter uses the same value as
@ -195,10 +193,10 @@ void MimeHandlerExec::finaldetails()
if (MD5File(m_fn, md5, &reason)) { if (MD5File(m_fn, md5, &reason)) {
m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5); m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5);
} else { } else {
LOGERR(("MimeHandlerExec: cant compute md5 for [%s]: %s\n", LOGERR("MimeHandlerExec: cant compute md5 for [" << (m_fn) << "]: " << (reason) << "\n" );
m_fn.c_str(), reason.c_str()));
} }
} }
handle_cs(m_metaData[cstr_dj_keymt]); handle_cs(m_metaData[cstr_dj_keymt]);
} }

View file

@ -23,7 +23,7 @@ using namespace std;
#include "cstr.h" #include "cstr.h"
#include "mh_execm.h" #include "mh_execm.h"
#include "mh_html.h" #include "mh_html.h"
#include "debuglog.h" #include "log.h"
#include "cancelcheck.h" #include "cancelcheck.h"
#include "smallut.h" #include "smallut.h"
#include "md5ut.h" #include "md5ut.h"
@ -36,10 +36,10 @@ using namespace std;
bool MimeHandlerExecMultiple::startCmd() bool MimeHandlerExecMultiple::startCmd()
{ {
LOGDEB(("MimeHandlerExecMultiple::startCmd\n")); LOGDEB("MimeHandlerExecMultiple::startCmd\n" );
if (params.empty()) { if (params.empty()) {
// Hu ho // Hu ho
LOGERR(("MHExecMultiple::startCmd: empty params\n")); LOGERR("MHExecMultiple::startCmd: empty params\n" );
m_reason = "RECFILTERROR BADCONFIG"; m_reason = "RECFILTERROR BADCONFIG";
return false; return false;
} }
@ -86,15 +86,15 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data)
// Read name and length // Read name and length
if (m_cmd.getline(ibuf) <= 0) { if (m_cmd.getline(ibuf) <= 0) {
LOGERR(("MHExecMultiple: getline error\n")); LOGERR("MHExecMultiple: getline error\n" );
return false; return false;
} }
LOGDEB1(("MHEM:rde: line [%s]\n", ibuf.c_str())); LOGDEB1("MHEM:rde: line [" << (ibuf) << "]\n" );
// Empty line (end of message) ? // Empty line (end of message) ?
if (!ibuf.compare("\n")) { if (!ibuf.compare("\n")) {
LOGDEB(("MHExecMultiple: Got empty line\n")); LOGDEB("MHExecMultiple: Got empty line\n" );
name.clear(); name.clear();
return true; return true;
} }
@ -112,8 +112,7 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data)
vector<string> tokens; vector<string> tokens;
stringToTokens(ibuf, tokens); stringToTokens(ibuf, tokens);
if (tokens.size() != 2) { if (tokens.size() != 2) {
LOGERR(("MHExecMultiple: bad line in filter output: [%s]\n", LOGERR("MHExecMultiple: bad line in filter output: [" << (ibuf) << "]\n" );
ibuf.c_str()));
return false; return false;
} }
vector<string>::iterator it = tokens.begin(); vector<string>::iterator it = tokens.begin();
@ -121,13 +120,12 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data)
string& slen = *it; string& slen = *it;
int len; int len;
if (sscanf(slen.c_str(), "%d", &len) != 1) { if (sscanf(slen.c_str(), "%d", &len) != 1) {
LOGERR(("MHExecMultiple: bad line in filter output: [%s]\n", LOGERR("MHExecMultiple: bad line in filter output: [" << (ibuf) << "]\n" );
ibuf.c_str()));
return false; return false;
} }
if (len / 1024 > m_maxmemberkb) { if (len / 1024 > m_maxmemberkb) {
LOGERR(("MHExecMultiple: data len > maxmemberkb\n")); LOGERR("MHExecMultiple: data len > maxmemberkb\n" );
return false; return false;
} }
@ -144,24 +142,23 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data)
// Read element data // Read element data
datap->erase(); datap->erase();
if (len > 0 && m_cmd.receive(*datap, len) != len) { if (len > 0 && m_cmd.receive(*datap, len) != len) {
LOGERR(("MHExecMultiple: expected %d bytes of data, got %d\n", LOGERR("MHExecMultiple: expected " << (len) << " bytes of data, got " << (datap->length()) << "\n" );
len, datap->length()));
return false; return false;
} }
LOGDEB1(("MHExecMe:rdDtElt got: name [%s] len %d value [%s]\n", LOGDEB1("MHExecMe:rdDtElt got: name [" << name << "] len " << len <<
name.c_str(), len, datap->size() > 100 ? "value [" << (datap->size() > 100 ?
(datap->substr(0, 100) + " ...").c_str() : datap->c_str())); (datap->substr(0, 100) + " ...") : datap) << endl);
return true; return true;
} }
bool MimeHandlerExecMultiple::next_document() bool MimeHandlerExecMultiple::next_document()
{ {
LOGDEB(("MimeHandlerExecMultiple::next_document(): [%s]\n", m_fn.c_str())); LOGDEB("MimeHandlerExecMultiple::next_document(): [" << (m_fn) << "]\n" );
if (m_havedoc == false) if (m_havedoc == false)
return false; return false;
if (missingHelper) { if (missingHelper) {
LOGDEB(("MHExecMultiple::next_document(): helper known missing\n")); LOGDEB("MHExecMultiple::next_document(): helper known missing\n" );
return false; return false;
} }
@ -185,8 +182,7 @@ bool MimeHandlerExecMultiple::next_document()
if (MD5File(m_fn, md5, &reason)) { if (MD5File(m_fn, md5, &reason)) {
file_md5 = MD5HexPrint(md5, xmd5); file_md5 = MD5HexPrint(md5, xmd5);
} else { } else {
LOGERR(("MimeHandlerExecM: cant compute md5 for [%s]: %s\n", LOGERR("MimeHandlerExecM: cant compute md5 for [" << (m_fn) << "]: " << (reason) << "\n" );
m_fn.c_str(), reason.c_str()));
} }
} }
obuf << "FileName: " << m_fn.length() << "\n" << m_fn; obuf << "FileName: " << m_fn.length() << "\n" << m_fn;
@ -196,8 +192,7 @@ bool MimeHandlerExecMultiple::next_document()
obuf << "Filename: " << 0 << "\n"; obuf << "Filename: " << 0 << "\n";
} }
if (!m_ipath.empty()) { if (!m_ipath.empty()) {
LOGDEB(("next_doc: sending len %d val [%s]\n", m_ipath.length(), LOGDEB("next_doc: sending len " << (m_ipath.length()) << " val [" << (m_ipath) << "]\n" );
m_ipath.c_str()));
obuf << "Ipath: " << m_ipath.length() << "\n" << m_ipath; obuf << "Ipath: " << m_ipath.length() << "\n" << m_ipath;
} }
if (!m_dfltInputCharset.empty()) { if (!m_dfltInputCharset.empty()) {
@ -208,14 +203,14 @@ bool MimeHandlerExecMultiple::next_document()
obuf << "\n"; obuf << "\n";
if (m_cmd.send(obuf.str()) < 0) { if (m_cmd.send(obuf.str()) < 0) {
m_cmd.zapChild(); m_cmd.zapChild();
LOGERR(("MHExecMultiple: send error\n")); LOGERR("MHExecMultiple: send error\n" );
return false; return false;
} }
m_adv.reset(); m_adv.reset();
// Read answer (multiple elements) // Read answer (multiple elements)
LOGDEB1(("MHExecMultiple: reading answer\n")); LOGDEB1("MHExecMultiple: reading answer\n" );
bool eofnext_received = false; bool eofnext_received = false;
bool eofnow_received = false; bool eofnow_received = false;
bool fileerror_received = false; bool fileerror_received = false;
@ -231,47 +226,46 @@ bool MimeHandlerExecMultiple::next_document()
return false; return false;
} }
} catch (HandlerTimeout) { } catch (HandlerTimeout) {
LOGINFO(("MHExecMultiple: timeout\n")); LOGINFO("MHExecMultiple: timeout\n" );
m_cmd.zapChild(); m_cmd.zapChild();
return false; return false;
} catch (CancelExcept) { } catch (CancelExcept) {
LOGINFO(("MHExecMultiple: interrupt\n")); LOGINFO("MHExecMultiple: interrupt\n" );
m_cmd.zapChild(); m_cmd.zapChild();
return false; return false;
} }
if (name.empty()) if (name.empty())
break; break;
if (!stringlowercmp("eofnext:", name)) { if (!stringlowercmp("eofnext:", name)) {
LOGDEB(("MHExecMultiple: got EOFNEXT\n")); LOGDEB("MHExecMultiple: got EOFNEXT\n" );
eofnext_received = true; eofnext_received = true;
} else if (!stringlowercmp("eofnow:", name)) { } else if (!stringlowercmp("eofnow:", name)) {
LOGDEB(("MHExecMultiple: got EOFNOW\n")); LOGDEB("MHExecMultiple: got EOFNOW\n" );
eofnow_received = true; eofnow_received = true;
} else if (!stringlowercmp("fileerror:", name)) { } else if (!stringlowercmp("fileerror:", name)) {
LOGDEB(("MHExecMultiple: got FILEERROR\n")); LOGDEB("MHExecMultiple: got FILEERROR\n" );
fileerror_received = true; fileerror_received = true;
} else if (!stringlowercmp("subdocerror:", name)) { } else if (!stringlowercmp("subdocerror:", name)) {
LOGDEB(("MHExecMultiple: got SUBDOCERROR\n")); LOGDEB("MHExecMultiple: got SUBDOCERROR\n" );
subdocerror_received = true; subdocerror_received = true;
} else if (!stringlowercmp("ipath:", name)) { } else if (!stringlowercmp("ipath:", name)) {
ipath = data; ipath = data;
LOGDEB(("MHExecMultiple: got ipath [%s]\n", data.c_str())); LOGDEB("MHExecMultiple: got ipath [" << (data) << "]\n" );
} else if (!stringlowercmp("charset:", name)) { } else if (!stringlowercmp("charset:", name)) {
charset = data; charset = data;
LOGDEB(("MHExecMultiple: got charset [%s]\n", data.c_str())); LOGDEB("MHExecMultiple: got charset [" << (data) << "]\n" );
} else if (!stringlowercmp("mimetype:", name)) { } else if (!stringlowercmp("mimetype:", name)) {
mtype = data; mtype = data;
LOGDEB(("MHExecMultiple: got mimetype [%s]\n", data.c_str())); LOGDEB("MHExecMultiple: got mimetype [" << (data) << "]\n" );
} else { } else {
string nm = stringtolower((const string&)name); string nm = stringtolower((const string&)name);
trimstring(nm, ":"); trimstring(nm, ":");
LOGDEB(("MHExecMultiple: got [%s] -> [%s]\n", nm.c_str(), LOGDEB("MHExecMultiple: got [" << (nm) << "] -> [" << (data) << "]\n" );
data.c_str()));
m_metaData[nm] += data; m_metaData[nm] += data;
} }
if (loop == 20) { if (loop == 20) {
// ?? // ??
LOGERR(("MHExecMultiple: filter sent too many parameters\n")); LOGERR("MHExecMultiple: filter sent too many parameters\n" );
return false; return false;
} }
} }
@ -289,8 +283,7 @@ bool MimeHandlerExecMultiple::next_document()
// this was wrong. Empty documents can be found ie in zip files and should // this was wrong. Empty documents can be found ie in zip files and should
// not be interpreted as eof. // not be interpreted as eof.
if (m_metaData[cstr_dj_keycontent].empty()) { if (m_metaData[cstr_dj_keycontent].empty()) {
LOGDEB0(("MHExecMultiple: got empty document inside [%s]: [%s]\n", LOGDEB0("MHExecMultiple: got empty document inside [" << (m_fn) << "]: [" << (ipath) << "]\n" );
m_fn.c_str(), ipath.c_str()));
} }
if (!ipath.empty()) { if (!ipath.empty()) {
@ -300,8 +293,7 @@ bool MimeHandlerExecMultiple::next_document()
// string which we can use to compute a mime type // string which we can use to compute a mime type
m_metaData[cstr_dj_keyipath] = ipath; m_metaData[cstr_dj_keyipath] = ipath;
if (mtype.empty()) { if (mtype.empty()) {
LOGDEB0(("MHExecMultiple: no mime type from filter, " LOGDEB0("MHExecMultiple: no mime type from filter, using ipath for a guess\n" );
"using ipath for a guess\n"));
mtype = mimetype(ipath, 0, m_config, false); mtype = mimetype(ipath, 0, m_config, false);
if (mtype.empty()) { if (mtype.empty()) {
// mimetype() won't call idFile when there is no file. Do it // mimetype() won't call idFile when there is no file. Do it
@ -310,7 +302,7 @@ bool MimeHandlerExecMultiple::next_document()
// Note this happens for example for directory zip members // Note this happens for example for directory zip members
// We could recognize them by the end /, but wouldn't know // We could recognize them by the end /, but wouldn't know
// what to do with them anyway. // what to do with them anyway.
LOGINFO(("MHExecMultiple: cant guess mime type\n")); LOGINFO("MHExecMultiple: cant guess mime type\n" );
mtype = "application/octet-stream"; mtype = "application/octet-stream";
} }
} }
@ -335,10 +327,7 @@ bool MimeHandlerExecMultiple::next_document()
if (eofnext_received) if (eofnext_received)
m_havedoc = false; m_havedoc = false;
LOGDEB0(("MHExecMultiple: returning %d bytes of content," LOGDEB0("MHExecMultiple: returning " << (m_metaData[cstr_dj_keycontent].size()) << " bytes of content, mtype [" << (m_metaData[cstr_dj_keymt]) << "] charset [" << (m_metaData[cstr_dj_keycharset]) << "]\n" );
" mtype [%s] charset [%s]\n",
m_metaData[cstr_dj_keycontent].size(),
m_metaData[cstr_dj_keymt].c_str(),
m_metaData[cstr_dj_keycharset].c_str()));
return true; return true;
} }

View file

@ -17,7 +17,7 @@
#include "cstr.h" #include "cstr.h"
#include "mimehandler.h" #include "mimehandler.h"
#include "debuglog.h" #include "log.h"
#include "readfile.h" #include "readfile.h"
#include "transcode.h" #include "transcode.h"
#include "mimeparse.h" #include "mimeparse.h"
@ -36,11 +36,11 @@ using namespace std;
bool MimeHandlerHtml::set_document_file(const string& mt, const string &fn) bool MimeHandlerHtml::set_document_file(const string& mt, const string &fn)
{ {
LOGDEB0(("textHtmlToDoc: %s\n", fn.c_str())); LOGDEB0("textHtmlToDoc: " << (fn) << "\n" );
RecollFilter::set_document_file(mt, fn); RecollFilter::set_document_file(mt, fn);
string otext; string otext;
if (!file_to_string(fn, otext)) { if (!file_to_string(fn, otext)) {
LOGINFO(("textHtmlToDoc: cant read: %s\n", fn.c_str())); LOGINFO("textHtmlToDoc: cant read: " << (fn) << "\n" );
return false; return false;
} }
m_filename = fn; m_filename = fn;
@ -73,14 +73,12 @@ bool MimeHandlerHtml::next_document()
m_filename.erase(); m_filename.erase();
string charset = m_dfltInputCharset; string charset = m_dfltInputCharset;
LOGDEB(("MHHtml::next_doc.: default supposed input charset: [%s]\n", LOGDEB("MHHtml::next_doc.: default supposed input charset: [" << (charset) << "]\n" );
charset.c_str()));
// Override default input charset if someone took care to set one: // Override default input charset if someone took care to set one:
map<string,string>::const_iterator it = m_metaData.find(cstr_dj_keycharset); map<string,string>::const_iterator it = m_metaData.find(cstr_dj_keycharset);
if (it != m_metaData.end() && !it->second.empty()) { if (it != m_metaData.end() && !it->second.empty()) {
charset = it->second; charset = it->second;
LOGDEB(("MHHtml: next_doc.: input charset from ext. metadata: [%s]\n", LOGDEB("MHHtml: next_doc.: input charset from ext. metadata: [" << (charset) << "]\n" );
charset.c_str()));
} }
// - We first try to convert from the supposed charset // - We first try to convert from the supposed charset
@ -93,14 +91,13 @@ bool MimeHandlerHtml::next_document()
MyHtmlParser result; MyHtmlParser result;
for (int pass = 0; pass < 2; pass++) { for (int pass = 0; pass < 2; pass++) {
string transcoded; string transcoded;
LOGDEB(("Html::mkDoc: pass %d\n", pass)); LOGDEB("Html::mkDoc: pass " << (pass) << "\n" );
MyHtmlParser p; MyHtmlParser p;
// Try transcoding. If it fails, use original text. // Try transcoding. If it fails, use original text.
int ecnt; int ecnt;
if (!transcode(m_html, transcoded, charset, "UTF-8", &ecnt)) { if (!transcode(m_html, transcoded, charset, "UTF-8", &ecnt)) {
LOGDEB(("textHtmlToDoc: transcode failed from cs '%s' to UTF-8 for" LOGDEB("textHtmlToDoc: transcode failed from cs '" << (charset) << "' to UTF-8 for[" << (fn.empty()?"unknown":fn) << "]" );
"[%s]", charset.c_str(), fn.empty()?"unknown":fn.c_str()));
transcoded = m_html; transcoded = m_html;
// We don't know the charset, at all // We don't know the charset, at all
p.reset_charsets(); p.reset_charsets();
@ -108,11 +105,9 @@ bool MimeHandlerHtml::next_document()
} else { } else {
if (ecnt) { if (ecnt) {
if (pass == 0) { if (pass == 0) {
LOGDEB(("textHtmlToDoc: init transcode had %d errors for " LOGDEB("textHtmlToDoc: init transcode had " << (ecnt) << " errors for [" << (fn.empty()?"unknown":fn) << "]\n" );
"[%s]\n", ecnt, fn.empty()?"unknown":fn.c_str()));
} else { } else {
LOGERR(("textHtmlToDoc: final transcode had %d errors for " LOGERR("textHtmlToDoc: final transcode had " << (ecnt) << " errors for [" << (fn.empty()?"unknown":fn) << "]\n" );
"[%s]\n", ecnt, fn.empty()?"unknown":fn.c_str()));
} }
} }
// charset has the putative source charset, transcoded is now // charset has the putative source charset, transcoded is now
@ -150,16 +145,15 @@ bool MimeHandlerHtml::next_document()
break; break;
} }
LOGDEB(("textHtmlToDoc: charset [%s] doc charset [%s]\n", LOGDEB("textHtmlToDoc: charset [" << (charset) << "] doc charset [" << (result.get_charset()) << "]\n" );
charset.c_str(), result.get_charset().c_str()));
if (!result.get_charset().empty() && if (!result.get_charset().empty() &&
!samecharset(result.get_charset(), result.fromcharset)) { !samecharset(result.get_charset(), result.fromcharset)) {
LOGDEB(("textHtmlToDoc: reparse for charsets\n")); LOGDEB("textHtmlToDoc: reparse for charsets\n" );
// Set the origin charset as specified in document before // Set the origin charset as specified in document before
// transcoding again // transcoding again
charset = result.get_charset(); charset = result.get_charset();
} else { } else {
LOGERR(("textHtmlToDoc:: error: non charset exception\n")); LOGERR("textHtmlToDoc:: error: non charset exception\n" );
return false; return false;
} }
} }
@ -181,3 +175,4 @@ bool MimeHandlerHtml::next_document()
} }
return true; return true;
} }

View file

@ -33,7 +33,7 @@
#include "transcode.h" #include "transcode.h"
#include "mimeparse.h" #include "mimeparse.h"
#include "mh_mail.h" #include "mh_mail.h"
#include "debuglog.h" #include "log.h"
#include "smallut.h" #include "smallut.h"
#include "mh_html.h" #include "mh_html.h"
#include "rclconfig.h" #include "rclconfig.h"
@ -89,7 +89,7 @@ void MimeHandlerMail::clear()
bool MimeHandlerMail::set_document_file(const string& mt, const string &fn) bool MimeHandlerMail::set_document_file(const string& mt, const string &fn)
{ {
LOGDEB(("MimeHandlerMail::set_document_file(%s)\n", fn.c_str())); LOGDEB("MimeHandlerMail::set_document_file(" << (fn) << ")\n" );
RecollFilter::set_document_file(mt, fn); RecollFilter::set_document_file(mt, fn);
if (m_fd >= 0) { if (m_fd >= 0) {
close(m_fd); close(m_fd);
@ -103,14 +103,12 @@ bool MimeHandlerMail::set_document_file(const string& mt, const string &fn)
if (MD5File(fn, md5, &reason)) { if (MD5File(fn, md5, &reason)) {
m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5); m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5);
} else { } else {
LOGERR(("MimeHandlerMail: cant md5 [%s]: %s\n", fn.c_str(), LOGERR("MimeHandlerMail: cant md5 [" << (fn) << "]: " << (reason) << "\n" );
reason.c_str()));
} }
} }
m_fd = open(fn.c_str(), 0); m_fd = open(fn.c_str(), 0);
if (m_fd < 0) { if (m_fd < 0) {
LOGERR(("MimeHandlerMail::set_document_file: open(%s) errno %d\n", LOGERR("MimeHandlerMail::set_document_file: open(" << (fn) << ") errno " << (errno) << "\n" );
fn.c_str(), errno));
return false; return false;
} }
#if defined O_NOATIME && O_NOATIME != 0 #if defined O_NOATIME && O_NOATIME != 0
@ -122,8 +120,7 @@ bool MimeHandlerMail::set_document_file(const string& mt, const string &fn)
m_bincdoc = new Binc::MimeDocument; m_bincdoc = new Binc::MimeDocument;
m_bincdoc->parseFull(m_fd); m_bincdoc->parseFull(m_fd);
if (!m_bincdoc->isHeaderParsed() && !m_bincdoc->isAllParsed()) { if (!m_bincdoc->isHeaderParsed() && !m_bincdoc->isAllParsed()) {
LOGERR(("MimeHandlerMail::mkDoc: mime parse error for %s\n", LOGERR("MimeHandlerMail::mkDoc: mime parse error for " << (fn) << "\n" );
fn.c_str()));
return false; return false;
} }
m_havedoc = true; m_havedoc = true;
@ -133,8 +130,8 @@ bool MimeHandlerMail::set_document_file(const string& mt, const string &fn)
bool MimeHandlerMail::set_document_string(const string& mt, bool MimeHandlerMail::set_document_string(const string& mt,
const string &msgtxt) const string &msgtxt)
{ {
LOGDEB1(("MimeHandlerMail::set_document_string\n")); LOGDEB1("MimeHandlerMail::set_document_string\n" );
LOGDEB2(("Message text: [%s]\n", msgtxt.c_str())); LOGDEB2("Message text: [" << (msgtxt) << "]\n" );
RecollFilter::set_document_string(mt, msgtxt); RecollFilter::set_document_string(mt, msgtxt);
delete m_stream; delete m_stream;
@ -145,19 +142,17 @@ bool MimeHandlerMail::set_document_string(const string& mt,
} }
if ((m_stream = new stringstream(msgtxt)) == 0 || !m_stream->good()) { if ((m_stream = new stringstream(msgtxt)) == 0 || !m_stream->good()) {
LOGERR(("MimeHandlerMail::set_document_string: stream create error." LOGERR("MimeHandlerMail::set_document_string: stream create error.msgtxt.size() " << (int(msgtxt.size())) << "\n" );
"msgtxt.size() %d\n", int(msgtxt.size())));
return false; return false;
} }
delete m_bincdoc; delete m_bincdoc;
if ((m_bincdoc = new Binc::MimeDocument) == 0) { if ((m_bincdoc = new Binc::MimeDocument) == 0) {
LOGERR(("MimeHandlerMail::set_doc._string: new Binc:Document failed." LOGERR("MimeHandlerMail::set_doc._string: new Binc:Document failed. Out of memory?" );
" Out of memory?"));
return false; return false;
} }
m_bincdoc->parseFull(*m_stream); m_bincdoc->parseFull(*m_stream);
if (!m_bincdoc->isHeaderParsed() && !m_bincdoc->isAllParsed()) { if (!m_bincdoc->isHeaderParsed() && !m_bincdoc->isAllParsed()) {
LOGERR(("MimeHandlerMail::set_document_string: mime parse error\n")); LOGERR("MimeHandlerMail::set_document_string: mime parse error\n" );
return false; return false;
} }
m_havedoc = true; m_havedoc = true;
@ -166,14 +161,14 @@ bool MimeHandlerMail::set_document_string(const string& mt,
bool MimeHandlerMail::skip_to_document(const string& ipath) bool MimeHandlerMail::skip_to_document(const string& ipath)
{ {
LOGDEB(("MimeHandlerMail::skip_to_document(%s)\n", ipath.c_str())); LOGDEB("MimeHandlerMail::skip_to_document(" << (ipath) << ")\n" );
if (m_idx == -1) { if (m_idx == -1) {
// No decoding done yet. If ipath is null need do nothing // No decoding done yet. If ipath is null need do nothing
if (ipath.empty() || ipath == "-1") if (ipath.empty() || ipath == "-1")
return true; return true;
// ipath points to attachment: need to decode message // ipath points to attachment: need to decode message
if (!next_document()) { if (!next_document()) {
LOGERR(("MimeHandlerMail::skip_to_doc: next_document failed\n")); LOGERR("MimeHandlerMail::skip_to_doc: next_document failed\n" );
return false; return false;
} }
} }
@ -183,8 +178,7 @@ bool MimeHandlerMail::skip_to_document(const string& ipath)
bool MimeHandlerMail::next_document() bool MimeHandlerMail::next_document()
{ {
LOGDEB(("MimeHandlerMail::next_document m_idx %d m_havedoc %d\n", LOGDEB("MimeHandlerMail::next_document m_idx " << (m_idx) << " m_havedoc " << (m_havedoc) << "\n" );
m_idx, m_havedoc));
if (!m_havedoc) if (!m_havedoc)
return false; return false;
bool res = false; bool res = false;
@ -192,8 +186,7 @@ bool MimeHandlerMail::next_document()
if (m_idx == -1) { if (m_idx == -1) {
m_metaData[cstr_dj_keymt] = cstr_textplain; m_metaData[cstr_dj_keymt] = cstr_textplain;
res = processMsg(m_bincdoc, 0); res = processMsg(m_bincdoc, 0);
LOGDEB1(("MimeHandlerMail::next_document: mt %s, att cnt %d\n", LOGDEB1("MimeHandlerMail::next_document: mt " << (m_metaData[cstr_dj_keymt]) << ", att cnt " << (m_attachments.size()) << "\n" );
m_metaData[cstr_dj_keymt].c_str(), m_attachments.size()));
const string& txt = m_metaData[cstr_dj_keycontent]; const string& txt = m_metaData[cstr_dj_keycontent];
if (m_startoftext < txt.size()) if (m_startoftext < txt.size())
m_metaData[cstr_dj_keyabstract] = m_metaData[cstr_dj_keyabstract] =
@ -228,16 +221,16 @@ static bool decodeBody(const string& cte, // Content transfer encoding
if (!stringlowercmp("quoted-printable", cte)) { if (!stringlowercmp("quoted-printable", cte)) {
if (!qp_decode(body, decoded)) { if (!qp_decode(body, decoded)) {
LOGERR(("decodeBody: quoted-printable decoding failed !\n")); LOGERR("decodeBody: quoted-printable decoding failed !\n" );
LOGDEB((" Body: \n%s\n", body.c_str())); LOGDEB(" Body: \n" << (body) << "\n" );
return false; return false;
} }
*respp = &decoded; *respp = &decoded;
} else if (!stringlowercmp("base64", cte)) { } else if (!stringlowercmp("base64", cte)) {
if (!base64_decode(body, decoded)) { if (!base64_decode(body, decoded)) {
// base64 encoding errors are actually relatively common // base64 encoding errors are actually relatively common
LOGERR(("decodeBody: base64 decoding failed !\n")); LOGERR("decodeBody: base64 decoding failed !\n" );
LOGDEB((" Body: \n%s\n", body.c_str())); LOGDEB(" Body: \n" << (body) << "\n" );
return false; return false;
} }
*respp = &decoded; *respp = &decoded;
@ -247,7 +240,7 @@ static bool decodeBody(const string& cte, // Content transfer encoding
bool MimeHandlerMail::processAttach() bool MimeHandlerMail::processAttach()
{ {
LOGDEB(("MimeHandlerMail::processAttach() m_idx %d\n", m_idx)); LOGDEB("MimeHandlerMail::processAttach() m_idx " << (m_idx) << "\n" );
if (!m_havedoc) if (!m_havedoc)
return false; return false;
if (m_idx >= (int)m_attachments.size()) { if (m_idx >= (int)m_attachments.size()) {
@ -261,10 +254,7 @@ bool MimeHandlerMail::processAttach()
m_metaData[cstr_dj_keycharset] = att->m_charset; m_metaData[cstr_dj_keycharset] = att->m_charset;
m_metaData[cstr_dj_keyfn] = att->m_filename; m_metaData[cstr_dj_keyfn] = att->m_filename;
m_metaData[cstr_dj_keytitle] = att->m_filename + " (" + m_subject + ")"; m_metaData[cstr_dj_keytitle] = att->m_filename + " (" + m_subject + ")";
LOGDEB1((" processAttach:ct [%s] cs [%s] fn [%s]\n", LOGDEB1(" processAttach:ct [" << (att->m_contentType) << "] cs [" << (att->m_charset) << "] fn [" << (att->m_filename) << "]\n" );
att->m_contentType.c_str(),
att->m_charset.c_str(),
att->m_filename.c_str()));
// Erase current content and replace // Erase current content and replace
m_metaData[cstr_dj_keycontent] = string(); m_metaData[cstr_dj_keycontent] = string();
@ -315,11 +305,10 @@ bool MimeHandlerMail::processAttach()
// text // text
bool MimeHandlerMail::processMsg(Binc::MimePart *doc, int depth) bool MimeHandlerMail::processMsg(Binc::MimePart *doc, int depth)
{ {
LOGDEB2(("MimeHandlerMail::processMsg: depth %d\n", depth)); LOGDEB2("MimeHandlerMail::processMsg: depth " << (depth) << "\n" );
if (depth++ >= maxdepth) { if (depth++ >= maxdepth) {
// Have to stop somewhere // Have to stop somewhere
LOGINFO(("MimeHandlerMail::processMsg: maxdepth %d exceeded\n", LOGINFO("MimeHandlerMail::processMsg: maxdepth " << (maxdepth) << " exceeded\n" );
maxdepth));
// Return true anyway, better to index partially than not at all // Return true anyway, better to index partially than not at all
return true; return true;
} }
@ -371,7 +360,7 @@ bool MimeHandlerMail::processMsg(Binc::MimePart *doc, int depth)
m_metaData[cstr_dj_keymd] = ascuxtime; m_metaData[cstr_dj_keymd] = ascuxtime;
} else { } else {
// Leave mtime field alone, ftime will be used instead. // Leave mtime field alone, ftime will be used instead.
LOGDEB(("rfc2822Date...: failed: [%s]\n", decoded.c_str())); LOGDEB("rfc2822Date...: failed: [" << (decoded) << "]\n" );
} }
} }
if (preview()) if (preview())
@ -405,12 +394,10 @@ bool MimeHandlerMail::processMsg(Binc::MimePart *doc, int depth)
text += '\n'; text += '\n';
m_startoftext = text.size(); m_startoftext = text.size();
LOGDEB2(("MimeHandlerMail::processMsg:ismultipart %d mime subtype '%s'\n", LOGDEB2("MimeHandlerMail::processMsg:ismultipart " << (doc->isMultipart()) << " mime subtype '" << (doc->getSubType()) << "'\n" );
doc->isMultipart(), doc->getSubType().c_str()));
walkmime(doc, depth); walkmime(doc, depth);
LOGDEB2(("MimeHandlerMail::processMsg:text:[%s]\n", LOGDEB2("MimeHandlerMail::processMsg:text:[" << (m_metaData[cstr_dj_keycontent]) << "]\n" );
m_metaData[cstr_dj_keycontent].c_str()));
return true; return true;
} }
@ -426,17 +413,16 @@ bool MimeHandlerMail::processMsg(Binc::MimePart *doc, int depth)
// message/rfc822 may also be of interest. // message/rfc822 may also be of interest.
void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth) void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
{ {
LOGDEB2(("MimeHandlerMail::walkmime: depth %d\n", depth)); LOGDEB2("MimeHandlerMail::walkmime: depth " << (depth) << "\n" );
if (depth++ >= maxdepth) { if (depth++ >= maxdepth) {
LOGINFO(("walkmime: max depth (%d) exceeded\n", maxdepth)); LOGINFO("walkmime: max depth (" << (maxdepth) << ") exceeded\n" );
return; return;
} }
string& out = m_metaData[cstr_dj_keycontent]; string& out = m_metaData[cstr_dj_keycontent];
if (doc->isMultipart()) { if (doc->isMultipart()) {
LOGDEB2(("walkmime: ismultipart %d subtype '%s'\n", LOGDEB2("walkmime: ismultipart " << (doc->isMultipart()) << " subtype '" << (doc->getSubType()) << "'\n" );
doc->isMultipart(), doc->getSubType().c_str()));
// We only handle alternative, related and mixed (no digests). // We only handle alternative, related and mixed (no digests).
std::vector<Binc::MimePart>::iterator it; std::vector<Binc::MimePart>::iterator it;
@ -459,22 +445,22 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
// Get and parse content-type header // Get and parse content-type header
Binc::HeaderItem hi; Binc::HeaderItem hi;
if (!it->h.getFirstHeader("Content-Type", hi)) { if (!it->h.getFirstHeader("Content-Type", hi)) {
LOGDEB(("walkmime:no ctent-type header for part %d\n", i)); LOGDEB("walkmime:no ctent-type header for part " << (i) << "\n" );
continue; continue;
} }
MimeHeaderValue content_type; MimeHeaderValue content_type;
parseMimeHeaderValue(hi.getValue(), content_type); parseMimeHeaderValue(hi.getValue(), content_type);
LOGDEB2(("walkmime: C-type: %s\n",content_type.value.c_str())); LOGDEB2("walkmime: C-type: " << (content_type.value) << "\n" );
if (!stringlowercmp(cstr_textplain, content_type.value)) if (!stringlowercmp(cstr_textplain, content_type.value))
ittxt = it; ittxt = it;
else if (!stringlowercmp("text/html", content_type.value)) else if (!stringlowercmp("text/html", content_type.value))
ithtml = it; ithtml = it;
} }
if (ittxt != doc->members.end()) { if (ittxt != doc->members.end()) {
LOGDEB2(("walkmime: alternative: chose text/plain part\n")) LOGDEB2("walkmime: alternative: chose text/plain part\n" );
walkmime(&(*ittxt), depth); walkmime(&(*ittxt), depth);
} else if (ithtml != doc->members.end()) { } else if (ithtml != doc->members.end()) {
LOGDEB2(("walkmime: alternative: chose text/html part\n")) LOGDEB2("walkmime: alternative: chose text/html part\n" );
walkmime(&(*ithtml), depth); walkmime(&(*ithtml), depth);
} }
} }
@ -490,7 +476,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
if (doc->h.getFirstHeader("Content-Type", hi)) { if (doc->h.getFirstHeader("Content-Type", hi)) {
ctt = hi.getValue(); ctt = hi.getValue();
} }
LOGDEB2(("walkmime:content-type: %s\n", ctt.c_str())); LOGDEB2("walkmime:content-type: " << (ctt) << "\n" );
MimeHeaderValue content_type; MimeHeaderValue content_type;
parseMimeHeaderValue(ctt, content_type); parseMimeHeaderValue(ctt, content_type);
@ -501,7 +487,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
} }
MimeHeaderValue content_disposition; MimeHeaderValue content_disposition;
parseMimeHeaderValue(ctd, content_disposition); parseMimeHeaderValue(ctd, content_disposition);
LOGDEB2(("Content_disposition:[%s]\n", content_disposition.value.c_str())); LOGDEB2("Content_disposition:[" << (content_disposition.value) << "]\n" );
string dispindic; string dispindic;
if (stringlowercmp("inline", content_disposition.value)) if (stringlowercmp("inline", content_disposition.value))
dispindic = "Attachment"; dispindic = "Attachment";
@ -521,7 +507,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
} }
if (doc->isMessageRFC822()) { if (doc->isMessageRFC822()) {
LOGDEB2(("walkmime: message/RFC822 part\n")); LOGDEB2("walkmime: message/RFC822 part\n" );
// The first part is the already parsed message. Call // The first part is the already parsed message. Call
// processMsg instead of walkmime so that mail headers get // processMsg instead of walkmime so that mail headers get
@ -542,7 +528,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
} }
// "Simple" part. // "Simple" part.
LOGDEB2(("walkmime: simple part\n")); LOGDEB2("walkmime: simple part\n" );
// Normally the default charset is us-ascii. But it happens that 8 // Normally the default charset is us-ascii. But it happens that 8
// bit chars exist in a message that is stated as us-ascii. Ie the // bit chars exist in a message that is stated as us-ascii. Ie the
// mailer used by yahoo support ('KANA') does this. We could // mailer used by yahoo support ('KANA') does this. We could
@ -589,7 +575,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
} }
MHMailAttach *att = new MHMailAttach; MHMailAttach *att = new MHMailAttach;
if (att == 0) { if (att == 0) {
LOGERR(("Out of memory\n")); LOGERR("Out of memory\n" );
return; return;
} }
att->m_contentType = content_type.value; att->m_contentType = content_type.value;
@ -598,11 +584,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
att->m_charset = charset; att->m_charset = charset;
att->m_contentTransferEncoding = cte; att->m_contentTransferEncoding = cte;
att->m_part = doc; att->m_part = doc;
LOGDEB(("walkmime: attachmnt: ct [%s] cte [%s] cs [%s] fn [%s]\n", LOGDEB("walkmime: attachmnt: ct [" << (att->m_contentType) << "] cte [" << (att->m_contentTransferEncoding) << "] cs [" << (att->m_charset) << "] fn [" << (filename) << "]\n" );
att->m_contentType.c_str(),
att->m_contentTransferEncoding.c_str(),
att->m_charset.c_str(),
filename.c_str()));
m_attachments.push_back(att); m_attachments.push_back(att);
return; return;
} }
@ -612,15 +594,14 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
// filter stack work: this would create another subdocument, but // filter stack work: this would create another subdocument, but
// we want instead to decode a body part of this message document. // we want instead to decode a body part of this message document.
LOGDEB2(("walkmime: final: body start offset %d, length %d\n", LOGDEB2("walkmime: final: body start offset " << (doc->getBodyStartOffset()) << ", length " << (doc->getBodyLength()) << "\n" );
doc->getBodyStartOffset(), doc->getBodyLength()));
string body; string body;
doc->getBody(body, 0, doc->bodylength); doc->getBody(body, 0, doc->bodylength);
{ {
string decoded; string decoded;
const string *bdp; const string *bdp;
if (!decodeBody(cte, body, decoded, &bdp)) { if (!decodeBody(cte, body, decoded, &bdp)) {
LOGERR(("MimeHandlerMail::walkmime: failed decoding body\n")); LOGERR("MimeHandlerMail::walkmime: failed decoding body\n" );
} }
if (bdp != &body) if (bdp != &body)
body.swap(decoded); body.swap(decoded);
@ -641,10 +622,9 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
} else { } else {
string utf8; string utf8;
// Transcode to utf-8 // Transcode to utf-8
LOGDEB1(("walkmime: transcoding from %s to UTF-8\n", charset.c_str())); LOGDEB1("walkmime: transcoding from " << (charset) << " to UTF-8\n" );
if (!transcode(body, utf8, charset, cstr_utf8)) { if (!transcode(body, utf8, charset, cstr_utf8)) {
LOGERR(("walkmime: transcode failed from cs '%s' to UTF-8\n", LOGERR("walkmime: transcode failed from cs '" << (charset) << "' to UTF-8\n" );
charset.c_str()));
out += body; out += body;
} else { } else {
out += utf8; out += utf8;
@ -654,5 +634,6 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth)
if (out.length() && out[out.length()-1] != '\n') if (out.length() && out[out.length()-1] != '\n')
out += '\n'; out += '\n';
LOGDEB2(("walkmime: out now: [%s]\n", out.c_str())); LOGDEB2("walkmime: out now: [" << (out) << "]\n" );
} }

View file

@ -38,7 +38,7 @@
#include "cstr.h" #include "cstr.h"
#include "mimehandler.h" #include "mimehandler.h"
#include "debuglog.h" #include "log.h"
#include "readfile.h" #include "readfile.h"
#include "mh_mbox.h" #include "mh_mbox.h"
#include "smallut.h" #include "smallut.h"
@ -100,47 +100,43 @@ public:
~MboxCache() {} ~MboxCache() {}
mbhoff_type get_offset(RclConfig *config, const string& udi, int msgnum) mbhoff_type get_offset(RclConfig *config, const string& udi, int msgnum)
{ {
LOGDEB0(("MboxCache::get_offsets: udi [%s] msgnum %d\n", udi.c_str(), LOGDEB0("MboxCache::get_offsets: udi [" << (udi) << "] msgnum " << (msgnum) << "\n" );
msgnum));
if (!ok(config)) { if (!ok(config)) {
LOGDEB0(("MboxCache::get_offsets: init failed\n")); LOGDEB0("MboxCache::get_offsets: init failed\n" );
return -1; return -1;
} }
PTMutexLocker locker(o_mcache_mutex); PTMutexLocker locker(o_mcache_mutex);
string fn = makefilename(udi); string fn = makefilename(udi);
FILE *fp = 0; FILE *fp = 0;
if ((fp = fopen(fn.c_str(), "r")) == 0) { if ((fp = fopen(fn.c_str(), "r")) == 0) {
LOGDEB(("MboxCache::get_offsets: open failed, errno %d\n", errno)); LOGDEB("MboxCache::get_offsets: open failed, errno " << (errno) << "\n" );
return -1; return -1;
} }
FpKeeper keeper(&fp); FpKeeper keeper(&fp);
char blk1[M_o_b1size]; char blk1[M_o_b1size];
if (fread(blk1, 1, o_b1size, fp) != o_b1size) { if (fread(blk1, 1, o_b1size, fp) != o_b1size) {
LOGDEB0(("MboxCache::get_offsets: read blk1 errno %d\n", errno)); LOGDEB0("MboxCache::get_offsets: read blk1 errno " << (errno) << "\n" );
return -1; return -1;
} }
ConfSimple cf(string(blk1, o_b1size)); ConfSimple cf(string(blk1, o_b1size));
string fudi; string fudi;
if (!cf.get("udi", fudi) || fudi.compare(udi)) { if (!cf.get("udi", fudi) || fudi.compare(udi)) {
LOGINFO(("MboxCache::get_offset:badudi fn %s udi [%s], fudi [%s]\n", LOGINFO("MboxCache::get_offset:badudi fn " << (fn) << " udi [" << (udi) << "], fudi [" << (fudi) << "]\n" );
fn.c_str(), udi.c_str(), fudi.c_str()));
return -1; return -1;
} }
if (fseeko(fp, cacheoffset(msgnum), SEEK_SET) != 0) { if (fseeko(fp, cacheoffset(msgnum), SEEK_SET) != 0) {
LOGDEB0(("MboxCache::get_offsets: seek %s errno %d\n", LOGDEB0("MboxCache::get_offsets: seek " << (lltodecstr(cacheoffset(msgnum))) << " errno " << (errno) << "\n" );
lltodecstr(cacheoffset(msgnum)).c_str(), errno));
return -1; return -1;
} }
mbhoff_type offset = -1; mbhoff_type offset = -1;
size_t ret; size_t ret;
if ((ret = fread(&offset, 1, sizeof(mbhoff_type), fp)) if ((ret = fread(&offset, 1, sizeof(mbhoff_type), fp))
!= sizeof(mbhoff_type)) { != sizeof(mbhoff_type)) {
LOGDEB0(("MboxCache::get_offsets: read ret %d errno %d\n", LOGDEB0("MboxCache::get_offsets: read ret " << (ret) << " errno " << (errno) << "\n" );
ret, errno));
return -1; return -1;
} }
LOGDEB0(("MboxCache::get_offsets: ret %s\n", lltodecstr(offset).c_str())); LOGDEB0("MboxCache::get_offsets: ret " << (lltodecstr(offset)) << "\n" );
return offset; return offset;
} }
@ -148,7 +144,7 @@ public:
void put_offsets(RclConfig *config, const string& udi, mbhoff_type fsize, void put_offsets(RclConfig *config, const string& udi, mbhoff_type fsize,
vector<mbhoff_type>& offs) vector<mbhoff_type>& offs)
{ {
LOGDEB0(("MboxCache::put_offsets: %u offsets\n", offs.size())); LOGDEB0("MboxCache::put_offsets: " << (offs.size()) << " offsets\n" );
if (!ok(config) || !maybemakedir()) if (!ok(config) || !maybemakedir())
return; return;
if (fsize < m_minfsize) if (fsize < m_minfsize)
@ -157,7 +153,7 @@ public:
string fn = makefilename(udi); string fn = makefilename(udi);
FILE *fp; FILE *fp;
if ((fp = fopen(fn.c_str(), "w")) == 0) { if ((fp = fopen(fn.c_str(), "w")) == 0) {
LOGDEB(("MboxCache::put_offsets: fopen errno %d\n", errno)); LOGDEB("MboxCache::put_offsets: fopen errno " << (errno) << "\n" );
return; return;
} }
FpKeeper keeper(&fp); FpKeeper keeper(&fp);
@ -167,7 +163,7 @@ public:
blk1.append(cstr_newline); blk1.append(cstr_newline);
blk1.resize(o_b1size, 0); blk1.resize(o_b1size, 0);
if (fwrite(blk1.c_str(), 1, o_b1size, fp) != o_b1size) { if (fwrite(blk1.c_str(), 1, o_b1size, fp) != o_b1size) {
LOGDEB(("MboxCache::put_offsets: fwrite errno %d\n", errno)); LOGDEB("MboxCache::put_offsets: fwrite errno " << (errno) << "\n" );
return; return;
} }
@ -261,7 +257,7 @@ void MimeHandlerMbox::clear()
bool MimeHandlerMbox::set_document_file(const string& mt, const string &fn) bool MimeHandlerMbox::set_document_file(const string& mt, const string &fn)
{ {
LOGDEB(("MimeHandlerMbox::set_document_file(%s)\n", fn.c_str())); LOGDEB("MimeHandlerMbox::set_document_file(" << (fn) << ")\n" );
RecollFilter::set_document_file(mt, fn); RecollFilter::set_document_file(mt, fn);
m_fn = fn; m_fn = fn;
if (m_vfp) { if (m_vfp) {
@ -271,8 +267,7 @@ bool MimeHandlerMbox::set_document_file(const string& mt, const string &fn)
m_vfp = fopen(fn.c_str(), "r"); m_vfp = fopen(fn.c_str(), "r");
if (m_vfp == 0) { if (m_vfp == 0) {
LOGERR(("MimeHandlerMail::set_document_file: error opening %s\n", LOGERR("MimeHandlerMail::set_document_file: error opening " << (fn) << "\n" );
fn.c_str()));
return false; return false;
} }
#if defined O_NOATIME && O_NOATIME != 0 #if defined O_NOATIME && O_NOATIME != 0
@ -283,8 +278,7 @@ bool MimeHandlerMbox::set_document_file(const string& mt, const string &fn)
// Used to use ftell() here: no good beyond 2GB // Used to use ftell() here: no good beyond 2GB
{struct stat st; {struct stat st;
if (fstat(fileno((FILE*)m_vfp), &st) < 0) { if (fstat(fileno((FILE*)m_vfp), &st) < 0) {
LOGERR(("MimeHandlerMbox:setdocfile: fstat(%s) failed errno %d\n", LOGERR("MimeHandlerMbox:setdocfile: fstat(" << (fn) << ") failed errno " << (errno) << "\n" );
fn.c_str(), errno));
return false; return false;
} }
m_fsize = st.st_size; m_fsize = st.st_size;
@ -297,7 +291,7 @@ bool MimeHandlerMbox::set_document_file(const string& mt, const string &fn)
string quirks; string quirks;
if (m_config && m_config->getConfParam(cstr_keyquirks, quirks)) { if (m_config && m_config->getConfParam(cstr_keyquirks, quirks)) {
if (quirks == "tbird") { if (quirks == "tbird") {
LOGDEB(("MimeHandlerMbox: setting quirks TBIRD\n")); LOGDEB("MimeHandlerMbox: setting quirks TBIRD\n" );
m_quirks |= MBOXQUIRK_TBIRD; m_quirks |= MBOXQUIRK_TBIRD;
} }
} }
@ -305,8 +299,7 @@ bool MimeHandlerMbox::set_document_file(const string& mt, const string &fn)
// And double check for thunderbird // And double check for thunderbird
string tbirdmsf = fn + ".msf"; string tbirdmsf = fn + ".msf";
if ((m_quirks&MBOXQUIRK_TBIRD) == 0 && path_exists(tbirdmsf)) { if ((m_quirks&MBOXQUIRK_TBIRD) == 0 && path_exists(tbirdmsf)) {
LOGDEB(("MimeHandlerMbox: detected unconfigured tbird mbox in %s\n", LOGDEB("MimeHandlerMbox: detected unconfigured tbird mbox in " << (fn) << "\n" );
fn.c_str()));
m_quirks |= MBOXQUIRK_TBIRD; m_quirks |= MBOXQUIRK_TBIRD;
} }
@ -423,7 +416,7 @@ static void compileregexes()
bool MimeHandlerMbox::next_document() bool MimeHandlerMbox::next_document()
{ {
if (m_vfp == 0) { if (m_vfp == 0) {
LOGERR(("MimeHandlerMbox::next_document: not open\n")); LOGERR("MimeHandlerMbox::next_document: not open\n" );
return false; return false;
} }
if (!m_havedoc) { if (!m_havedoc) {
@ -435,11 +428,10 @@ bool MimeHandlerMbox::next_document()
sscanf(m_ipath.c_str(), "%d", &mtarg); sscanf(m_ipath.c_str(), "%d", &mtarg);
} else if (m_forPreview) { } else if (m_forPreview) {
// Can't preview an mbox. // Can't preview an mbox.
LOGDEB(("MimeHandlerMbox::next_document: can't preview folders!\n")); LOGDEB("MimeHandlerMbox::next_document: can't preview folders!\n" );
return false; return false;
} }
LOGDEB0(("MimeHandlerMbox::next_document: fn %s, msgnum %d mtarg %d \n", LOGDEB0("MimeHandlerMbox::next_document: fn " << (m_fn) << ", msgnum " << (m_msgnum) << " mtarg " << (mtarg) << " \n" );
m_fn.c_str(), m_msgnum, mtarg));
if (mtarg == 0) if (mtarg == 0)
mtarg = -1; mtarg = -1;
@ -459,8 +451,7 @@ bool MimeHandlerMbox::next_document()
if (mtarg > 0) { if (mtarg > 0) {
mbhoff_type off; mbhoff_type off;
line_type line; line_type line;
LOGDEB0(("MimeHandlerMbox::next_doc: mtarg %d m_udi[%s]\n", LOGDEB0("MimeHandlerMbox::next_doc: mtarg " << (mtarg) << " m_udi[" << (m_udi) << "]\n" );
mtarg, m_udi.c_str()));
if (!m_udi.empty() && if (!m_udi.empty() &&
(off = o_mcache.get_offset(m_config, m_udi, mtarg)) >= 0 && (off = o_mcache.get_offset(m_config, m_udi, mtarg)) >= 0 &&
fseeko(fp, (off_t)off, SEEK_SET) >= 0 && fseeko(fp, (off_t)off, SEEK_SET) >= 0 &&
@ -468,7 +459,7 @@ bool MimeHandlerMbox::next_document()
(!M_regexec(fromregex, line, 0, 0, 0) || (!M_regexec(fromregex, line, 0, 0, 0) ||
((m_quirks & MBOXQUIRK_TBIRD) && ((m_quirks & MBOXQUIRK_TBIRD) &&
!M_regexec(minifromregex, line, 0, 0, 0))) ) { !M_regexec(minifromregex, line, 0, 0, 0))) ) {
LOGDEB0(("MimeHandlerMbox: Cache: From_ Ok\n")); LOGDEB0("MimeHandlerMbox: Cache: From_ Ok\n" );
fseeko(fp, (off_t)off, SEEK_SET); fseeko(fp, (off_t)off, SEEK_SET);
m_msgnum = mtarg -1; m_msgnum = mtarg -1;
storeoffsets = false; storeoffsets = false;
@ -487,7 +478,7 @@ bool MimeHandlerMbox::next_document()
for (;;) { for (;;) {
message_end = ftello(fp); message_end = ftello(fp);
if (!fgets(line, LL, fp)) { if (!fgets(line, LL, fp)) {
LOGDEB2(("MimeHandlerMbox:next: eof\n")); LOGDEB2("MimeHandlerMbox:next: eof\n" );
iseof = true; iseof = true;
m_msgnum++; m_msgnum++;
break; break;
@ -495,8 +486,7 @@ bool MimeHandlerMbox::next_document()
m_lineno++; m_lineno++;
int ll; int ll;
stripendnl(line, ll); stripendnl(line, ll);
LOGDEB2(("mhmbox:next: hadempty %d lineno %d ll %d Line: [%s]\n", LOGDEB2("mhmbox:next: hadempty " << (hademptyline) << " lineno " << (m_lineno) << " ll " << (ll) << " Line: [" << (line) << "]\n" );
hademptyline, m_lineno, ll, line));
if (hademptyline) { if (hademptyline) {
if (ll > 0) { if (ll > 0) {
// Non-empty line with empty line flag set, reset flag // Non-empty line with empty line flag set, reset flag
@ -514,8 +504,7 @@ bool MimeHandlerMbox::next_document()
((m_quirks & MBOXQUIRK_TBIRD) && ((m_quirks & MBOXQUIRK_TBIRD) &&
!M_regexec(minifromregex, line, 0, 0, 0))) !M_regexec(minifromregex, line, 0, 0, 0)))
) { ) {
LOGDEB0(("MimeHandlerMbox: msgnum %d, " LOGDEB0("MimeHandlerMbox: msgnum " << (m_msgnum) << ", From_ at line " << (m_lineno) << ": [" << (line) << "]\n" );
"From_ at line %d: [%s]\n", m_msgnum, m_lineno, line));
if (storeoffsets) if (storeoffsets)
m_offsets.push_back(message_end); m_offsets.push_back(message_end);
m_msgnum++; m_msgnum++;
@ -538,15 +527,13 @@ bool MimeHandlerMbox::next_document()
line[ll+1] = 0; line[ll+1] = 0;
msgtxt += line; msgtxt += line;
if (msgtxt.size() > max_mbox_member_size) { if (msgtxt.size() > max_mbox_member_size) {
LOGERR(("mh_mbox: huge message (more than %u MB) inside %s," LOGERR("mh_mbox: huge message (more than " << (max_mbox_member_size/(1024*1024)) << " MB) inside " << (m_fn) << ", giving up\n" );
" giving up\n", max_mbox_member_size/(1024*1024),
m_fn.c_str()));
return false; return false;
} }
} }
} }
LOGDEB2(("Message text length %d\n", msgtxt.size())); LOGDEB2("Message text length " << (msgtxt.size()) << "\n" );
LOGDEB2(("Message text: [%s]\n", msgtxt.c_str())); LOGDEB2("Message text: [" << (msgtxt) << "]\n" );
char buf[20]; char buf[20];
// m_msgnum was incremented when hitting the next From_ or eof, so the data // m_msgnum was incremented when hitting the next From_ or eof, so the data
// is for m_msgnum - 1 // is for m_msgnum - 1
@ -554,7 +541,7 @@ bool MimeHandlerMbox::next_document()
m_metaData[cstr_dj_keyipath] = buf; m_metaData[cstr_dj_keyipath] = buf;
m_metaData[cstr_dj_keymt] = "message/rfc822"; m_metaData[cstr_dj_keymt] = "message/rfc822";
if (iseof) { if (iseof) {
LOGDEB2(("MimeHandlerMbox::next: eof hit\n")); LOGDEB2("MimeHandlerMbox::next: eof hit\n" );
m_havedoc = false; m_havedoc = false;
if (!m_udi.empty() && storeoffsets) { if (!m_udi.empty() && storeoffsets) {
o_mcache.put_offsets(m_config, m_udi, m_fsize, m_offsets); o_mcache.put_offsets(m_config, m_udi, m_fsize, m_offsets);
@ -679,3 +666,4 @@ int main(int argc, char **argv)
#endif // TEST_MH_MBOX #endif // TEST_MH_MBOX

View file

@ -25,7 +25,7 @@
#include "mimehandler.h" #include "mimehandler.h"
#include "transcode.h" #include "transcode.h"
#include "pathut.h" #include "pathut.h"
#include "debuglog.h" #include "log.h"
/** Index symlink target /** Index symlink target
* *
@ -61,8 +61,7 @@ class MimeHandlerSymlink : public RecollFilter {
transcode(path_getsimple(slc), m_metaData[cstr_dj_keycontent], transcode(path_getsimple(slc), m_metaData[cstr_dj_keycontent],
m_config->getDefCharset(true), "UTF-8"); m_config->getDefCharset(true), "UTF-8");
} else { } else {
LOGDEB(("Symlink: readlink [%s] failed, errno %d\n", m_fn.c_str(), LOGDEB("Symlink: readlink [" << (m_fn) << "] failed, errno " << (errno) << "\n" );
errno));
} }
m_metaData[cstr_dj_keymt] = cstr_textplain; m_metaData[cstr_dj_keymt] = cstr_textplain;
return true; return true;
@ -72,3 +71,4 @@ private:
}; };
#endif /* _MH_SYMLINK_H_INCLUDED_ */ #endif /* _MH_SYMLINK_H_INCLUDED_ */

View file

@ -27,7 +27,7 @@
#include "cstr.h" #include "cstr.h"
#include "mh_text.h" #include "mh_text.h"
#include "debuglog.h" #include "log.h"
#include "readfile.h" #include "readfile.h"
#include "md5ut.h" #include "md5ut.h"
#include "rclconfig.h" #include "rclconfig.h"
@ -42,8 +42,7 @@ const int KB = 1024;
// Process a plain text file // Process a plain text file
bool MimeHandlerText::set_document_file(const string& mt, const string &fn) bool MimeHandlerText::set_document_file(const string& mt, const string &fn)
{ {
LOGDEB(("MimeHandlerText::set_document_file: [%s] offs %s\n", LOGDEB("MimeHandlerText::set_document_file: [" << (fn) << "] offs " << (lltodecstr(m_offs)) << "\n" );
fn.c_str(), lltodecstr(m_offs).c_str()));
RecollFilter::set_document_file(mt, fn); RecollFilter::set_document_file(mt, fn);
@ -55,8 +54,7 @@ bool MimeHandlerText::set_document_file(const string& mt, const string &fn)
// file size for oversize check // file size for oversize check
long long fsize = path_filesize(m_fn); long long fsize = path_filesize(m_fn);
if (fsize < 0) { if (fsize < 0) {
LOGERR(("MimeHandlerText::set_document_file: stat %s errno %d\n", LOGERR("MimeHandlerText::set_document_file: stat " << (m_fn) << " errno " << (errno) << "\n" );
m_fn.c_str(), errno));
return false; return false;
} }
@ -111,8 +109,7 @@ bool MimeHandlerText::skip_to_document(const string& ipath)
char *endptr; char *endptr;
long long t = strtoll(ipath.c_str(), &endptr, 10); long long t = strtoll(ipath.c_str(), &endptr, 10);
if (endptr == ipath.c_str()) { if (endptr == ipath.c_str()) {
LOGERR(("MimeHandlerText::skip_to_document: bad ipath offs [%s]\n", LOGERR("MimeHandlerText::skip_to_document: bad ipath offs [" << (ipath) << "]\n" );
ipath.c_str()));
return false; return false;
} }
m_offs = (off_t)t; m_offs = (off_t)t;
@ -122,7 +119,7 @@ bool MimeHandlerText::skip_to_document(const string& ipath)
bool MimeHandlerText::next_document() bool MimeHandlerText::next_document()
{ {
LOGDEB(("MimeHandlerText::next_document: m_havedoc %d\n", int(m_havedoc))); LOGDEB("MimeHandlerText::next_document: m_havedoc " << (int(m_havedoc)) << "\n" );
if (m_havedoc == false) if (m_havedoc == false)
return false; return false;
@ -175,7 +172,7 @@ bool MimeHandlerText::readnext()
string reason; string reason;
m_text.clear(); m_text.clear();
if (!file_to_string(m_fn, m_text, m_offs, m_pagesz, &reason)) { if (!file_to_string(m_fn, m_text, m_offs, m_pagesz, &reason)) {
LOGERR(("MimeHandlerText: can't read file: %s\n", reason.c_str())); LOGERR("MimeHandlerText: can't read file: " << (reason) << "\n" );
m_havedoc = false; m_havedoc = false;
return false; return false;
} }
@ -197,3 +194,4 @@ bool MimeHandlerText::readnext()
m_offs += m_text.length(); m_offs += m_text.length();
return true; return true;
} }

View file

@ -27,7 +27,7 @@ using namespace std;
#include "cstr.h" #include "cstr.h"
#include "mimehandler.h" #include "mimehandler.h"
#include "debuglog.h" #include "log.h"
#include "rclconfig.h" #include "rclconfig.h"
#include "smallut.h" #include "smallut.h"
#include "md5ut.h" #include "md5ut.h"
@ -60,8 +60,7 @@ static RecollFilter *getMimeHandlerFromCache(const string& key)
PTMutexLocker locker(o_handlers_mutex); PTMutexLocker locker(o_handlers_mutex);
string xdigest; string xdigest;
MD5HexPrint(key, xdigest); MD5HexPrint(key, xdigest);
LOGDEB(("getMimeHandlerFromCache: %s cache size %u\n", LOGDEB("getMimeHandlerFromCache: " << (xdigest) << " cache size " << (o_handlers.size()) << "\n" );
xdigest.c_str(), o_handlers.size()));
multimap<string, RecollFilter *>::iterator it = o_handlers.find(key); multimap<string, RecollFilter *>::iterator it = o_handlers.find(key);
if (it != o_handlers.end()) { if (it != o_handlers.end()) {
@ -70,14 +69,13 @@ static RecollFilter *getMimeHandlerFromCache(const string& key)
if (it1 != o_hlru.end()) { if (it1 != o_hlru.end()) {
o_hlru.erase(it1); o_hlru.erase(it1);
} else { } else {
LOGERR(("getMimeHandlerFromCache: lru position not found\n")); LOGERR("getMimeHandlerFromCache: lru position not found\n" );
} }
o_handlers.erase(it); o_handlers.erase(it);
LOGDEB(("getMimeHandlerFromCache: %s found size %u\n", LOGDEB("getMimeHandlerFromCache: " << (xdigest) << " found size " << (o_handlers.size()) << "\n" );
xdigest.c_str(), o_handlers.size()));
return h; return h;
} }
LOGDEB(("getMimeHandlerFromCache: %s not found\n", xdigest.c_str())); LOGDEB("getMimeHandlerFromCache: " << (xdigest) << " not found\n" );
return 0; return 0;
} }
@ -87,15 +85,14 @@ void returnMimeHandler(RecollFilter *handler)
typedef multimap<string, RecollFilter*>::value_type value_type; typedef multimap<string, RecollFilter*>::value_type value_type;
if (handler == 0) { if (handler == 0) {
LOGERR(("returnMimeHandler: bad parameter\n")); LOGERR("returnMimeHandler: bad parameter\n" );
return; return;
} }
handler->clear(); handler->clear();
PTMutexLocker locker(o_handlers_mutex); PTMutexLocker locker(o_handlers_mutex);
LOGDEB(("returnMimeHandler: returning filter for %s cache size %d\n", LOGDEB("returnMimeHandler: returning filter for " << (handler->get_mime_type()) << " cache size " << (o_handlers.size()) << "\n" );
handler->get_mime_type().c_str(), o_handlers.size()));
// Limit pool size. The pool can grow quite big because there are // Limit pool size. The pool can grow quite big because there are
// many filter types, each of which can be used in several copies // many filter types, each of which can be used in several copies
@ -108,9 +105,9 @@ void returnMimeHandler(RecollFilter *handler)
if (once) { if (once) {
once = 0; once = 0;
for (it = o_handlers.begin(); it != o_handlers.end(); it++) { for (it = o_handlers.begin(); it != o_handlers.end(); it++) {
LOGDEB1(("Cache full. key: %s\n", it->first.c_str())); LOGDEB1("Cache full. key: " << (it->first) << "\n" );
} }
LOGDEB1(("Cache LRU size: %u\n", o_hlru.size())); LOGDEB1("Cache LRU size: " << (o_hlru.size()) << "\n" );
} }
if (o_hlru.size() > 0) { if (o_hlru.size() > 0) {
it = o_hlru.back(); it = o_hlru.back();
@ -125,7 +122,7 @@ void returnMimeHandler(RecollFilter *handler)
void clearMimeHandlerCache() void clearMimeHandlerCache()
{ {
LOGDEB(("clearMimeHandlerCache()\n")); LOGDEB("clearMimeHandlerCache()\n" );
multimap<string, RecollFilter *>::iterator it; multimap<string, RecollFilter *>::iterator it;
PTMutexLocker locker(o_handlers_mutex); PTMutexLocker locker(o_handlers_mutex);
for (it = o_handlers.begin(); it != o_handlers.end(); it++) { for (it = o_handlers.begin(); it != o_handlers.end(); it++) {
@ -139,31 +136,31 @@ void clearMimeHandlerCache()
static RecollFilter *mhFactory(RclConfig *config, const string &mime, static RecollFilter *mhFactory(RclConfig *config, const string &mime,
bool nobuild, string& id) bool nobuild, string& id)
{ {
LOGDEB2(("mhFactory(%s)\n", mime.c_str())); LOGDEB2("mhFactory(" << (mime) << ")\n" );
string lmime(mime); string lmime(mime);
stringtolower(lmime); stringtolower(lmime);
if (cstr_textplain == lmime) { if (cstr_textplain == lmime) {
LOGDEB2(("mhFactory(%s): returning MimeHandlerText\n", mime.c_str())); LOGDEB2("mhFactory(" << (mime) << "): returning MimeHandlerText\n" );
MD5String("MimeHandlerText", id); MD5String("MimeHandlerText", id);
return nobuild ? 0 : new MimeHandlerText(config, id); return nobuild ? 0 : new MimeHandlerText(config, id);
} else if ("text/html" == lmime) { } else if ("text/html" == lmime) {
LOGDEB2(("mhFactory(%s): returning MimeHandlerHtml\n", mime.c_str())); LOGDEB2("mhFactory(" << (mime) << "): returning MimeHandlerHtml\n" );
MD5String("MimeHandlerHtml", id); MD5String("MimeHandlerHtml", id);
return nobuild ? 0 : new MimeHandlerHtml(config, id); return nobuild ? 0 : new MimeHandlerHtml(config, id);
} else if ("text/x-mail" == lmime) { } else if ("text/x-mail" == lmime) {
LOGDEB2(("mhFactory(%s): returning MimeHandlerMbox\n", mime.c_str())); LOGDEB2("mhFactory(" << (mime) << "): returning MimeHandlerMbox\n" );
MD5String("MimeHandlerMbox", id); MD5String("MimeHandlerMbox", id);
return nobuild ? 0 : new MimeHandlerMbox(config, id); return nobuild ? 0 : new MimeHandlerMbox(config, id);
} else if ("message/rfc822" == lmime) { } else if ("message/rfc822" == lmime) {
LOGDEB2(("mhFactory(%s): returning MimeHandlerMail\n", mime.c_str())); LOGDEB2("mhFactory(" << (mime) << "): returning MimeHandlerMail\n" );
MD5String("MimeHandlerMail", id); MD5String("MimeHandlerMail", id);
return nobuild ? 0 : new MimeHandlerMail(config, id); return nobuild ? 0 : new MimeHandlerMail(config, id);
} else if ("inode/symlink" == lmime) { } else if ("inode/symlink" == lmime) {
LOGDEB2(("mhFactory(%s): ret MimeHandlerSymlink\n", mime.c_str())); LOGDEB2("mhFactory(" << (mime) << "): ret MimeHandlerSymlink\n" );
MD5String("MimeHandlerSymlink", id); MD5String("MimeHandlerSymlink", id);
return nobuild ? 0 : new MimeHandlerSymlink(config, id); return nobuild ? 0 : new MimeHandlerSymlink(config, id);
} else if ("application/x-zerosize" == lmime) { } else if ("application/x-zerosize" == lmime) {
LOGDEB(("mhFactory(%s): ret MimeHandlerNull\n", mime.c_str())); LOGDEB("mhFactory(" << (mime) << "): ret MimeHandlerNull\n" );
MD5String("MimeHandlerNull", id); MD5String("MimeHandlerNull", id);
return nobuild ? 0 : new MimeHandlerNull(config, id); return nobuild ? 0 : new MimeHandlerNull(config, id);
} else if (lmime.find("text/") == 0) { } else if (lmime.find("text/") == 0) {
@ -172,15 +169,14 @@ static RecollFilter *mhFactory(RclConfig *config, const string &mime,
// mimeconf, not at random. For programs, for example this // mimeconf, not at random. For programs, for example this
// allows indexing and previewing as text/plain (no filter // allows indexing and previewing as text/plain (no filter
// exec) but still opening with a specific editor. // exec) but still opening with a specific editor.
LOGDEB2(("mhFactory(%s): returning MimeHandlerText(x)\n",mime.c_str())); LOGDEB2("mhFactory(" << (mime) << "): returning MimeHandlerText(x)\n" );
MD5String("MimeHandlerText", id); MD5String("MimeHandlerText", id);
return nobuild ? 0 : new MimeHandlerText(config, id); return nobuild ? 0 : new MimeHandlerText(config, id);
} else { } else {
// We should not get there. It means that "internal" was set // We should not get there. It means that "internal" was set
// as a handler in mimeconf for a mime type we actually can't // as a handler in mimeconf for a mime type we actually can't
// handle. // handle.
LOGERR(("mhFactory: mime type [%s] set as internal but unknown\n", LOGERR("mhFactory: mime type [" << (lmime) << "] set as internal but unknown\n" );
lmime.c_str()));
MD5String("MimeHandlerUnknown", id); MD5String("MimeHandlerUnknown", id);
return nobuild ? 0 : new MimeHandlerUnknown(config, id); return nobuild ? 0 : new MimeHandlerUnknown(config, id);
} }
@ -203,8 +199,7 @@ MimeHandlerExec *mhExecFactory(RclConfig *cfg, const string& mtype, string& hs,
string cmdstr; string cmdstr;
if (!cfg->valueSplitAttributes(hs, cmdstr, attrs)) { if (!cfg->valueSplitAttributes(hs, cmdstr, attrs)) {
LOGERR(("mhExecFactory: bad config line for [%s]: [%s]\n", LOGERR("mhExecFactory: bad config line for [" << (mtype) << "]: [" << (hs) << "]\n" );
mtype.c_str(), hs.c_str()));
return 0; return 0;
} }
@ -212,8 +207,7 @@ MimeHandlerExec *mhExecFactory(RclConfig *cfg, const string& mtype, string& hs,
vector<string> cmdtoks; vector<string> cmdtoks;
stringToStrings(cmdstr, cmdtoks); stringToStrings(cmdstr, cmdtoks);
if (cmdtoks.empty()) { if (cmdtoks.empty()) {
LOGERR(("mhExecFactory: bad config line for [%s]: [%s]\n", LOGERR("mhExecFactory: bad config line for [" << (mtype) << "]: [" << (hs) << "]\n" );
mtype.c_str(), hs.c_str()));
return 0; return 0;
} }
MimeHandlerExec *h = multiple ? MimeHandlerExec *h = multiple ?
@ -227,8 +221,7 @@ MimeHandlerExec *mhExecFactory(RclConfig *cfg, const string& mtype, string& hs,
// the same change if we ever want to use the same cmdling as windows // the same change if we ever want to use the same cmdling as windows
if (!stringlowercmp("python", *it) || !stringlowercmp("perl", *it)) { if (!stringlowercmp("python", *it) || !stringlowercmp("perl", *it)) {
if (cmdtoks.size() < 2) { if (cmdtoks.size() < 2) {
LOGERR(("mhExecFactory: python/perl cmd: no script?. [%s]: [%s]\n", LOGERR("mhExecFactory: python/perl cmd: no script?. [" << (mtype) << "]: [" << (hs) << "]\n" );
mtype.c_str(), hs.c_str()));
} }
vector<string>::iterator it1(it); vector<string>::iterator it1(it);
it1++; it1++;
@ -251,9 +244,7 @@ MimeHandlerExec *mhExecFactory(RclConfig *cfg, const string& mtype, string& hs,
for (it = h->params.begin(); it != h->params.end(); it++) { for (it = h->params.begin(); it != h->params.end(); it++) {
scmd += string("[") + *it + "] "; scmd += string("[") + *it + "] ";
} }
LOGDEB(("mhExecFactory:mt [%s] cfgmt [%s] cfgcs [%s] cmd: [%s]\n", LOGDEB("mhExecFactory:mt [" << (mtype) << "] cfgmt [" << (h->cfgFilterOutputMtype) << "] cfgcs [" << (h->cfgFilterOutputCharset) << "] cmd: [" << (scmd) << "]\n" );
mtype.c_str(), h->cfgFilterOutputMtype.c_str(), h->cfgFilterOutputCharset.c_str(),
scmd.c_str()));
#endif #endif
return h; return h;
@ -263,8 +254,7 @@ MimeHandlerExec *mhExecFactory(RclConfig *cfg, const string& mtype, string& hs,
RecollFilter *getMimeHandler(const string &mtype, RclConfig *cfg, RecollFilter *getMimeHandler(const string &mtype, RclConfig *cfg,
bool filtertypes) bool filtertypes)
{ {
LOGDEB(("getMimeHandler: mtype [%s] filtertypes %d\n", LOGDEB("getMimeHandler: mtype [" << (mtype) << "] filtertypes " << (filtertypes) << "\n" );
mtype.c_str(), filtertypes));
RecollFilter *h = 0; RecollFilter *h = 0;
// Get handler definition for mime type. We do this even if an // Get handler definition for mime type. We do this even if an
@ -297,18 +287,12 @@ RecollFilter *getMimeHandler(const string &mtype, RclConfig *cfg,
MD5String(hs, id); MD5String(hs, id);
} }
#if 0
{ // string xdigest; LOGDEB2(("getMimeHandler: [%s] hs [%s] id [%s]\n",
//mtype.c_str(), hs.c_str(), MD5HexPrint(id, xdigest).c_str()));
}
#endif
// Do we already have a handler object in the cache ? // Do we already have a handler object in the cache ?
h = getMimeHandlerFromCache(id); h = getMimeHandlerFromCache(id);
if (h != 0) if (h != 0)
goto out; goto out;
LOGDEB2(("getMimeHandler: %s not in cache\n", mtype.c_str())); LOGDEB2("getMimeHandler: " << (mtype) << " not in cache\n" );
// Not in cache. // Not in cache.
if (internal) { if (internal) {
@ -319,14 +303,13 @@ RecollFilter *getMimeHandler(const string &mtype, RclConfig *cfg,
// partly redundant with the localfields/rclaptg, but // partly redundant with the localfields/rclaptg, but
// better and the latter will probably go away at some // better and the latter will probably go away at some
// point in the future. // point in the future.
LOGDEB2(("handlertype internal, cmdstr [%s]\n", cmdstr.c_str())); LOGDEB2("handlertype internal, cmdstr [" << (cmdstr) << "]\n" );
h = mhFactory(cfg, cmdstr.empty() ? mtype : cmdstr, false, id); h = mhFactory(cfg, cmdstr.empty() ? mtype : cmdstr, false, id);
goto out; goto out;
} else if (!stringlowercmp("dll", handlertype)) { } else if (!stringlowercmp("dll", handlertype)) {
} else { } else {
if (cmdstr.empty()) { if (cmdstr.empty()) {
LOGERR(("getMimeHandler: bad line for %s: %s\n", LOGERR("getMimeHandler: bad line for " << (mtype) << ": " << (hs) << "\n" );
mtype.c_str(), hs.c_str()));
goto out; goto out;
} }
if (!stringlowercmp("exec", handlertype)) { if (!stringlowercmp("exec", handlertype)) {
@ -336,8 +319,7 @@ RecollFilter *getMimeHandler(const string &mtype, RclConfig *cfg,
h = mhExecFactory(cfg, mtype, cmdstr, true, id); h = mhExecFactory(cfg, mtype, cmdstr, true, id);
goto out; goto out;
} else { } else {
LOGERR(("getMimeHandler: bad line for %s: %s\n", LOGERR("getMimeHandler: bad line for " << (mtype) << ": " << (hs) << "\n" );
mtype.c_str(), hs.c_str()));
goto out; goto out;
} }
} }
@ -380,3 +362,4 @@ bool canIntern(const std::string mtype, RclConfig *cfg)
return false; return false;
return true; return true;
} }

View file

@ -37,7 +37,7 @@
#include "mimeparse.h" #include "mimeparse.h"
#include "smallut.h" #include "smallut.h"
#include "cancelcheck.h" #include "cancelcheck.h"
#include "debuglog.h" #include "log.h"
#include "transcode.h" #include "transcode.h"
static const string cstr_html_charset("charset"); static const string cstr_html_charset("charset");
@ -193,7 +193,7 @@ MyHtmlParser::MyHtmlParser()
void MyHtmlParser::decode_entities(string &s) void MyHtmlParser::decode_entities(string &s)
{ {
LOGDEB2(("MyHtmlParser::decode_entities\n")); LOGDEB2("MyHtmlParser::decode_entities\n" );
// This has no meaning whatsoever if the character encoding is unknown, // This has no meaning whatsoever if the character encoding is unknown,
// so don't do it. If charset known, caller has converted text to utf-8, // so don't do it. If charset known, caller has converted text to utf-8,
// and this is also how we translate entities // and this is also how we translate entities
@ -261,14 +261,7 @@ void MyHtmlParser::decode_entities(string &s)
void void
MyHtmlParser::process_text(const string &text) MyHtmlParser::process_text(const string &text)
{ {
LOGDEB2(("process_text: title %d script %d style %d pre %d " LOGDEB2("process_text: title " << (in_title_tag) << " script " << (in_script_tag) << " style " << (in_style_tag) << " pre " << (in_pre_tag) << " pending_space " << (pending_space) << " txt [" << (text) << "]\n" );
"pending_space %d txt [%s]\n",
in_title_tag,
in_script_tag,
in_style_tag,
in_pre_tag,
pending_space,
text.c_str()));
CancelCheck::instance().checkCancel(); CancelCheck::instance().checkCancel();
if (!in_script_tag && !in_style_tag) { if (!in_script_tag && !in_style_tag) {
@ -307,7 +300,7 @@ MyHtmlParser::process_text(const string &text)
bool bool
MyHtmlParser::opening_tag(const string &tag) MyHtmlParser::opening_tag(const string &tag)
{ {
LOGDEB2(("opening_tag: [%s]\n", tag.c_str())); LOGDEB2("opening_tag: [" << (tag) << "]\n" );
#if 0 #if 0
cout << "TAG: " << tag << ": " << endl; cout << "TAG: " << tag << ": " << endl;
map<string, string>::const_iterator x; map<string, string>::const_iterator x;
@ -419,10 +412,7 @@ MyHtmlParser::opening_tag(const string &tag)
charset = k->second; charset = k->second;
if (!charset.empty() && if (!charset.empty() &&
!samecharset(charset, fromcharset)) { !samecharset(charset, fromcharset)) {
LOGDEB1(("Doc http-equiv charset '%s' " LOGDEB1("Doc http-equiv charset '" << (charset) << "' differs from dir deflt '" << (fromcharset) << "'\n" );
"differs from dir deflt '%s'\n",
charset.c_str(),
fromcharset.c_str()));
throw false; throw false;
} }
} }
@ -436,10 +426,7 @@ MyHtmlParser::opening_tag(const string &tag)
charset = newcharset; charset = newcharset;
if (!charset.empty() && if (!charset.empty() &&
!samecharset(charset, fromcharset)) { !samecharset(charset, fromcharset)) {
LOGDEB1(("Doc html5 charset '%s' " LOGDEB1("Doc html5 charset '" << (charset) << "' differs from dir deflt '" << (fromcharset) << "'\n" );
"differs from dir deflt '%s'\n",
charset.c_str(),
fromcharset.c_str()));
throw false; throw false;
} }
} }
@ -494,7 +481,7 @@ MyHtmlParser::opening_tag(const string &tag)
bool bool
MyHtmlParser::closing_tag(const string &tag) MyHtmlParser::closing_tag(const string &tag)
{ {
LOGDEB2(("closing_tag: [%s]\n", tag.c_str())); LOGDEB2("closing_tag: [" << (tag) << "]\n" );
if (tag.empty()) return true; if (tag.empty()) return true;
switch (tag[0]) { switch (tag[0]) {
case 'a': case 'a':
@ -592,3 +579,4 @@ void
MyHtmlParser::do_eof() MyHtmlParser::do_eof()
{ {
} }

View file

@ -18,7 +18,7 @@
#include "cstr.h" #include "cstr.h"
#include "transcode.h" #include "transcode.h"
#include "mimehandler.h" #include "mimehandler.h"
#include "debuglog.h" #include "log.h"
#include "smallut.h" #include "smallut.h"
@ -33,8 +33,7 @@ static bool alternate_decode(const string& in, string& out)
{ {
string lang = localelang(); string lang = localelang();
string code = langtocode(lang); string code = langtocode(lang);
LOGDEB(("RecollFilter::txtdcode: trying alternate decode from %s\n", LOGDEB("RecollFilter::txtdcode: trying alternate decode from " << (code) << "\n" );
code.c_str()));
int ecnt; int ecnt;
bool ret = transcode(in, out, code, cstr_utf8, &ecnt); bool ret = transcode(in, out, code, cstr_utf8, &ecnt);
return ecnt > 5 ? false : ret; return ecnt > 5 ? false : ret;
@ -43,22 +42,18 @@ static bool alternate_decode(const string& in, string& out)
bool RecollFilter::txtdcode(const string& who) bool RecollFilter::txtdcode(const string& who)
{ {
if (m_metaData[cstr_dj_keymt].compare(cstr_textplain)) { if (m_metaData[cstr_dj_keymt].compare(cstr_textplain)) {
LOGERR(("%s::txtdcode: called on non txt/plain: %s\n", who.c_str(), LOGERR("" << (who) << "::txtdcode: called on non txt/plain: " << (m_metaData[cstr_dj_keymt]) << "\n" );
m_metaData[cstr_dj_keymt].c_str()));
return false; return false;
} }
string& ocs = m_metaData[cstr_dj_keyorigcharset]; string& ocs = m_metaData[cstr_dj_keyorigcharset];
string& itext = m_metaData[cstr_dj_keycontent]; string& itext = m_metaData[cstr_dj_keycontent];
LOGDEB1(("%s::txtdcode: %d bytes from [%s] to UTF-8\n", LOGDEB1("" << (who) << "::txtdcode: " << (itext.size()) << " bytes from [" << (ocs) << "] to UTF-8\n" );
who.c_str(), itext.size(), ocs.c_str()));
int ecnt; int ecnt;
string otext; string otext;
bool ret = transcode(itext, otext, ocs, cstr_utf8, &ecnt); bool ret = transcode(itext, otext, ocs, cstr_utf8, &ecnt);
if (!ret || ecnt > int(itext.size() / 100)) { if (!ret || ecnt > int(itext.size() / 100)) {
LOGERR(("%s::txtdcode: transcode %d bytes to UTF-8 failed " LOGERR("" << (who) << "::txtdcode: transcode " << (itext.size()) << " bytes to UTF-8 failed for input charset [" << (ocs) << "] ret " << (ret) << " ecnt " << (ecnt) << "\n" );
"for input charset [%s] ret %d ecnt %d\n",
who.c_str(), itext.size(), ocs.c_str(), ret, ecnt));
if (samecharset(ocs, cstr_utf8)) { if (samecharset(ocs, cstr_utf8)) {
ret = alternate_decode(itext, otext); ret = alternate_decode(itext, otext);
@ -66,7 +61,7 @@ bool RecollFilter::txtdcode(const string& who)
ret = false; ret = false;
} }
if (!ret) { if (!ret) {
LOGDEB(("txtdcode: failed. Doc is not text?\n")); LOGDEB("txtdcode: failed. Doc is not text?\n" );
itext.erase(); itext.erase();
return false; return false;
} }
@ -77,3 +72,4 @@ bool RecollFilter::txtdcode(const string& who)
return true; return true;
} }

View file

@ -24,7 +24,7 @@
#include <map> #include <map>
#include "uncomp.h" #include "uncomp.h"
#include "debuglog.h" #include "log.h"
#include "smallut.h" #include "smallut.h"
#include "execmd.h" #include "execmd.h"
#include "pathut.h" #include "pathut.h"
@ -57,7 +57,7 @@ bool Uncomp::uncompressfile(const string& ifn,
} }
// Make sure tmp dir is empty. we guarantee this to filters // Make sure tmp dir is empty. we guarantee this to filters
if (!m_dir || !m_dir->ok() || !m_dir->wipe()) { if (!m_dir || !m_dir->ok() || !m_dir->wipe()) {
LOGERR(("uncompressfile: can't clear temp dir %s\n", m_dir->dirname())); LOGERR("uncompressfile: can't clear temp dir " << (m_dir->dirname()) << "\n" );
return false; return false;
} }
@ -66,14 +66,12 @@ bool Uncomp::uncompressfile(const string& ifn,
int pc; int pc;
long long availmbs; long long availmbs;
if (!fsocc(m_dir->dirname(), &pc, &availmbs)) { if (!fsocc(m_dir->dirname(), &pc, &availmbs)) {
LOGERR(("uncompressfile: can't retrieve avail space for %s\n", LOGERR("uncompressfile: can't retrieve avail space for " << (m_dir->dirname()) << "\n" );
m_dir->dirname()));
// Hope for the best // Hope for the best
} else { } else {
long long fsize = path_filesize(ifn); long long fsize = path_filesize(ifn);
if (fsize < 0) { if (fsize < 0) {
LOGERR(("uncompressfile: stat input file %s errno %d\n", LOGERR("uncompressfile: stat input file " << (ifn) << " errno " << (errno) << "\n" );
ifn.c_str(), errno));
return false; return false;
} }
// We need at least twice the file size for the uncompressed // We need at least twice the file size for the uncompressed
@ -85,10 +83,7 @@ bool Uncomp::uncompressfile(const string& ifn,
long long filembs = fsize / (1024 * 1024); long long filembs = fsize / (1024 * 1024);
if (availmbs < 2 * filembs + 1) { if (availmbs < 2 * filembs + 1) {
LOGERR(("uncompressfile. %s MBs available in %s not enough " LOGERR("uncompressfile. " << (lltodecstr(availmbs)) << " MBs available in " << (m_dir->dirname()) << " not enough to uncompress " << (ifn) << " of size " << (lltodecstr(filembs)) << " mbs\n" );
"to uncompress %s of size %s mbs\n",
lltodecstr(availmbs).c_str(), m_dir->dirname(),
ifn.c_str(), lltodecstr(filembs).c_str()));
return false; return false;
} }
} }
@ -112,10 +107,9 @@ bool Uncomp::uncompressfile(const string& ifn,
ExecCmd ex; ExecCmd ex;
int status = ex.doexec(cmd, args, 0, &tfile); int status = ex.doexec(cmd, args, 0, &tfile);
if (status || tfile.empty()) { if (status || tfile.empty()) {
LOGERR(("uncompressfile: doexec: failed for [%s] status 0x%x\n", LOGERR("uncompressfile: doexec: failed for [" << (ifn) << "] status 0x" << (status) << "\n" );
ifn.c_str(), status));
if (!m_dir->wipe()) { if (!m_dir->wipe()) {
LOGERR(("uncompressfile: wipedir failed\n")); LOGERR("uncompressfile: wipedir failed\n" );
} }
return false; return false;
} }
@ -139,3 +133,4 @@ Uncomp::~Uncomp()
} }
} }

View file

@ -36,7 +36,7 @@
#include "rclconfig.h" #include "rclconfig.h"
#include "pathut.h" #include "pathut.h"
#include "rclinit.h" #include "rclinit.h"
#include "debuglog.h" #include "log.h"
#include "wasatorcl.h" #include "wasatorcl.h"
#include "internfile.h" #include "internfile.h"
#include "wipedir.h" #include "wipedir.h"
@ -238,3 +238,4 @@ extern "C" {
ZEND_GET_MODULE(recoll) ZEND_GET_MODULE(recoll)
} }
#endif #endif

View file

@ -25,7 +25,7 @@
#include <string> #include <string>
using namespace std; using namespace std;
#include "debuglog.h" #include "log.h"
#include "rcldoc.h" #include "rcldoc.h"
#include "internfile.h" #include "internfile.h"
#include "rclconfig.h" #include "rclconfig.h"
@ -49,7 +49,7 @@ typedef struct {
static void static void
Extractor_dealloc(rclx_ExtractorObject *self) Extractor_dealloc(rclx_ExtractorObject *self)
{ {
LOGDEB(("Extractor_dealloc\n")); LOGDEB("Extractor_dealloc\n" );
delete self->xtr; delete self->xtr;
Py_TYPE(self)->tp_free((PyObject*)self); Py_TYPE(self)->tp_free((PyObject*)self);
} }
@ -57,7 +57,7 @@ Extractor_dealloc(rclx_ExtractorObject *self)
static PyObject * static PyObject *
Extractor_new(PyTypeObject *type, PyObject *args, PyObject *kwds) Extractor_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{ {
LOGDEB(("Extractor_new\n")); LOGDEB("Extractor_new\n" );
rclx_ExtractorObject *self = rclx_ExtractorObject *self =
(rclx_ExtractorObject *)type->tp_alloc(type, 0); (rclx_ExtractorObject *)type->tp_alloc(type, 0);
if (self == 0) if (self == 0)
@ -70,7 +70,7 @@ Extractor_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static int static int
Extractor_init(rclx_ExtractorObject *self, PyObject *args, PyObject *kwargs) Extractor_init(rclx_ExtractorObject *self, PyObject *args, PyObject *kwargs)
{ {
LOGDEB(("Extractor_init\n")); LOGDEB("Extractor_init\n" );
static const char* kwlist[] = {"doc", NULL}; static const char* kwlist[] = {"doc", NULL};
PyObject *pdobj; PyObject *pdobj;
@ -99,7 +99,7 @@ static PyObject *
Extractor_textextract(rclx_ExtractorObject* self, PyObject *args, Extractor_textextract(rclx_ExtractorObject* self, PyObject *args,
PyObject *kwargs) PyObject *kwargs)
{ {
LOGDEB(("Extractor_textextract\n")); LOGDEB("Extractor_textextract\n" );
static const char* kwlist[] = {"ipath", NULL}; static const char* kwlist[] = {"ipath", NULL};
char *sipath = 0; char *sipath = 0;
@ -153,7 +153,7 @@ static PyObject *
Extractor_idoctofile(rclx_ExtractorObject* self, PyObject *args, Extractor_idoctofile(rclx_ExtractorObject* self, PyObject *args,
PyObject *kwargs) PyObject *kwargs)
{ {
LOGDEB(("Extractor_idoctofile\n")); LOGDEB("Extractor_idoctofile\n" );
static const char* kwlist[] = {"ipath", "mimetype", "ofilename", NULL}; static const char* kwlist[] = {"ipath", "mimetype", "ofilename", NULL};
char *sipath = 0; char *sipath = 0;
char *smt = 0; char *smt = 0;
@ -359,3 +359,4 @@ initrclextract(void)
return module; return module;
#endif #endif
} }

View file

@ -34,7 +34,7 @@ using namespace std;
#include "pathut.h" #include "pathut.h"
#include "rclutil.h" #include "rclutil.h"
#include "wasatorcl.h" #include "wasatorcl.h"
#include "debuglog.h" #include "log.h"
#include "pathut.h" #include "pathut.h"
#include "plaintorich.h" #include "plaintorich.h"
#include "hldata.h" #include "hldata.h"
@ -62,8 +62,7 @@ typedef struct {
static void static void
SearchData_dealloc(recoll_SearchDataObject *self) SearchData_dealloc(recoll_SearchDataObject *self)
{ {
LOGDEB(("SearchData_dealloc. Releasing. Count before: %d\n", LOGDEB("SearchData_dealloc. Releasing. Count before: " << (self->sd.use_count()) << "\n" );
self->sd.use_count()));
self->sd.reset(); self->sd.reset();
Py_TYPE(self)->tp_free((PyObject*)self); Py_TYPE(self)->tp_free((PyObject*)self);
} }
@ -71,7 +70,7 @@ SearchData_dealloc(recoll_SearchDataObject *self)
static PyObject * static PyObject *
SearchData_new(PyTypeObject *type, PyObject *args, PyObject *kwds) SearchData_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{ {
LOGDEB(("SearchData_new\n")); LOGDEB("SearchData_new\n" );
recoll_SearchDataObject *self; recoll_SearchDataObject *self;
self = (recoll_SearchDataObject *)type->tp_alloc(type, 0); self = (recoll_SearchDataObject *)type->tp_alloc(type, 0);
@ -90,7 +89,7 @@ PyDoc_STRVAR(doc_SearchDataObject,
static int static int
SearchData_init(recoll_SearchDataObject *self, PyObject *args, PyObject *kwargs) SearchData_init(recoll_SearchDataObject *self, PyObject *args, PyObject *kwargs)
{ {
LOGDEB(("SearchData_init\n")); LOGDEB("SearchData_init\n" );
static const char* kwlist[] = {"type", "stemlang", NULL}; static const char* kwlist[] = {"type", "stemlang", NULL};
char *stp = 0; char *stp = 0;
char *steml = 0; char *steml = 0;
@ -180,9 +179,9 @@ static PyObject *
SearchData_addclause(recoll_SearchDataObject* self, PyObject *args, SearchData_addclause(recoll_SearchDataObject* self, PyObject *args,
PyObject *kwargs) PyObject *kwargs)
{ {
LOGDEB0(("SearchData_addclause\n")); LOGDEB0("SearchData_addclause\n" );
if (!self->sd) { if (!self->sd) {
LOGERR(("SearchData_addclause: not init??\n")); LOGERR("SearchData_addclause: not init??\n" );
PyErr_SetString(PyExc_AttributeError, "sd"); PyErr_SetString(PyExc_AttributeError, "sd");
return 0; return 0;
} }
@ -294,7 +293,7 @@ SearchData_addclause(recoll_SearchDataObject* self, PyObject *args,
static void static void
Doc_dealloc(recoll_DocObject *self) Doc_dealloc(recoll_DocObject *self)
{ {
LOGDEB(("Doc_dealloc\n")); LOGDEB("Doc_dealloc\n" );
if (self->doc) if (self->doc)
the_docs.erase(self->doc); the_docs.erase(self->doc);
deleteZ(self->doc); deleteZ(self->doc);
@ -304,7 +303,7 @@ Doc_dealloc(recoll_DocObject *self)
static PyObject * static PyObject *
Doc_new(PyTypeObject *type, PyObject *args, PyObject *kwds) Doc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{ {
LOGDEB(("Doc_new\n")); LOGDEB("Doc_new\n" );
recoll_DocObject *self; recoll_DocObject *self;
self = (recoll_DocObject *)type->tp_alloc(type, 0); self = (recoll_DocObject *)type->tp_alloc(type, 0);
@ -318,7 +317,7 @@ Doc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static int static int
Doc_init(recoll_DocObject *self, PyObject *, PyObject *) Doc_init(recoll_DocObject *self, PyObject *, PyObject *)
{ {
LOGDEB(("Doc_init\n")); LOGDEB("Doc_init\n" );
if (self->doc) if (self->doc)
the_docs.erase(self->doc); the_docs.erase(self->doc);
delete self->doc; delete self->doc;
@ -340,7 +339,7 @@ PyDoc_STRVAR(doc_Doc_getbinurl,
static PyObject * static PyObject *
Doc_getbinurl(recoll_DocObject *self) Doc_getbinurl(recoll_DocObject *self)
{ {
LOGDEB0(("Doc_getbinurl\n")); LOGDEB0("Doc_getbinurl\n" );
if (self->doc == 0 || if (self->doc == 0 ||
the_docs.find(self->doc) == the_docs.end()) { the_docs.find(self->doc) == the_docs.end()) {
PyErr_SetString(PyExc_AttributeError, "doc"); PyErr_SetString(PyExc_AttributeError, "doc");
@ -359,7 +358,7 @@ PyDoc_STRVAR(doc_Doc_setbinurl,
static PyObject * static PyObject *
Doc_setbinurl(recoll_DocObject *self, PyObject *value) Doc_setbinurl(recoll_DocObject *self, PyObject *value)
{ {
LOGDEB0(("Doc_setbinurl\n")); LOGDEB0("Doc_setbinurl\n" );
if (self->doc == 0 || if (self->doc == 0 ||
the_docs.find(self->doc) == the_docs.end()) { the_docs.find(self->doc) == the_docs.end()) {
PyErr_SetString(PyExc_AttributeError, "doc??"); PyErr_SetString(PyExc_AttributeError, "doc??");
@ -381,7 +380,7 @@ PyDoc_STRVAR(doc_Doc_keys,
static PyObject * static PyObject *
Doc_keys(recoll_DocObject *self) Doc_keys(recoll_DocObject *self)
{ {
LOGDEB0(("Doc_keys\n")); LOGDEB0("Doc_keys\n" );
if (self->doc == 0 || if (self->doc == 0 ||
the_docs.find(self->doc) == the_docs.end()) { the_docs.find(self->doc) == the_docs.end()) {
PyErr_SetString(PyExc_AttributeError, "doc"); PyErr_SetString(PyExc_AttributeError, "doc");
@ -406,7 +405,7 @@ PyDoc_STRVAR(doc_Doc_items,
static PyObject * static PyObject *
Doc_items(recoll_DocObject *self) Doc_items(recoll_DocObject *self)
{ {
LOGDEB0(("Doc_items\n")); LOGDEB0("Doc_items\n" );
if (self->doc == 0 || if (self->doc == 0 ||
the_docs.find(self->doc) == the_docs.end()) { the_docs.find(self->doc) == the_docs.end()) {
PyErr_SetString(PyExc_AttributeError, "doc"); PyErr_SetString(PyExc_AttributeError, "doc");
@ -436,7 +435,7 @@ PyDoc_STRVAR(doc_Doc_get,
static PyObject * static PyObject *
Doc_get(recoll_DocObject *self, PyObject *args) Doc_get(recoll_DocObject *self, PyObject *args)
{ {
LOGDEB0(("Doc_get\n")); LOGDEB0("Doc_get\n" );
char *sutf8 = 0; // needs freeing char *sutf8 = 0; // needs freeing
if (!PyArg_ParseTuple(args, "es:Doc_get", if (!PyArg_ParseTuple(args, "es:Doc_get",
"utf-8", &sutf8)) { "utf-8", &sutf8)) {
@ -490,7 +489,7 @@ static PyMethodDef Doc_methods[] = {
static PyObject * static PyObject *
Doc_getattro(recoll_DocObject *self, PyObject *nameobj) Doc_getattro(recoll_DocObject *self, PyObject *nameobj)
{ {
LOGDEB0(("Doc_getattro\n")); LOGDEB0("Doc_getattro\n" );
if (self->doc == 0 || the_docs.find(self->doc) == the_docs.end()) { if (self->doc == 0 || the_docs.find(self->doc) == the_docs.end()) {
PyErr_SetString(PyExc_AttributeError, "doc"); PyErr_SetString(PyExc_AttributeError, "doc");
return 0; return 0;
@ -505,7 +504,7 @@ Doc_getattro(recoll_DocObject *self, PyObject *nameobj)
if (PyUnicode_Check(nameobj)) { if (PyUnicode_Check(nameobj)) {
utf8o = PyUnicode_AsUTF8String(nameobj); utf8o = PyUnicode_AsUTF8String(nameobj);
if (utf8o == 0) { if (utf8o == 0) {
LOGERR(("Doc_getattro: encoding name to utf8 failed\n")); LOGERR("Doc_getattro: encoding name to utf8 failed\n" );
PyErr_SetString(PyExc_AttributeError, "name??"); PyErr_SetString(PyExc_AttributeError, "name??");
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@ -597,7 +596,7 @@ Doc_getattro(recoll_DocObject *self, PyObject *nameobj)
} }
if (found) { if (found) {
LOGDEB1(("Doc_getattro: [%s] -> [%s]\n", key.c_str(), value.c_str())); LOGDEB1("Doc_getattro: [" << (key) << "] -> [" << (value) << "]\n" );
// Return a python unicode object // Return a python unicode object
return PyUnicode_Decode(value.c_str(), value.size(), "utf-8", return PyUnicode_Decode(value.c_str(), value.size(), "utf-8",
"replace"); "replace");
@ -636,15 +635,14 @@ Doc_setattr(recoll_DocObject *self, char *name, PyObject *value)
PyObject* putf8 = PyUnicode_AsUTF8String(value); PyObject* putf8 = PyUnicode_AsUTF8String(value);
if (putf8 == 0) { if (putf8 == 0) {
LOGERR(("Doc_setmeta: encoding to utf8 failed\n")); LOGERR("Doc_setmeta: encoding to utf8 failed\n" );
PyErr_SetString(PyExc_AttributeError, "value??"); PyErr_SetString(PyExc_AttributeError, "value??");
return -1; return -1;
} }
char* uvalue = PyBytes_AsString(putf8); char* uvalue = PyBytes_AsString(putf8);
string key = rclconfig->fieldQCanon(string(name)); string key = rclconfig->fieldQCanon(string(name));
LOGDEB0(("Doc_setattr: doc %p [%s] (%s) -> [%s]\n", LOGDEB0("Doc_setattr: doc " << (self->doc) << " [" << (key) << "] (" << (name) << ") -> [" << (uvalue) << "]\n" );
self->doc, key.c_str(), name, uvalue));
// We set the value in the meta array in all cases. Good idea ? or do it // We set the value in the meta array in all cases. Good idea ? or do it
// only for fields without a dedicated Doc:: entry? // only for fields without a dedicated Doc:: entry?
@ -804,7 +802,7 @@ PyDoc_STRVAR(doc_Query_close,
static PyObject * static PyObject *
Query_close(recoll_QueryObject *self) Query_close(recoll_QueryObject *self)
{ {
LOGDEB(("Query_close\n")); LOGDEB("Query_close\n" );
if (self->query) { if (self->query) {
the_queries.erase(self->query); the_queries.erase(self->query);
deleteZ(self->query); deleteZ(self->query);
@ -820,7 +818,7 @@ Query_close(recoll_QueryObject *self)
static void static void
Query_dealloc(recoll_QueryObject *self) Query_dealloc(recoll_QueryObject *self)
{ {
LOGDEB(("Query_dealloc\n")); LOGDEB("Query_dealloc\n" );
PyObject *ret = Query_close(self); PyObject *ret = Query_close(self);
Py_DECREF(ret); Py_DECREF(ret);
Py_TYPE(self)->tp_free((PyObject*)self); Py_TYPE(self)->tp_free((PyObject*)self);
@ -829,7 +827,7 @@ Query_dealloc(recoll_QueryObject *self)
static PyObject * static PyObject *
Query_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) Query_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{ {
LOGDEB(("Query_new\n")); LOGDEB("Query_new\n" );
recoll_QueryObject *self; recoll_QueryObject *self;
self = (recoll_QueryObject *)type->tp_alloc(type, 0); self = (recoll_QueryObject *)type->tp_alloc(type, 0);
@ -851,7 +849,7 @@ Query_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
static int static int
Query_init(recoll_QueryObject *self, PyObject *, PyObject *) Query_init(recoll_QueryObject *self, PyObject *, PyObject *)
{ {
LOGDEB(("Query_init\n")); LOGDEB("Query_init\n" );
if (self->query) if (self->query)
the_queries.erase(self->query); the_queries.erase(self->query);
@ -879,7 +877,7 @@ PyDoc_STRVAR(doc_Query_sortby,
static PyObject * static PyObject *
Query_sortby(recoll_QueryObject* self, PyObject *args, PyObject *kwargs) Query_sortby(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
{ {
LOGDEB0(("Query_sortby\n")); LOGDEB0("Query_sortby\n" );
static const char *kwlist[] = {"field", "ascending", NULL}; static const char *kwlist[] = {"field", "ascending", NULL};
char *sfield = 0; char *sfield = 0;
PyObject *ascobj = 0; PyObject *ascobj = 0;
@ -913,7 +911,7 @@ PyDoc_STRVAR(doc_Query_execute,
static PyObject * static PyObject *
Query_execute(recoll_QueryObject* self, PyObject *args, PyObject *kwargs) Query_execute(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
{ {
LOGDEB0(("Query_execute\n")); LOGDEB0("Query_execute\n" );
static const char *kwlist[] = {"query_string", "stemming", "stemlang", NULL}; static const char *kwlist[] = {"query_string", "stemming", "stemlang", NULL};
char *sutf8 = 0; // needs freeing char *sutf8 = 0; // needs freeing
char *sstemlang = 0; char *sstemlang = 0;
@ -936,8 +934,7 @@ Query_execute(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
PyMem_Free(sstemlang); PyMem_Free(sstemlang);
} }
LOGDEB0(("Query_execute: [%s] dostem %d stemlang [%s]\n", utf8.c_str(), LOGDEB0("Query_execute: [" << (utf8) << "] dostem " << (dostem) << " stemlang [" << (stemlang) << "]\n" );
dostem, stemlang.c_str()));
if (self->query == 0 || if (self->query == 0 ||
the_queries.find(self->query) == the_queries.end()) { the_queries.find(self->query) == the_queries.end()) {
@ -974,7 +971,7 @@ PyDoc_STRVAR(doc_Query_executesd,
static PyObject * static PyObject *
Query_executesd(recoll_QueryObject* self, PyObject *args, PyObject *kwargs) Query_executesd(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
{ {
LOGDEB0(("Query_executeSD\n")); LOGDEB0("Query_executeSD\n" );
static const char *kwlist[] = {"searchdata", NULL}; static const char *kwlist[] = {"searchdata", NULL};
recoll_SearchDataObject *pysd = 0; recoll_SearchDataObject *pysd = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:Query_execute", if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:Query_execute",
@ -1016,7 +1013,7 @@ PyDoc_STRVAR(doc_Query_fetchone,
static PyObject * static PyObject *
Query_fetchone(PyObject *_self) Query_fetchone(PyObject *_self)
{ {
LOGDEB0(("Query_fetchone/next\n")); LOGDEB0("Query_fetchone/next\n" );
recoll_QueryObject* self = (recoll_QueryObject*)_self; recoll_QueryObject* self = (recoll_QueryObject*)_self;
if (self->query == 0 || if (self->query == 0 ||
@ -1057,7 +1054,7 @@ PyDoc_STRVAR(doc_Query_fetchmany,
static PyObject * static PyObject *
Query_fetchmany(recoll_QueryObject* self, PyObject *args, PyObject *kwargs) Query_fetchmany(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
{ {
LOGDEB0(("Query_fetchmany\n")); LOGDEB0("Query_fetchmany\n" );
static const char *kwlist[] = {"size", NULL}; static const char *kwlist[] = {"size", NULL};
int size = 0; int size = 0;
@ -1107,7 +1104,7 @@ PyDoc_STRVAR(doc_Query_scroll,
static PyObject * static PyObject *
Query_scroll(recoll_QueryObject* self, PyObject *args, PyObject *kwargs) Query_scroll(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
{ {
LOGDEB0(("Query_scroll\n")); LOGDEB0("Query_scroll\n" );
static const char *kwlist[] = {"position", "mode", NULL}; static const char *kwlist[] = {"position", "mode", NULL};
int pos = 0; int pos = 0;
char *smode = 0; char *smode = 0;
@ -1194,7 +1191,7 @@ public:
static PyObject * static PyObject *
Query_highlight(recoll_QueryObject* self, PyObject *args, PyObject *kwargs) Query_highlight(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
{ {
LOGDEB0(("Query_highlight\n")); LOGDEB0("Query_highlight\n" );
static const char *kwlist[] = {"text", "ishtml", "eolbr", "methods", NULL}; static const char *kwlist[] = {"text", "ishtml", "eolbr", "methods", NULL};
char *sutf8 = 0; // needs freeing char *sutf8 = 0; // needs freeing
int ishtml = 0; int ishtml = 0;
@ -1216,7 +1213,7 @@ Query_highlight(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
ishtml = 1; ishtml = 1;
if (eolbrobj && !PyObject_IsTrue(eolbrobj)) if (eolbrobj && !PyObject_IsTrue(eolbrobj))
eolbr = 0; eolbr = 0;
LOGDEB0(("Query_highlight: ishtml %d\n", ishtml)); LOGDEB0("Query_highlight: ishtml " << (ishtml) << "\n" );
if (self->query == 0 || if (self->query == 0 ||
the_queries.find(self->query) == the_queries.end()) { the_queries.find(self->query) == the_queries.end()) {
@ -1254,7 +1251,7 @@ PyDoc_STRVAR(doc_Query_makedocabstract,
static PyObject * static PyObject *
Query_makedocabstract(recoll_QueryObject* self, PyObject *args,PyObject *kwargs) Query_makedocabstract(recoll_QueryObject* self, PyObject *args,PyObject *kwargs)
{ {
LOGDEB0(("Query_makeDocAbstract\n")); LOGDEB0("Query_makeDocAbstract\n" );
static const char *kwlist[] = {"doc", "methods", NULL}; static const char *kwlist[] = {"doc", "methods", NULL};
recoll_DocObject *pydoc = 0; recoll_DocObject *pydoc = 0;
PyObject *hlmethods = 0; PyObject *hlmethods = 0;
@ -1266,12 +1263,12 @@ Query_makedocabstract(recoll_QueryObject* self, PyObject *args,PyObject *kwargs)
} }
if (pydoc->doc == 0 || the_docs.find(pydoc->doc) == the_docs.end()) { if (pydoc->doc == 0 || the_docs.find(pydoc->doc) == the_docs.end()) {
LOGERR(("Query_makeDocAbstract: doc not found %p\n", pydoc->doc)); LOGERR("Query_makeDocAbstract: doc not found " << (pydoc->doc) << "\n" );
PyErr_SetString(PyExc_AttributeError, "doc"); PyErr_SetString(PyExc_AttributeError, "doc");
return 0; return 0;
} }
if (the_queries.find(self->query) == the_queries.end()) { if (the_queries.find(self->query) == the_queries.end()) {
LOGERR(("Query_makeDocAbstract: query not found %p\n", self->query)); LOGERR("Query_makeDocAbstract: query not found " << (self->query) << "\n" );
PyErr_SetString(PyExc_AttributeError, "query"); PyErr_SetString(PyExc_AttributeError, "query");
return 0; return 0;
} }
@ -1324,7 +1321,7 @@ PyDoc_STRVAR(doc_Query_getxquery,
static PyObject * static PyObject *
Query_getxquery(recoll_QueryObject* self, PyObject *, PyObject *) Query_getxquery(recoll_QueryObject* self, PyObject *, PyObject *)
{ {
LOGDEB0(("Query_getxquery self->query %p\n", self->query)); LOGDEB0("Query_getxquery self->query " << (self->query) << "\n" );
if (self->query == 0 || if (self->query == 0 ||
the_queries.find(self->query) == the_queries.end()) { the_queries.find(self->query) == the_queries.end()) {
@ -1352,7 +1349,7 @@ PyDoc_STRVAR(doc_Query_getgroups,
static PyObject * static PyObject *
Query_getgroups(recoll_QueryObject* self, PyObject *, PyObject *) Query_getgroups(recoll_QueryObject* self, PyObject *, PyObject *)
{ {
LOGDEB0(("Query_getgroups\n")); LOGDEB0("Query_getgroups\n" );
if (self->query == 0 || if (self->query == 0 ||
the_queries.find(self->query) == the_queries.end()) { the_queries.find(self->query) == the_queries.end()) {
@ -1497,7 +1494,7 @@ typedef struct recoll_DbObject {
static PyObject * static PyObject *
Db_close(recoll_DbObject *self) Db_close(recoll_DbObject *self)
{ {
LOGDEB(("Db_close. self %p\n", self)); LOGDEB("Db_close. self " << (self) << "\n" );
if (self->db) { if (self->db) {
the_dbs.erase(self->db); the_dbs.erase(self->db);
delete self->db; delete self->db;
@ -1509,7 +1506,7 @@ Db_close(recoll_DbObject *self)
static void static void
Db_dealloc(recoll_DbObject *self) Db_dealloc(recoll_DbObject *self)
{ {
LOGDEB(("Db_dealloc\n")); LOGDEB("Db_dealloc\n" );
PyObject *ret = Db_close(self); PyObject *ret = Db_close(self);
Py_DECREF(ret); Py_DECREF(ret);
Py_TYPE(self)->tp_free((PyObject*)self); Py_TYPE(self)->tp_free((PyObject*)self);
@ -1518,7 +1515,7 @@ Db_dealloc(recoll_DbObject *self)
static PyObject * static PyObject *
Db_new(PyTypeObject *type, PyObject *args, PyObject *kwds) Db_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{ {
LOGDEB2(("Db_new\n")); LOGDEB2("Db_new\n" );
recoll_DbObject *self; recoll_DbObject *self;
self = (recoll_DbObject *)type->tp_alloc(type, 0); self = (recoll_DbObject *)type->tp_alloc(type, 0);
@ -1550,7 +1547,7 @@ Db_init(recoll_DbObject *self, PyObject *args, PyObject *kwargs)
} else { } else {
rclconfig = recollinit(0, 0, reason, 0); rclconfig = recollinit(0, 0, reason, 0);
} }
LOGDEB(("Db_init\n")); LOGDEB("Db_init\n" );
if (rclconfig == 0) { if (rclconfig == 0) {
PyErr_SetString(PyExc_EnvironmentError, reason.c_str()); PyErr_SetString(PyExc_EnvironmentError, reason.c_str());
@ -1566,7 +1563,7 @@ Db_init(recoll_DbObject *self, PyObject *args, PyObject *kwargs)
delete self->db; delete self->db;
self->db = new Rcl::Db(rclconfig); self->db = new Rcl::Db(rclconfig);
if (!self->db->open(writable ? Rcl::Db::DbUpd : Rcl::Db::DbRO)) { if (!self->db->open(writable ? Rcl::Db::DbUpd : Rcl::Db::DbRO)) {
LOGERR(("Db_init: db open error\n")); LOGERR("Db_init: db open error\n" );
PyErr_SetString(PyExc_EnvironmentError, "Can't open index"); PyErr_SetString(PyExc_EnvironmentError, "Can't open index");
return -1; return -1;
} }
@ -1609,9 +1606,9 @@ Db_init(recoll_DbObject *self, PyObject *args, PyObject *kwargs)
static PyObject * static PyObject *
Db_query(recoll_DbObject* self) Db_query(recoll_DbObject* self)
{ {
LOGDEB(("Db_query\n")); LOGDEB("Db_query\n" );
if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) { if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) {
LOGERR(("Db_query: db not found %p\n", self->db)); LOGERR("Db_query: db not found " << (self->db) << "\n" );
PyErr_SetString(PyExc_AttributeError, "db"); PyErr_SetString(PyExc_AttributeError, "db");
return 0; return 0;
} }
@ -1630,18 +1627,18 @@ Db_query(recoll_DbObject* self)
static PyObject * static PyObject *
Db_setAbstractParams(recoll_DbObject *self, PyObject *args, PyObject *kwargs) Db_setAbstractParams(recoll_DbObject *self, PyObject *args, PyObject *kwargs)
{ {
LOGDEB0(("Db_setAbstractParams\n")); LOGDEB0("Db_setAbstractParams\n" );
static const char *kwlist[] = {"maxchars", "contextwords", NULL}; static const char *kwlist[] = {"maxchars", "contextwords", NULL};
int ctxwords = -1, maxchars = -1; int ctxwords = -1, maxchars = -1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii", (char**)kwlist, if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii", (char**)kwlist,
&maxchars, &ctxwords)) &maxchars, &ctxwords))
return 0; return 0;
if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) { if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) {
LOGERR(("Db_query: db not found %p\n", self->db)); LOGERR("Db_query: db not found " << (self->db) << "\n" );
PyErr_SetString(PyExc_AttributeError, "db id not found"); PyErr_SetString(PyExc_AttributeError, "db id not found");
return 0; return 0;
} }
LOGDEB0(("Db_setAbstractParams: mxchrs %d, ctxwrds %d\n", maxchars, ctxwords)); LOGDEB0("Db_setAbstractParams: mxchrs " << (maxchars) << ", ctxwrds " << (ctxwords) << "\n" );
self->db->setAbstractParams(-1, maxchars, ctxwords); self->db->setAbstractParams(-1, maxchars, ctxwords);
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@ -1649,7 +1646,7 @@ Db_setAbstractParams(recoll_DbObject *self, PyObject *args, PyObject *kwargs)
static PyObject * static PyObject *
Db_makeDocAbstract(recoll_DbObject* self, PyObject *args) Db_makeDocAbstract(recoll_DbObject* self, PyObject *args)
{ {
LOGDEB0(("Db_makeDocAbstract\n")); LOGDEB0("Db_makeDocAbstract\n" );
recoll_DocObject *pydoc = 0; recoll_DocObject *pydoc = 0;
recoll_QueryObject *pyquery = 0; recoll_QueryObject *pyquery = 0;
if (!PyArg_ParseTuple(args, "O!O!:Db_makeDocAbstract", if (!PyArg_ParseTuple(args, "O!O!:Db_makeDocAbstract",
@ -1658,18 +1655,18 @@ Db_makeDocAbstract(recoll_DbObject* self, PyObject *args)
return 0; return 0;
} }
if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) { if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) {
LOGERR(("Db_makeDocAbstract: db not found %p\n", self->db)); LOGERR("Db_makeDocAbstract: db not found " << (self->db) << "\n" );
PyErr_SetString(PyExc_AttributeError, "db"); PyErr_SetString(PyExc_AttributeError, "db");
return 0; return 0;
} }
if (pydoc->doc == 0 || the_docs.find(pydoc->doc) == the_docs.end()) { if (pydoc->doc == 0 || the_docs.find(pydoc->doc) == the_docs.end()) {
LOGERR(("Db_makeDocAbstract: doc not found %p\n", pydoc->doc)); LOGERR("Db_makeDocAbstract: doc not found " << (pydoc->doc) << "\n" );
PyErr_SetString(PyExc_AttributeError, "doc"); PyErr_SetString(PyExc_AttributeError, "doc");
return 0; return 0;
} }
if (pyquery->query == 0 || if (pyquery->query == 0 ||
the_queries.find(pyquery->query) == the_queries.end()) { the_queries.find(pyquery->query) == the_queries.end()) {
LOGERR(("Db_makeDocAbstract: query not found %p\n", pyquery->query)); LOGERR("Db_makeDocAbstract: query not found " << (pyquery->query) << "\n" );
PyErr_SetString(PyExc_AttributeError, "query"); PyErr_SetString(PyExc_AttributeError, "query");
return 0; return 0;
} }
@ -1694,7 +1691,7 @@ PyDoc_STRVAR(doc_Db_termMatch,
static PyObject * static PyObject *
Db_termMatch(recoll_DbObject* self, PyObject *args, PyObject *kwargs) Db_termMatch(recoll_DbObject* self, PyObject *args, PyObject *kwargs)
{ {
LOGDEB0(("Db_termMatch\n")); LOGDEB0("Db_termMatch\n" );
static const char *kwlist[] = {"type", "expr", "field", "maxlen", static const char *kwlist[] = {"type", "expr", "field", "maxlen",
"casesens", "diacsens", "lang", NULL}; "casesens", "diacsens", "lang", NULL};
char *tp = 0; char *tp = 0;
@ -1717,7 +1714,7 @@ Db_termMatch(recoll_DbObject* self, PyObject *args, PyObject *kwargs)
return 0; return 0;
if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) { if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) {
LOGERR(("Db_termMatch: db not found %p\n", self->db)); LOGERR("Db_termMatch: db not found " << (self->db) << "\n" );
PyErr_SetString(PyExc_AttributeError, "db"); PyErr_SetString(PyExc_AttributeError, "db");
goto out; goto out;
} }
@ -1742,7 +1739,7 @@ Db_termMatch(recoll_DbObject* self, PyObject *args, PyObject *kwargs)
if (!self->db->termMatch(typ_sens, lang ? lang : "english", if (!self->db->termMatch(typ_sens, lang ? lang : "english",
expr, result, maxlen, field ? field : "")) { expr, result, maxlen, field ? field : "")) {
LOGERR(("Db_termMatch: db termMatch error\n")); LOGERR("Db_termMatch: db termMatch error\n" );
PyErr_SetString(PyExc_AttributeError, "rcldb termMatch error"); PyErr_SetString(PyExc_AttributeError, "rcldb termMatch error");
goto out; goto out;
} }
@ -1763,7 +1760,7 @@ out:
static PyObject * static PyObject *
Db_needUpdate(recoll_DbObject* self, PyObject *args, PyObject *kwds) Db_needUpdate(recoll_DbObject* self, PyObject *args, PyObject *kwds)
{ {
LOGDEB0(("Db_needUpdate\n")); LOGDEB0("Db_needUpdate\n" );
char *udi = 0; // needs freeing char *udi = 0; // needs freeing
char *sig = 0; // needs freeing char *sig = 0; // needs freeing
if (!PyArg_ParseTuple(args, "eses:Db_needUpdate", if (!PyArg_ParseTuple(args, "eses:Db_needUpdate",
@ -1771,7 +1768,7 @@ Db_needUpdate(recoll_DbObject* self, PyObject *args, PyObject *kwds)
return 0; return 0;
} }
if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) { if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) {
LOGERR(("Db_needUpdate: db not found %p\n", self->db)); LOGERR("Db_needUpdate: db not found " << (self->db) << "\n" );
PyErr_SetString(PyExc_AttributeError, "db"); PyErr_SetString(PyExc_AttributeError, "db");
PyMem_Free(udi); PyMem_Free(udi);
PyMem_Free(sig); PyMem_Free(sig);
@ -1786,13 +1783,13 @@ Db_needUpdate(recoll_DbObject* self, PyObject *args, PyObject *kwds)
static PyObject * static PyObject *
Db_delete(recoll_DbObject* self, PyObject *args, PyObject *kwds) Db_delete(recoll_DbObject* self, PyObject *args, PyObject *kwds)
{ {
LOGDEB0(("Db_delete\n")); LOGDEB0("Db_delete\n" );
char *udi = 0; // needs freeing char *udi = 0; // needs freeing
if (!PyArg_ParseTuple(args, "es:Db_delete", "utf-8", &udi)) { if (!PyArg_ParseTuple(args, "es:Db_delete", "utf-8", &udi)) {
return 0; return 0;
} }
if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) { if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) {
LOGERR(("Db_delete: db not found %p\n", self->db)); LOGERR("Db_delete: db not found " << (self->db) << "\n" );
PyErr_SetString(PyExc_AttributeError, "db"); PyErr_SetString(PyExc_AttributeError, "db");
PyMem_Free(udi); PyMem_Free(udi);
return 0; return 0;
@ -1805,9 +1802,9 @@ Db_delete(recoll_DbObject* self, PyObject *args, PyObject *kwds)
static PyObject * static PyObject *
Db_purge(recoll_DbObject* self) Db_purge(recoll_DbObject* self)
{ {
LOGDEB0(("Db_purge\n")); LOGDEB0("Db_purge\n" );
if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) { if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) {
LOGERR(("Db_purge: db not found %p\n", self->db)); LOGERR("Db_purge: db not found " << (self->db) << "\n" );
PyErr_SetString(PyExc_AttributeError, "db"); PyErr_SetString(PyExc_AttributeError, "db");
return 0; return 0;
} }
@ -1818,7 +1815,7 @@ Db_purge(recoll_DbObject* self)
static PyObject * static PyObject *
Db_addOrUpdate(recoll_DbObject* self, PyObject *args, PyObject *) Db_addOrUpdate(recoll_DbObject* self, PyObject *args, PyObject *)
{ {
LOGDEB0(("Db_addOrUpdate\n")); LOGDEB0("Db_addOrUpdate\n" );
char *sudi = 0; // needs freeing char *sudi = 0; // needs freeing
char *sparent_udi = 0; // needs freeing char *sparent_udi = 0; // needs freeing
recoll_DocObject *pydoc; recoll_DocObject *pydoc;
@ -1834,17 +1831,17 @@ Db_addOrUpdate(recoll_DbObject* self, PyObject *args, PyObject *)
PyMem_Free(sparent_udi); PyMem_Free(sparent_udi);
if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) { if (self->db == 0 || the_dbs.find(self->db) == the_dbs.end()) {
LOGERR(("Db_addOrUpdate: db not found %p\n", self->db)); LOGERR("Db_addOrUpdate: db not found " << (self->db) << "\n" );
PyErr_SetString(PyExc_AttributeError, "db"); PyErr_SetString(PyExc_AttributeError, "db");
return 0; return 0;
} }
if (pydoc->doc == 0 || the_docs.find(pydoc->doc) == the_docs.end()) { if (pydoc->doc == 0 || the_docs.find(pydoc->doc) == the_docs.end()) {
LOGERR(("Db_addOrUpdate: doc not found %p\n", pydoc->doc)); LOGERR("Db_addOrUpdate: doc not found " << (pydoc->doc) << "\n" );
PyErr_SetString(PyExc_AttributeError, "doc"); PyErr_SetString(PyExc_AttributeError, "doc");
return 0; return 0;
} }
if (!self->db->addOrUpdate(udi, parent_udi, *pydoc->doc)) { if (!self->db->addOrUpdate(udi, parent_udi, *pydoc->doc)) {
LOGERR(("Db_addOrUpdate: rcldb error\n")); LOGERR("Db_addOrUpdate: rcldb error\n" );
PyErr_SetString(PyExc_AttributeError, "rcldb error"); PyErr_SetString(PyExc_AttributeError, "rcldb error");
return 0; return 0;
} }
@ -1959,7 +1956,7 @@ static PyTypeObject recoll_DbType = {
static PyObject * static PyObject *
recoll_connect(PyObject *self, PyObject *args, PyObject *kwargs) recoll_connect(PyObject *self, PyObject *args, PyObject *kwargs)
{ {
LOGDEB2(("recoll_connect\n")); LOGDEB2("recoll_connect\n" );
recoll_DbObject *db = (recoll_DbObject *) recoll_DbObject *db = (recoll_DbObject *)
PyObject_Call((PyObject *)&recoll_DbType, args, kwargs); PyObject_Call((PyObject *)&recoll_DbType, args, kwargs);
return (PyObject *)db; return (PyObject *)db;
@ -2094,3 +2091,4 @@ initrecoll(void)
return module; return module;
#endif #endif
} }

View file

@ -18,6 +18,7 @@ if "CYGWIN" in os.environ:
else: else:
libraries = ['recoll'] libraries = ['recoll']
extra_compile_args = ['-std=c++11']
if 'libdir' in os.environ and os.environ['libdir'] != "": if 'libdir' in os.environ and os.environ['libdir'] != "":
runtime_library_dirs = [os.path.join(os.environ['libdir'], 'recoll')] runtime_library_dirs = [os.path.join(os.environ['libdir'], 'recoll')]
@ -39,6 +40,7 @@ module1 = Extension('recoll',
os.path.join(top, 'query'), os.path.join(top, 'query'),
os.path.join(top, 'unac') os.path.join(top, 'unac')
], ],
extra_compile_args = extra_compile_args,
libraries = libraries, libraries = libraries,
library_dirs = library_dirs, library_dirs = library_dirs,
runtime_library_dirs = runtime_library_dirs, runtime_library_dirs = runtime_library_dirs,
@ -57,6 +59,7 @@ module2 = Extension('rclextract',
os.path.join(top, 'internfile'), os.path.join(top, 'internfile'),
os.path.join(top, 'rcldb'), os.path.join(top, 'rcldb'),
], ],
extra_compile_args = extra_compile_args,
libraries = libraries, libraries = libraries,
library_dirs = library_dirs, library_dirs = library_dirs,
runtime_library_dirs = runtime_library_dirs, runtime_library_dirs = runtime_library_dirs,

View file

@ -38,7 +38,7 @@ using namespace std;
#include "recoll.h" #include "recoll.h"
#include "rclconfig.h" #include "rclconfig.h"
#include "debuglog.h" #include "log.h"
#include "searchdata.h" #include "searchdata.h"
#include "guiutils.h" #include "guiutils.h"
#include "rclhelp.h" #include "rclhelp.h"
@ -443,7 +443,7 @@ void AdvSearch::runSearch()
entries.push_back(subtreeCMB->currentText()); entries.push_back(subtreeCMB->currentText());
entries.sort(); entries.sort();
entries.unique(); entries.unique();
LOGDEB(("Subtree list now has %d entries\n", entries.size())); LOGDEB("Subtree list now has " << (entries.size()) << " entries\n" );
subtreeCMB->clear(); subtreeCMB->clear();
for (list<QString>::iterator it = entries.begin(); for (list<QString>::iterator it = entries.begin();
it != entries.end(); it++) { it != entries.end(); it++) {
@ -479,7 +479,7 @@ void AdvSearch::fromSearch(STD_SHARED_PTR<SearchData> sdata)
for (unsigned int i = 0; i < sdata->m_query.size(); i++) { for (unsigned int i = 0; i < sdata->m_query.size(); i++) {
// Set fields from clause // Set fields from clause
if (sdata->m_query[i]->getTp() == SCLT_SUB) { if (sdata->m_query[i]->getTp() == SCLT_SUB) {
LOGERR(("AdvSearch::fromSearch: SUB clause found !\n")); LOGERR("AdvSearch::fromSearch: SUB clause found !\n" );
continue; continue;
} }
if (sdata->m_query[i]->getTp() == SCLT_PATH) { if (sdata->m_query[i]->getTp() == SCLT_PATH) {
@ -576,3 +576,4 @@ void AdvSearch::slotHistoryPrev()
fromSearch(sd); fromSearch(sd);
} }

View file

@ -19,7 +19,7 @@
#include "advshist.h" #include "advshist.h"
#include "guiutils.h" #include "guiutils.h"
#include "debuglog.h" #include "log.h"
#include "xmltosd.h" #include "xmltosd.h"
using namespace std; using namespace std;
@ -94,3 +94,4 @@ void AdvSearchHist::clear()
{ {
g_dynconf->eraseAll(advSearchHistSk); g_dynconf->eraseAll(advSearchHistSk);
} }

View file

@ -40,7 +40,7 @@
#include "confgui.h" #include "confgui.h"
#include "smallut.h" #include "smallut.h"
#include "debuglog.h" #include "log.h"
#include "rcldb.h" #include "rcldb.h"
#include "guiutils.h" #include "guiutils.h"
@ -376,7 +376,7 @@ void ConfParamSLW::showInputDialog()
void ConfParamSLW::listToConf() void ConfParamSLW::listToConf()
{ {
list<string> ls; list<string> ls;
LOGDEB2(("ConfParamSLW::listToConf. m_fsencoding %d\n", int(m_fsencoding))); LOGDEB2("ConfParamSLW::listToConf. m_fsencoding " << (int(m_fsencoding)) << "\n" );
for (int i = 0; i < m_lb->count(); i++) { for (int i = 0; i < m_lb->count(); i++) {
// General parameters are encoded as utf-8. File names as // General parameters are encoded as utf-8. File names as
// local8bit There is no hope for 8bit file names anyway // local8bit There is no hope for 8bit file names anyway
@ -423,7 +423,7 @@ void ConfParamSLW::deleteSelected()
} }
for (vector<int>::reverse_iterator it = idxes.rbegin(); for (vector<int>::reverse_iterator it = idxes.rbegin();
it != idxes.rend(); it++) { it != idxes.rend(); it++) {
LOGDEB0(("deleteSelected: %d was selected\n", *it)); LOGDEB0("deleteSelected: " << (*it) << " was selected\n" );
QListWidgetItem *item = m_lb->takeItem(*it); QListWidgetItem *item = m_lb->takeItem(*it);
emit entryDeleted(item->text()); emit entryDeleted(item->text());
delete item; delete item;
@ -476,3 +476,4 @@ void ConfParamCSLW::showInputDialog()
} }
} // Namespace confgui } // Namespace confgui

View file

@ -35,7 +35,7 @@ using std::list;
#include "recoll.h" #include "recoll.h"
#include "confguiindex.h" #include "confguiindex.h"
#include "smallut.h" #include "smallut.h"
#include "debuglog.h" #include "log.h"
#include "rcldb.h" #include "rcldb.h"
#include "conflinkrcl.h" #include "conflinkrcl.h"
#include "execmd.h" #include "execmd.h"
@ -68,9 +68,9 @@ ConfIndexW::ConfIndexW(QWidget *parent, RclConfig *config)
void ConfIndexW::acceptChanges() void ConfIndexW::acceptChanges()
{ {
LOGDEB(("ConfIndexW::acceptChanges()\n")); LOGDEB("ConfIndexW::acceptChanges()\n" );
if (!m_conf) { if (!m_conf) {
LOGERR(("ConfIndexW::acceptChanges: no config\n")); LOGERR("ConfIndexW::acceptChanges: no config\n" );
return; return;
} }
// Let the changes to disk // Let the changes to disk
@ -88,7 +88,7 @@ void ConfIndexW::acceptChanges()
void ConfIndexW::rejectChanges() void ConfIndexW::rejectChanges()
{ {
LOGDEB(("ConfIndexW::rejectChanges()\n")); LOGDEB("ConfIndexW::rejectChanges()\n" );
// Discard local changes. // Discard local changes.
delete m_conf; delete m_conf;
m_conf = 0; m_conf = 0;
@ -477,7 +477,7 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, ConfNull *config,
string cmd = "iconv"; string cmd = "iconv";
int status = ex.doexec(cmd, args, 0, &icout); int status = ex.doexec(cmd, args, 0, &icout);
if (status) { if (status) {
LOGERR(("Can't get list of charsets from 'iconv -l'")); LOGERR("Can't get list of charsets from 'iconv -l'" );
} }
icout = neutchars(icout, ","); icout = neutchars(icout, ",");
list<string> ccsets; list<string> ccsets;
@ -579,7 +579,7 @@ void ConfSubPanelW::reloadAll()
void ConfSubPanelW::subDirChanged(QListWidgetItem *current, QListWidgetItem *) void ConfSubPanelW::subDirChanged(QListWidgetItem *current, QListWidgetItem *)
{ {
LOGDEB(("ConfSubPanelW::subDirChanged\n")); LOGDEB("ConfSubPanelW::subDirChanged\n" );
if (current == 0 || current->text() == "") { if (current == 0 || current->text() == "") {
m_sk = ""; m_sk = "";
@ -588,13 +588,13 @@ void ConfSubPanelW::subDirChanged(QListWidgetItem *current, QListWidgetItem *)
m_sk = (const char *) current->text().toUtf8(); m_sk = (const char *) current->text().toUtf8();
m_groupbox->setTitle(current->text()); m_groupbox->setTitle(current->text());
} }
LOGDEB(("ConfSubPanelW::subDirChanged: now [%s]\n", m_sk.c_str())); LOGDEB("ConfSubPanelW::subDirChanged: now [" << (m_sk) << "]\n" );
reloadAll(); reloadAll();
} }
void ConfSubPanelW::subDirDeleted(QString sbd) void ConfSubPanelW::subDirDeleted(QString sbd)
{ {
LOGDEB(("ConfSubPanelW::subDirDeleted(%s)\n", (const char *)sbd.toUtf8())); LOGDEB("ConfSubPanelW::subDirDeleted(" << ((const char *)sbd.toUtf8()) << ")\n" );
if (sbd == "") { if (sbd == "") {
// Can't do this, have to reinsert it // Can't do this, have to reinsert it
QTimer::singleShot(0, this, SLOT(restoreEmpty())); QTimer::singleShot(0, this, SLOT(restoreEmpty()));
@ -606,8 +606,9 @@ void ConfSubPanelW::subDirDeleted(QString sbd)
void ConfSubPanelW::restoreEmpty() void ConfSubPanelW::restoreEmpty()
{ {
LOGDEB(("ConfSubPanelW::restoreEmpty()\n")); LOGDEB("ConfSubPanelW::restoreEmpty()\n" );
m_subdirs->getListBox()->insertItem(0, ""); m_subdirs->getListBox()->insertItem(0, "");
} }
} // Namespace confgui } // Namespace confgui

View file

@ -25,7 +25,7 @@
*/ */
#include "confgui.h" #include "confgui.h"
#include "conftree.h" #include "conftree.h"
#include "debuglog.h" #include "log.h"
namespace confgui { namespace confgui {
@ -42,10 +42,10 @@ public:
{ {
if (!m_conf) if (!m_conf)
return false; return false;
LOGDEB1(("Setting [%s] value to [%s]\n", m_nm.c_str(), val.c_str())); LOGDEB1("Setting [" << (m_nm) << "] value to [" << (val) << "]\n" );
bool ret = m_conf->set(m_nm, val, m_sk?*m_sk:""); bool ret = m_conf->set(m_nm, val, m_sk?*m_sk:"");
if (!ret) if (!ret)
LOGERR(("Value set failed\n")); LOGERR("Value set failed\n" );
return ret; return ret;
} }
virtual bool get(string& val) virtual bool get(string& val)
@ -53,9 +53,7 @@ public:
if (!m_conf) if (!m_conf)
return false; return false;
bool ret = m_conf->get(m_nm, val, m_sk?*m_sk:""); bool ret = m_conf->get(m_nm, val, m_sk?*m_sk:"");
LOGDEB1(("ConfLinkRcl::get: [%s] sk [%s] -> [%s]\n", LOGDEB1("ConfLinkRcl::get: [" << (m_nm) << "] sk [" << (m_sk?m_sk:"") << "] -> [" << (ret ? val : "no value") << "]\n" );
m_nm.c_str(), m_sk?m_sk->c_str():"",
ret ? val.c_str() : "no value"));
return ret; return ret;
} }
private: private:
@ -67,3 +65,4 @@ private:
} // Namespace confgui } // Namespace confgui
#endif /* _CONFLINKRCL_H_INCLUDED_ */ #endif /* _CONFLINKRCL_H_INCLUDED_ */

View file

@ -39,7 +39,7 @@ using namespace std;
#include "pathut.h" #include "pathut.h"
#include "confguiindex.h" #include "confguiindex.h"
#include "debuglog.h" #include "log.h"
#include "rclconfig.h" #include "rclconfig.h"
#include "execmd.h" #include "execmd.h"
#include "conflinkrcl.h" #include "conflinkrcl.h"
@ -89,9 +89,6 @@ int main(int argc, char **argv)
argc--; argv++; argc--; argv++;
} }
DebugLog::getdbl()->setloglevel(DEBDEB1);
DebugLog::setfilename("stderr");
string a_config = "tstconfdir"; string a_config = "tstconfdir";
config = new RclConfig(&a_config); config = new RclConfig(&a_config);
if (config == 0 || !config->ok()) { if (config == 0 || !config->ok()) {
@ -130,3 +127,4 @@ int main(int argc, char **argv)
// Let's go // Let's go
return app.exec(); return app.exec();
} }

View file

@ -34,7 +34,7 @@
#include "pathut.h" #include "pathut.h"
#include "smallut.h" #include "smallut.h"
#include "recoll.h" #include "recoll.h"
#include "debuglog.h" #include "log.h"
#include "readfile.h" #include "readfile.h"
#include "copyfile.h" #include "copyfile.h"
@ -158,7 +158,7 @@ FragButs::FragButs(QWidget* parent)
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll",
tr("%1 not found.").arg( tr("%1 not found.").arg(
QString::fromLocal8Bit(m_fn.c_str()))); QString::fromLocal8Bit(m_fn.c_str())));
LOGERR(("Fragbuts:: can't read [%s]\n", m_fn.c_str())); LOGERR("Fragbuts:: can't read [" << (m_fn) << "]\n" );
return; return;
} }
FragButsParser parser(this, m_buttons); FragButsParser parser(this, m_buttons);
@ -199,7 +199,7 @@ bool FragButs::isStale(time_t *reftime)
void FragButs::onButtonClicked(bool on) void FragButs::onButtonClicked(bool on)
{ {
LOGDEB(("FragButs::onButtonClicked: [%d]\n", int(on))); LOGDEB("FragButs::onButtonClicked: [" << (int(on)) << "]\n" );
emit fragmentsChanged(); emit fragmentsChanged();
} }
@ -208,8 +208,9 @@ void FragButs::getfrags(std::vector<std::string>& frags)
for (vector<ButFrag>::iterator it = m_buttons.begin(); for (vector<ButFrag>::iterator it = m_buttons.begin();
it != m_buttons.end(); it++) { it != m_buttons.end(); it++) {
if (it->button->isChecked() && !it->fragment.empty()) { if (it->button->isChecked() && !it->fragment.empty()) {
LOGDEB(("FragButs: fragment [%s]\n", it->fragment.c_str())); LOGDEB("FragButs: fragment [" << (it->fragment) << "]\n" );
frags.push_back(it->fragment); frags.push_back(it->fragment);
} }
} }
} }

View file

@ -20,7 +20,7 @@
#include <cstdio> #include <cstdio>
#include "recoll.h" #include "recoll.h"
#include "debuglog.h" #include "log.h"
#include "smallut.h" #include "smallut.h"
#include "guiutils.h" #include "guiutils.h"
#include "pathut.h" #include "pathut.h"
@ -73,7 +73,7 @@ static bool havereadsettings;
void rwSettings(bool writing) void rwSettings(bool writing)
{ {
LOGDEB1(("rwSettings: write %d\n", int(writing))); LOGDEB1("rwSettings: write " << (int(writing)) << "\n" );
if (writing && !havereadsettings) if (writing && !havereadsettings)
return; return;
QSettings settings("Recoll.org", "recoll"); QSettings settings("Recoll.org", "recoll");
@ -312,12 +312,11 @@ void rwSettings(bool writing)
continue; continue;
bool stripped; bool stripped;
if (!Rcl::Db::testDbDir(dbdir, &stripped)) { if (!Rcl::Db::testDbDir(dbdir, &stripped)) {
LOGERR(("Not a xapian index: [%s]\n", dbdir.c_str())); LOGERR("Not a xapian index: [" << (dbdir) << "]\n" );
continue; continue;
} }
if (stripped != o_index_stripchars) { if (stripped != o_index_stripchars) {
LOGERR(("Incompatible character stripping: [%s]\n", LOGERR("Incompatible character stripping: [" << (dbdir) << "]\n" );
dbdir.c_str()));
continue; continue;
} }
prefs.allExtraDbs.push_back(dbdir); prefs.allExtraDbs.push_back(dbdir);
@ -334,8 +333,7 @@ void rwSettings(bool writing)
bool stripped; bool stripped;
if (!Rcl::Db::testDbDir(*it, &stripped) || if (!Rcl::Db::testDbDir(*it, &stripped) ||
stripped != o_index_stripchars) { stripped != o_index_stripchars) {
LOGINFO(("Not a Xapian index or char stripping differs: [%s]\n", LOGINFO("Not a Xapian index or char stripping differs: [" << *it << "]\n" );
it->c_str()));
it = prefs.activeExtraDbs.erase(it); it = prefs.activeExtraDbs.erase(it);
} else { } else {
it++; it++;
@ -359,8 +357,7 @@ void rwSettings(bool writing)
bool strpd; bool strpd;
if (!Rcl::Db::testDbDir(dbdir, &strpd) || if (!Rcl::Db::testDbDir(dbdir, &strpd) ||
strpd != o_index_stripchars) { strpd != o_index_stripchars) {
LOGERR(("Not a Xapian dir or diff. char stripping: [%s]\n", LOGERR("Not a Xapian dir or diff. char stripping: [" << (dbdir) << "]\n" );
dbdir.c_str()));
continue; continue;
} }
prefs.activeExtraDbs.push_back(dbdir); prefs.activeExtraDbs.push_back(dbdir);
@ -414,3 +411,4 @@ string PrefsPack::stemlang()
} }
return stemLang; return stemLang;
} }

View file

@ -36,7 +36,7 @@
#include "recoll.h" #include "recoll.h"
#include "smallut.h" #include "smallut.h"
#include "rclinit.h" #include "rclinit.h"
#include "debuglog.h" #include "log.h"
#include "rclmain_w.h" #include "rclmain_w.h"
#include "ssearch_w.h" #include "ssearch_w.h"
#include "guiutils.h" #include "guiutils.h"
@ -98,7 +98,7 @@ void startManual(const string& helpindex)
bool maybeOpenDb(string &reason, bool force, bool *maindberror) bool maybeOpenDb(string &reason, bool force, bool *maindberror)
{ {
LOGDEB2(("maybeOpenDb: force %d\n", force)); LOGDEB2("maybeOpenDb: force " << (force) << "\n" );
if (!rcldb) { if (!rcldb) {
reason = "Internal error: db not created"; reason = "Internal error: db not created";
return false; return false;
@ -109,7 +109,7 @@ bool maybeOpenDb(string &reason, bool force, bool *maindberror)
rcldb->rmQueryDb(""); rcldb->rmQueryDb("");
for (list<string>::const_iterator it = prefs.activeExtraDbs.begin(); for (list<string>::const_iterator it = prefs.activeExtraDbs.begin();
it != prefs.activeExtraDbs.end(); it++) { it != prefs.activeExtraDbs.end(); it++) {
LOGDEB(("main: adding [%s]\n", it->c_str())); LOGDEB("main: adding [" << *it << "]\n" );
rcldb->addQueryDb(*it); rcldb->addQueryDb(*it);
} }
Rcl::Db::OpenError error; Rcl::Db::OpenError error;
@ -136,8 +136,7 @@ bool getStemLangs(vector<string>& vlangs)
string reason; string reason;
if (maybeOpenDb(reason)) { if (maybeOpenDb(reason)) {
vlangs = rcldb->getStemLangs(); vlangs = rcldb->getStemLangs();
LOGDEB0(("getStemLangs: from index: %s\n", LOGDEB0("getStemLangs: from index: " << (stringsToString(vlangs)) << "\n" );
stringsToString(vlangs).c_str()));
return true; return true;
} else { } else {
// Cant get the langs from the index. Maybe it just does not // Cant get the langs from the index. Maybe it just does not
@ -153,7 +152,7 @@ bool getStemLangs(vector<string>& vlangs)
static void recollCleanup() static void recollCleanup()
{ {
LOGDEB2(("recollCleanup: closing database\n")); LOGDEB2("recollCleanup: closing database\n" );
deleteZ(rcldb); deleteZ(rcldb);
deleteZ(theconfig); deleteZ(theconfig);
@ -163,13 +162,13 @@ static void recollCleanup()
deleteZ(aspell); deleteZ(aspell);
#endif #endif
LOGDEB2(("recollCleanup: done\n")); LOGDEB2("recollCleanup: done\n" );
} }
void applyStyleSheet(const QString& ssfname) void applyStyleSheet(const QString& ssfname)
{ {
const char *cfname = (const char *)ssfname.toLocal8Bit(); const char *cfname = (const char *)ssfname.toLocal8Bit();
LOGDEB0(("Applying style sheet: [%s]\n", cfname)); LOGDEB0("Applying style sheet: [" << (cfname) << "]\n" );
if (cfname && *cfname) { if (cfname && *cfname) {
string stylesheet; string stylesheet;
file_to_string(cfname, stylesheet); file_to_string(cfname, stylesheet);
@ -327,7 +326,7 @@ int main(int argc, char **argv)
aspell = new Aspell(theconfig); aspell = new Aspell(theconfig);
aspell->init(reason); aspell->init(reason);
if (!aspell || !aspell->ok()) { if (!aspell || !aspell->ok()) {
LOGDEB(("Aspell speller creation failed %s\n", reason.c_str())); LOGDEB("Aspell speller creation failed " << (reason) << "\n" );
aspell = 0; aspell = 0;
} }
#endif #endif
@ -396,7 +395,7 @@ int main(int argc, char **argv)
mainWindow-> mainWindow->
sSearch->setSearchString(QString::fromLocal8Bit(question.c_str())); sSearch->setSearchString(QString::fromLocal8Bit(question.c_str()));
} else if (!urltoview.empty()) { } else if (!urltoview.empty()) {
LOGDEB(("MAIN: got urltoview [%s]\n", urltoview.c_str())); LOGDEB("MAIN: got urltoview [" << (urltoview) << "]\n" );
mainWindow->setUrlToView(QString::fromLocal8Bit(urltoview.c_str())); mainWindow->setUrlToView(QString::fromLocal8Bit(urltoview.c_str()));
} }
return app.exec(); return app.exec();
@ -404,7 +403,7 @@ int main(int argc, char **argv)
QString myGetFileName(bool isdir, QString caption, bool filenosave) QString myGetFileName(bool isdir, QString caption, bool filenosave)
{ {
LOGDEB1(("myFileDialog: isdir %d\n", isdir)); LOGDEB1("myFileDialog: isdir " << (isdir) << "\n" );
QFileDialog dialog(0, caption); QFileDialog dialog(0, caption);
if (isdir) { if (isdir) {
@ -430,3 +429,4 @@ QString myGetFileName(bool isdir, QString caption, bool filenosave)
} }
return QString(); return QString();
} }

View file

@ -30,7 +30,7 @@ using namespace std;
#include "recoll.h" #include "recoll.h"
#include "multisave.h" #include "multisave.h"
#include "smallut.h" #include "smallut.h"
#include "debuglog.h" #include "log.h"
#include "pathut.h" #include "pathut.h"
#include "internfile.h" #include "internfile.h"
@ -52,7 +52,7 @@ void multiSave(QWidget *p, vector<Rcl::Doc>& docs)
return; return;
} }
string dir((const char *)dirl[0].toLocal8Bit()); string dir((const char *)dirl[0].toLocal8Bit());
LOGDEB2(("multiSave: got dir %s\n", dir.c_str())); LOGDEB2("multiSave: got dir " << (dir) << "\n" );
/* Save doc to files in target directory. Issues: /* Save doc to files in target directory. Issues:
- It is quite common to have docs in the array with the save - It is quite common to have docs in the array with the save
@ -90,13 +90,13 @@ void multiSave(QWidget *p, vector<Rcl::Doc>& docs)
string utf8fn; string utf8fn;
it->getmeta(Rcl::Doc::keyfn, &utf8fn); it->getmeta(Rcl::Doc::keyfn, &utf8fn);
string suffix = path_suffix(utf8fn); string suffix = path_suffix(utf8fn);
LOGDEB(("Multisave: [%s] suff [%s]\n", utf8fn.c_str(), suffix.c_str())); LOGDEB("Multisave: [" << (utf8fn) << "] suff [" << (suffix) << "]\n" );
if (suffix.empty() || suffix.size() > 10) { if (suffix.empty() || suffix.size() > 10) {
suffix = theconfig->getSuffixFromMimeType(it->mimetype); suffix = theconfig->getSuffixFromMimeType(it->mimetype);
LOGDEB(("Multisave: suff from config [%s]\n", suffix.c_str())); LOGDEB("Multisave: suff from config [" << (suffix) << "]\n" );
} }
string simple = path_basename(utf8fn, string(".") + suffix); string simple = path_basename(utf8fn, string(".") + suffix);
LOGDEB(("Multisave: simple [%s]\n", simple.c_str())); LOGDEB("Multisave: simple [" << (simple) << "]\n" );
if (simple.empty()) if (simple.empty())
simple = "rclsave"; simple = "rclsave";
if (simple.size() > maxlen) { if (simple.size() > maxlen) {
@ -141,3 +141,4 @@ void multiSave(QWidget *p, vector<Rcl::Doc>& docs)
} }
} }
} }

View file

@ -16,7 +16,7 @@
*/ */
#include <string> #include <string>
#include "debuglog.h" #include "log.h"
#include "preview_load.h" #include "preview_load.h"
#include "internfile.h" #include "internfile.h"
#include "rcldoc.h" #include "rcldoc.h"
@ -29,14 +29,10 @@ LoadThread::LoadThread(RclConfig *config, const Rcl::Doc& idc,
: QThread(parent), status(1), m_idoc(idc), m_previewHtml(pvhtm), : QThread(parent), status(1), m_idoc(idc), m_previewHtml(pvhtm),
m_config(*config) m_config(*config)
{ {
// Save log level while we're running in the calling thread.
m_loglevel = DebugLog::getdbl()->getlevel();
} }
void LoadThread::run() void LoadThread::run()
{ {
DebugLog::getdbl()->setloglevel(m_loglevel);
FileInterner interner(m_idoc, &m_config, FileInterner::FIF_forPreview); FileInterner interner(m_idoc, &m_config, FileInterner::FIF_forPreview);
FIMissingStore mst; FIMissingStore mst;
interner.setMissingStore(&mst); interner.setMissingStore(&mst);
@ -69,7 +65,8 @@ void LoadThread::run()
status = -1; status = -1;
} }
} catch (CancelExcept) { } catch (CancelExcept) {
LOGDEB(("LoadThread: cancelled\n")); LOGDEB("LoadThread: cancelled\n" );
status = -1; status = -1;
} }
} }

View file

@ -51,7 +51,6 @@ public:
private: private:
Rcl::Doc m_idoc; Rcl::Doc m_idoc;
int m_loglevel;
bool m_previewHtml; bool m_previewHtml;
RclConfig m_config; RclConfig m_config;
}; };

View file

@ -26,7 +26,7 @@
#include "preview_plaintorich.h" #include "preview_plaintorich.h"
#include "plaintorich.h" #include "plaintorich.h"
#include "debuglog.h" #include "log.h"
#include "guiutils.h" #include "guiutils.h"
#include "cancelcheck.h" #include "cancelcheck.h"
@ -71,9 +71,9 @@ string PlainToRichQtPreview::PlainToRichQtPreview::header()
string PlainToRichQtPreview::startMatch(unsigned int grpidx) string PlainToRichQtPreview::startMatch(unsigned int grpidx)
{ {
LOGDEB2(("startMatch, grpidx %u\n", grpidx)); LOGDEB2("startMatch, grpidx " << (grpidx) << "\n" );
grpidx = m_hdata->grpsugidx[grpidx]; grpidx = m_hdata->grpsugidx[grpidx];
LOGDEB2(("startMatch, ugrpidx %u\n", grpidx)); LOGDEB2("startMatch, ugrpidx " << (grpidx) << "\n" );
m_groupanchors[grpidx].push_back(++m_lastanchor); m_groupanchors[grpidx].push_back(++m_lastanchor);
m_groupcuranchors[grpidx] = 0; m_groupcuranchors[grpidx] = 0;
return string("<span style='color: "). return string("<span style='color: ").
@ -105,7 +105,7 @@ string PlainToRichQtPreview::startChunk()
int PlainToRichQtPreview::nextAnchorNum(int grpidx) int PlainToRichQtPreview::nextAnchorNum(int grpidx)
{ {
LOGDEB2(("nextAnchorNum: group %d\n", grpidx)); LOGDEB2("nextAnchorNum: group " << (grpidx) << "\n" );
map<unsigned int, unsigned int>::iterator curit = map<unsigned int, unsigned int>::iterator curit =
m_groupcuranchors.find(grpidx); m_groupcuranchors.find(grpidx);
map<unsigned int, vector<int> >::iterator vecit = map<unsigned int, vector<int> >::iterator vecit =
@ -122,7 +122,7 @@ int PlainToRichQtPreview::nextAnchorNum(int grpidx)
else else
m_groupcuranchors[grpidx]++; m_groupcuranchors[grpidx]++;
m_curanchor = vecit->second[m_groupcuranchors[grpidx]]; m_curanchor = vecit->second[m_groupcuranchors[grpidx]];
LOGDEB2(("nextAnchorNum: curanchor now %d\n", m_curanchor)); LOGDEB2("nextAnchorNum: curanchor now " << (m_curanchor) << "\n" );
} }
return m_curanchor; return m_curanchor;
} }
@ -161,7 +161,6 @@ ToRichThread::ToRichThread(const string &i, const HighlightData& hd,
QObject *parent) QObject *parent)
: QThread(parent), m_input(i), m_hdata(hd), m_ptr(ptr), m_output(qrichlist) : QThread(parent), m_input(i), m_hdata(hd), m_ptr(ptr), m_output(qrichlist)
{ {
m_loglevel = DebugLog::getdbl()->getlevel();
} }
// Insert into editor by chunks so that the top becomes visible // Insert into editor by chunks so that the top becomes visible
@ -171,7 +170,6 @@ ToRichThread::ToRichThread(const string &i, const HighlightData& hd,
void ToRichThread::run() void ToRichThread::run()
{ {
DebugLog::getdbl()->setloglevel(m_loglevel);
list<string> out; list<string> out;
try { try {
m_ptr->plaintorich(m_input, out, m_hdata, CHUNKL); m_ptr->plaintorich(m_input, out, m_hdata, CHUNKL);
@ -185,3 +183,4 @@ void ToRichThread::run()
m_output.push_back(QString::fromUtf8(it->c_str(), it->length())); m_output.push_back(QString::fromUtf8(it->c_str(), it->length()));
} }
} }

View file

@ -64,7 +64,6 @@ public:
virtual void run(); virtual void run();
private: private:
int m_loglevel;
const string &m_input; const string &m_input;
const HighlightData &m_hdata; const HighlightData &m_hdata;
STD_SHARED_PTR<PlainToRichQtPreview> m_ptr; STD_SHARED_PTR<PlainToRichQtPreview> m_ptr;

View file

@ -45,7 +45,7 @@
#include <QShortcut> #include <QShortcut>
#include <QTimer> #include <QTimer>
#include "debuglog.h" #include "log.h"
#include "pathut.h" #include "pathut.h"
#include "internfile.h" #include "internfile.h"
#include "recoll.h" #include "recoll.h"
@ -195,7 +195,7 @@ void Preview::emitShowPrev()
void Preview::closeEvent(QCloseEvent *e) void Preview::closeEvent(QCloseEvent *e)
{ {
LOGDEB(("Preview::closeEvent. m_loading %d\n", m_loading)); LOGDEB("Preview::closeEvent. m_loading " << (m_loading) << "\n" );
if (m_loading) { if (m_loading) {
CancelCheck::instance().setCancel(); CancelCheck::instance().setCancel();
e->ignore(); e->ignore();
@ -226,11 +226,10 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
{ {
if (event->type() != QEvent::KeyPress) { if (event->type() != QEvent::KeyPress) {
#if 0 #if 0
LOGDEB(("Preview::eventFilter(): %s\n", eventTypeToStr(event->type()))); LOGDEB("Preview::eventFilter(): " << (eventTypeToStr(event->type())) << "\n" );
if (event->type() == QEvent::MouseButtonRelease) { if (event->type() == QEvent::MouseButtonRelease) {
QMouseEvent *mev = (QMouseEvent *)event; QMouseEvent *mev = (QMouseEvent *)event;
LOGDEB(("Mouse: GlobalY %d y %d\n", mev->globalY(), LOGDEB("Mouse: GlobalY " << (mev->globalY()) << " y " << (mev->y()) << "\n" );
mev->y()));
} }
#endif #endif
return false; return false;
@ -241,7 +240,7 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
if (m_dynSearchActive) { if (m_dynSearchActive) {
if (keyEvent->key() == Qt::Key_F3) { if (keyEvent->key() == Qt::Key_F3) {
LOGDEB2(("Preview::eventFilter: got F3\n")); LOGDEB2("Preview::eventFilter: got F3\n" );
doSearch(searchTextCMB->currentText(), true, doSearch(searchTextCMB->currentText(), true,
(keyEvent->modifiers() & Qt::ShiftModifier) != 0); (keyEvent->modifiers() & Qt::ShiftModifier) != 0);
return true; return true;
@ -254,18 +253,18 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
if (keyEvent->key() == Qt::Key_Slash || if (keyEvent->key() == Qt::Key_Slash ||
(keyEvent->key() == Qt::Key_F && (keyEvent->key() == Qt::Key_F &&
(keyEvent->modifiers() & Qt::ControlModifier))) { (keyEvent->modifiers() & Qt::ControlModifier))) {
LOGDEB2(("Preview::eventFilter: got / or C-F\n")); LOGDEB2("Preview::eventFilter: got / or C-F\n" );
searchTextCMB->setFocus(); searchTextCMB->setFocus();
m_dynSearchActive = true; m_dynSearchActive = true;
return true; return true;
} else if (keyEvent->key() == Qt::Key_Space) { } else if (keyEvent->key() == Qt::Key_Space) {
LOGDEB2(("Preview::eventFilter: got Space\n")); LOGDEB2("Preview::eventFilter: got Space\n" );
int value = edit->verticalScrollBar()->value(); int value = edit->verticalScrollBar()->value();
value += edit->verticalScrollBar()->pageStep(); value += edit->verticalScrollBar()->pageStep();
edit->verticalScrollBar()->setValue(value); edit->verticalScrollBar()->setValue(value);
return true; return true;
} else if (keyEvent->key() == Qt::Key_Backspace) { } else if (keyEvent->key() == Qt::Key_Backspace) {
LOGDEB2(("Preview::eventFilter: got Backspace\n")); LOGDEB2("Preview::eventFilter: got Backspace\n" );
int value = edit->verticalScrollBar()->value(); int value = edit->verticalScrollBar()->value();
value -= edit->verticalScrollBar()->pageStep(); value -= edit->verticalScrollBar()->pageStep();
edit->verticalScrollBar()->setValue(value); edit->verticalScrollBar()->setValue(value);
@ -279,8 +278,7 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
void Preview::searchTextChanged(const QString & text) void Preview::searchTextChanged(const QString & text)
{ {
LOGDEB1(("Search line text changed. text: '%s'\n", LOGDEB1("Search line text changed. text: '" << ((const char *)text.toUtf8()) << "'\n" );
(const char *)text.toUtf8()));
m_searchTextFromIndex = -1; m_searchTextFromIndex = -1;
if (text.isEmpty()) { if (text.isEmpty()) {
m_dynSearchActive = false; m_dynSearchActive = false;
@ -294,13 +292,13 @@ void Preview::searchTextChanged(const QString & text)
void Preview::searchTextFromIndex(int idx) void Preview::searchTextFromIndex(int idx)
{ {
LOGDEB1(("search line from index %d\n", idx)); LOGDEB1("search line from index " << (idx) << "\n" );
m_searchTextFromIndex = idx; m_searchTextFromIndex = idx;
} }
PreviewTextEdit *Preview::currentEditor() PreviewTextEdit *Preview::currentEditor()
{ {
LOGDEB2(("Preview::currentEditor()\n")); LOGDEB2("Preview::currentEditor()\n" );
QWidget *tw = pvTab->currentWidget(); QWidget *tw = pvTab->currentWidget();
PreviewTextEdit *edit = 0; PreviewTextEdit *edit = 0;
if (tw) { if (tw) {
@ -325,9 +323,7 @@ void Preview::emitSaveDocToFile()
void Preview::doSearch(const QString &_text, bool next, bool reverse, void Preview::doSearch(const QString &_text, bool next, bool reverse,
bool wordOnly) bool wordOnly)
{ {
LOGDEB(("Preview::doSearch: text [%s] idx %d next %d rev %d word %d\n", LOGDEB("Preview::doSearch: text [" << ((const char *)_text.toUtf8()) << "] idx " << (m_searchTextFromIndex) << " next " << (int(next)) << " rev " << (int(reverse)) << " word " << (int(wordOnly)) << "\n" );
(const char *)_text.toUtf8(), m_searchTextFromIndex, int(next),
int(reverse), int(wordOnly)));
QString text = _text; QString text = _text;
bool matchCase = matchCheck->isChecked(); bool matchCase = matchCheck->isChecked();
@ -339,7 +335,7 @@ void Preview::doSearch(const QString &_text, bool next, bool reverse,
if (text.isEmpty() || m_searchTextFromIndex != -1) { if (text.isEmpty() || m_searchTextFromIndex != -1) {
if (!edit->m_plaintorich->haveAnchors()) { if (!edit->m_plaintorich->haveAnchors()) {
LOGDEB(("NO ANCHORS\n")); LOGDEB("NO ANCHORS\n" );
return; return;
} }
// The combobox indices are equal to the search ugroup indices // The combobox indices are equal to the search ugroup indices
@ -350,7 +346,7 @@ void Preview::doSearch(const QString &_text, bool next, bool reverse,
edit->m_plaintorich->nextAnchorNum(m_searchTextFromIndex); edit->m_plaintorich->nextAnchorNum(m_searchTextFromIndex);
} }
QString aname = edit->m_plaintorich->curAnchorName(); QString aname = edit->m_plaintorich->curAnchorName();
LOGDEB(("Calling scrollToAnchor(%s)\n", (const char *)aname.toUtf8())); LOGDEB("Calling scrollToAnchor(" << ((const char *)aname.toUtf8()) << ")\n" );
edit->scrollToAnchor(aname); edit->scrollToAnchor(aname);
// Position the cursor approximately at the anchor (top of // Position the cursor approximately at the anchor (top of
// viewport) so that searches start from here // viewport) so that searches start from here
@ -370,7 +366,7 @@ void Preview::doSearch(const QString &_text, bool next, bool reverse,
edit->setTextCursor(cursor); edit->setTextCursor(cursor);
} }
Chrono chron; Chrono chron;
LOGDEB(("Preview::doSearch: first find call\n")); LOGDEB("Preview::doSearch: first find call\n" );
QTextDocument::FindFlags flags = 0; QTextDocument::FindFlags flags = 0;
if (reverse) if (reverse)
flags |= QTextDocument::FindBackward; flags |= QTextDocument::FindBackward;
@ -379,21 +375,19 @@ void Preview::doSearch(const QString &_text, bool next, bool reverse,
if (matchCase) if (matchCase)
flags |= QTextDocument::FindCaseSensitively; flags |= QTextDocument::FindCaseSensitively;
bool found = edit->find(text, flags); bool found = edit->find(text, flags);
LOGDEB(("Preview::doSearch: first find call return: found %d %.2f S\n", LOGDEB("Preview::doSearch: first find call return: found " << (found) << " " << (chron.secs()) << " S\n" );
found, chron.secs()));
// If not found, try to wrap around. // If not found, try to wrap around.
if (!found) { if (!found) {
LOGDEB(("Preview::doSearch: wrapping around\n")); LOGDEB("Preview::doSearch: wrapping around\n" );
if (reverse) { if (reverse) {
edit->moveCursor (QTextCursor::End); edit->moveCursor (QTextCursor::End);
} else { } else {
edit->moveCursor (QTextCursor::Start); edit->moveCursor (QTextCursor::Start);
} }
LOGDEB(("Preview::doSearch: 2nd find call\n")); LOGDEB("Preview::doSearch: 2nd find call\n" );
chron.restart(); chron.restart();
found = edit->find(text, flags); found = edit->find(text, flags);
LOGDEB(("Preview::doSearch: 2nd find call return found %d %.2f S\n", LOGDEB("Preview::doSearch: 2nd find call return found " << (found) << " " << (chron.secs()) << " S\n" );
found, chron.secs()));
} }
if (found) { if (found) {
@ -403,37 +397,37 @@ void Preview::doSearch(const QString &_text, bool next, bool reverse,
QApplication::beep(); QApplication::beep();
m_canBeep = false; m_canBeep = false;
} }
LOGDEB(("Preview::doSearch: return\n")); LOGDEB("Preview::doSearch: return\n" );
} }
void Preview::nextPressed() void Preview::nextPressed()
{ {
LOGDEB2(("Preview::nextPressed\n")); LOGDEB2("Preview::nextPressed\n" );
doSearch(searchTextCMB->currentText(), true, false); doSearch(searchTextCMB->currentText(), true, false);
} }
void Preview::prevPressed() void Preview::prevPressed()
{ {
LOGDEB2(("Preview::prevPressed\n")); LOGDEB2("Preview::prevPressed\n" );
doSearch(searchTextCMB->currentText(), true, true); doSearch(searchTextCMB->currentText(), true, true);
} }
// Called when user clicks on tab // Called when user clicks on tab
void Preview::currentChanged(int index) void Preview::currentChanged(int index)
{ {
LOGDEB2(("PreviewTextEdit::currentChanged\n")); LOGDEB2("PreviewTextEdit::currentChanged\n" );
QWidget *tw = pvTab->widget(index); QWidget *tw = pvTab->widget(index);
PreviewTextEdit *edit = PreviewTextEdit *edit =
tw->findChild<PreviewTextEdit*>("pvEdit"); tw->findChild<PreviewTextEdit*>("pvEdit");
LOGDEB1(("Preview::currentChanged(). Editor: %p\n", edit)); LOGDEB1("Preview::currentChanged(). Editor: " << (edit) << "\n" );
if (edit == 0) { if (edit == 0) {
LOGERR(("Editor child not found\n")); LOGERR("Editor child not found\n" );
return; return;
} }
edit->setFocus(); edit->setFocus();
// Disconnect the print signal and reconnect it to the current editor // Disconnect the print signal and reconnect it to the current editor
LOGDEB(("Disconnecting reconnecting print signal\n")); LOGDEB("Disconnecting reconnecting print signal\n" );
disconnect(this, SIGNAL(printCurrentPreviewRequest()), 0, 0); disconnect(this, SIGNAL(printCurrentPreviewRequest()), 0, 0);
connect(this, SIGNAL(printCurrentPreviewRequest()), edit, SLOT(print())); connect(this, SIGNAL(printCurrentPreviewRequest()), edit, SLOT(print()));
edit->installEventFilter(this); edit->installEventFilter(this);
@ -444,7 +438,7 @@ void Preview::currentChanged(int index)
void Preview::closeCurrentTab() void Preview::closeCurrentTab()
{ {
LOGDEB1(("Preview::closeCurrentTab: m_loading %d\n", m_loading)); LOGDEB1("Preview::closeCurrentTab: m_loading " << (m_loading) << "\n" );
if (m_loading) { if (m_loading) {
CancelCheck::instance().setCancel(); CancelCheck::instance().setCancel();
return; return;
@ -461,7 +455,7 @@ void Preview::closeCurrentTab()
PreviewTextEdit *Preview::addEditorTab() PreviewTextEdit *Preview::addEditorTab()
{ {
LOGDEB1(("PreviewTextEdit::addEditorTab()\n")); LOGDEB1("PreviewTextEdit::addEditorTab()\n" );
QWidget *anon = new QWidget((QWidget *)pvTab); QWidget *anon = new QWidget((QWidget *)pvTab);
QVBoxLayout *anonLayout = new QVBoxLayout(anon); QVBoxLayout *anonLayout = new QVBoxLayout(anon);
PreviewTextEdit *editor = new PreviewTextEdit(anon, "pvEdit", this); PreviewTextEdit *editor = new PreviewTextEdit(anon, "pvEdit", this);
@ -475,7 +469,7 @@ PreviewTextEdit *Preview::addEditorTab()
void Preview::setCurTabProps(const Rcl::Doc &doc, int docnum) void Preview::setCurTabProps(const Rcl::Doc &doc, int docnum)
{ {
LOGDEB1(("Preview::setCurTabProps\n")); LOGDEB1("Preview::setCurTabProps\n" );
QString title; QString title;
string ctitle; string ctitle;
if (doc.getmeta(Rcl::Doc::keytt, &ctitle) && !ctitle.empty()) { if (doc.getmeta(Rcl::Doc::keytt, &ctitle) && !ctitle.empty()) {
@ -497,7 +491,7 @@ void Preview::setCurTabProps(const Rcl::Doc &doc, int docnum)
struct tm *tm = localtime(&mtime); struct tm *tm = localtime(&mtime);
strftime(datebuf, 99, "%Y-%m-%d %H:%M:%S", tm); strftime(datebuf, 99, "%Y-%m-%d %H:%M:%S", tm);
} }
LOGDEB(("Doc.url: [%s]\n", doc.url.c_str())); LOGDEB("Doc.url: [" << (doc.url) << "]\n" );
string url; string url;
printableUrl(theconfig->getDefCharset(), doc.url, url); printableUrl(theconfig->getDefCharset(), doc.url, url);
string tiptxt = url + string("\n"); string tiptxt = url + string("\n");
@ -517,10 +511,10 @@ void Preview::setCurTabProps(const Rcl::Doc &doc, int docnum)
bool Preview::makeDocCurrent(const Rcl::Doc& doc, int docnum, bool sametab) bool Preview::makeDocCurrent(const Rcl::Doc& doc, int docnum, bool sametab)
{ {
LOGDEB(("Preview::makeDocCurrent: %s\n", doc.url.c_str())); LOGDEB("Preview::makeDocCurrent: " << (doc.url) << "\n" );
if (m_loading) { if (m_loading) {
LOGERR(("Already loading\n")); LOGERR("Already loading\n" );
return false; return false;
} }
@ -609,7 +603,7 @@ public:
bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum) bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
{ {
LOGDEB1(("Preview::loadDocInCurrentTab()\n")); LOGDEB1("Preview::loadDocInCurrentTab()\n" );
LoadGuard guard(&m_loading); LoadGuard guard(&m_loading);
CancelCheck::instance().setCancel(false); CancelCheck::instance().setCancel(false);
@ -647,10 +641,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
progress.show(); progress.show();
} }
LOGDEB(("loadDocInCurrentTab: after file load: cancel %d status %d" LOGDEB("loadDocInCurrentTab: after file load: cancel " << (CancelCheck::instance().cancelState()) << " status " << (lthr.status) << " text length " << (lthr.fdoc.text.length()) << "\n" );
" text length %d\n",
CancelCheck::instance().cancelState(), lthr.status,
lthr.fdoc.text.length()));
if (CancelCheck::instance().cancelState()) if (CancelCheck::instance().cancelState())
return false; return false;
@ -719,10 +710,10 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
qApp->processEvents(); qApp->processEvents();
if (inputishtml) { if (inputishtml) {
LOGDEB1(("Preview: got html %s\n", lthr.fdoc.text.c_str())); LOGDEB1("Preview: got html " << (lthr.fdoc.text) << "\n" );
editor->m_plaintorich->set_inputhtml(true); editor->m_plaintorich->set_inputhtml(true);
} else { } else {
LOGDEB1(("Preview: got plain %s\n", lthr.fdoc.text.c_str())); LOGDEB1("Preview: got plain " << (lthr.fdoc.text) << "\n" );
editor->m_plaintorich->set_inputhtml(false); editor->m_plaintorich->set_inputhtml(false);
} }
@ -753,8 +744,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
} }
} }
} else { } else {
LOGDEB(("Preview: no hilighting, loading %d bytes\n", LOGDEB("Preview: no hilighting, loading " << (int(lthr.fdoc.text.size())) << " bytes\n" );
int(lthr.fdoc.text.size())));
// No plaintorich() call. In this case, either the text is // No plaintorich() call. In this case, either the text is
// html and the html quoting is hopefully correct, or it's // html and the html quoting is hopefully correct, or it's
// plain-text and there is no need to escape special // plain-text and there is no need to escape special
@ -804,7 +794,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
if (progress.wasCanceled()) { if (progress.wasCanceled()) {
editor->append("<b>Cancelled !</b>"); editor->append("<b>Cancelled !</b>");
LOGDEB(("loadDocInCurrentTab: cancelled in editor load\n")); LOGDEB("loadDocInCurrentTab: cancelled in editor load\n" );
break; break;
} }
} }
@ -836,7 +826,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
if (fn.empty() || !idoc.ipath.empty()) { if (fn.empty() || !idoc.ipath.empty()) {
TempFile temp = lthr.tmpimg; TempFile temp = lthr.tmpimg;
if (temp) { if (temp) {
LOGDEB1(("Preview: load: got temp file from internfile\n")); LOGDEB1("Preview: load: got temp file from internfile\n" );
} else if (!FileInterner::idocToFile(temp, string(), } else if (!FileInterner::idocToFile(temp, string(),
theconfig, idoc)) { theconfig, idoc)) {
temp.reset(); // just in case. temp.reset(); // just in case.
@ -868,7 +858,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
// Position to the first query term // Position to the first query term
if (editor->m_plaintorich->haveAnchors()) { if (editor->m_plaintorich->haveAnchors()) {
QString aname = editor->m_plaintorich->curAnchorName(); QString aname = editor->m_plaintorich->curAnchorName();
LOGDEB2(("Call movetoanchor(%s)\n", (const char *)aname.toUtf8())); LOGDEB2("Call movetoanchor(" << ((const char *)aname.toUtf8()) << ")\n" );
editor->scrollToAnchor(aname); editor->scrollToAnchor(aname);
// Position the cursor approximately at the anchor (top of // Position the cursor approximately at the anchor (top of
// viewport) so that searches start from here // viewport) so that searches start from here
@ -886,7 +876,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
editor->setFocus(); editor->setFocus();
emit(previewExposed(this, m_searchId, docnum)); emit(previewExposed(this, m_searchId, docnum));
LOGDEB(("loadDocInCurrentTab: returning true\n")); LOGDEB("loadDocInCurrentTab: returning true\n" );
return true; return true;
} }
@ -905,7 +895,7 @@ PreviewTextEdit::PreviewTextEdit(QWidget* parent, const char* nm, Preview *pv)
void PreviewTextEdit::createPopupMenu(const QPoint& pos) void PreviewTextEdit::createPopupMenu(const QPoint& pos)
{ {
LOGDEB1(("PreviewTextEdit::createPopupMenu()\n")); LOGDEB1("PreviewTextEdit::createPopupMenu()\n" );
QMenu *popup = new QMenu(this); QMenu *popup = new QMenu(this);
switch (m_curdsp) { switch (m_curdsp) {
case PTE_DSPTXT: case PTE_DSPTXT:
@ -944,7 +934,7 @@ void PreviewTextEdit::createPopupMenu(const QPoint& pos)
// Display main text // Display main text
void PreviewTextEdit::displayText() void PreviewTextEdit::displayText()
{ {
LOGDEB1(("PreviewTextEdit::displayText()\n")); LOGDEB1("PreviewTextEdit::displayText()\n" );
if (m_format == Qt::PlainText) if (m_format == Qt::PlainText)
setPlainText(m_richtxt); setPlainText(m_richtxt);
else else
@ -955,7 +945,7 @@ void PreviewTextEdit::displayText()
// Display field values // Display field values
void PreviewTextEdit::displayFields() void PreviewTextEdit::displayFields()
{ {
LOGDEB1(("PreviewTextEdit::displayFields()\n")); LOGDEB1("PreviewTextEdit::displayFields()\n" );
QString txt = "<html><head></head><body>\n"; QString txt = "<html><head></head><body>\n";
txt += "<b>" + QString::fromLocal8Bit(m_url.c_str()); txt += "<b>" + QString::fromLocal8Bit(m_url.c_str());
@ -977,7 +967,7 @@ void PreviewTextEdit::displayFields()
void PreviewTextEdit::displayImage() void PreviewTextEdit::displayImage()
{ {
LOGDEB1(("PreviewTextEdit::displayImage()\n")); LOGDEB1("PreviewTextEdit::displayImage()\n" );
if (m_image.isNull()) if (m_image.isNull())
displayText(); displayText();
@ -995,7 +985,7 @@ void PreviewTextEdit::displayImage()
void PreviewTextEdit::mouseDoubleClickEvent(QMouseEvent *event) void PreviewTextEdit::mouseDoubleClickEvent(QMouseEvent *event)
{ {
LOGDEB2(("PreviewTextEdit::mouseDoubleClickEvent\n")); LOGDEB2("PreviewTextEdit::mouseDoubleClickEvent\n" );
QTextEdit::mouseDoubleClickEvent(event); QTextEdit::mouseDoubleClickEvent(event);
if (textCursor().hasSelection() && m_preview) if (textCursor().hasSelection() && m_preview)
m_preview->emitWordSelect(textCursor().selectedText()); m_preview->emitWordSelect(textCursor().selectedText());
@ -1003,7 +993,7 @@ void PreviewTextEdit::mouseDoubleClickEvent(QMouseEvent *event)
void PreviewTextEdit::print() void PreviewTextEdit::print()
{ {
LOGDEB(("PreviewTextEdit::print\n")); LOGDEB("PreviewTextEdit::print\n" );
if (!m_preview) if (!m_preview)
return; return;
@ -1016,3 +1006,4 @@ void PreviewTextEdit::print()
QTextEdit::print(&printer); QTextEdit::print(&printer);
#endif #endif
} }

View file

@ -34,7 +34,7 @@ using namespace std;
#include <qlayout.h> #include <qlayout.h>
#include "recoll.h" #include "recoll.h"
#include "debuglog.h" #include "log.h"
#include "guiutils.h" #include "guiutils.h"
#include "conftree.h" #include "conftree.h"
@ -133,3 +133,4 @@ void EditTrans::on_transTW_itemSelectionChanged()
else else
delPB->setEnabled(1); delPB->setEnabled(1);
} }

View file

@ -22,7 +22,7 @@
#include "recoll.h" #include "recoll.h"
#include "rclhelp.h" #include "rclhelp.h"
#include "debuglog.h" #include "log.h"
map<string, string> HelpClient::helpmap; map<string, string> HelpClient::helpmap;
@ -42,7 +42,7 @@ bool HelpClient::eventFilter(QObject *obj, QEvent *event)
static time_t last_start; static time_t last_start;
if (event->type() == QEvent::KeyPress || if (event->type() == QEvent::KeyPress ||
event->type() == QEvent::ShortcutOverride) { event->type() == QEvent::ShortcutOverride) {
// LOGDEB(("HelpClient::eventFilter: %d\n", (int)event->type())); // LOGDEB("HelpClient::eventFilter: " << ((int)event->type()) << "\n" );
QKeyEvent *ke = static_cast<QKeyEvent *>(event); QKeyEvent *ke = static_cast<QKeyEvent *>(event);
if (ke->key() == Qt::Key_F1 || ke->key() == Qt::Key_Help) { if (ke->key() == Qt::Key_F1 || ke->key() == Qt::Key_Help) {
if (obj->isWidgetType()) { if (obj->isWidgetType()) {
@ -57,11 +57,10 @@ bool HelpClient::eventFilter(QObject *obj, QEvent *event)
if (time(0) - last_start > 5) { if (time(0) - last_start > 5) {
last_start = time(0); last_start = time(0);
if (it != helpmap.end()) { if (it != helpmap.end()) {
LOGDEB(("HelpClient::eventFilter: %s->%s\n", LOGDEB("HelpClient::eventFilter: " << (it->first) << "->" << (it->second) << "\n" );
it->first.c_str(), it->second.c_str()));
startManual(it->second); startManual(it->second);
} else { } else {
LOGDEB(("HelpClient::eventFilter: no help section\n")); LOGDEB("HelpClient::eventFilter: no help section\n" );
startManual(""); startManual("");
} }
} }
@ -71,3 +70,4 @@ bool HelpClient::eventFilter(QObject *obj, QEvent *event)
} }
return false; return false;
} }

View file

@ -23,7 +23,7 @@
#include <QTimer> #include <QTimer>
#include "execmd.h" #include "execmd.h"
#include "debuglog.h" #include "log.h"
#include "transcode.h" #include "transcode.h"
#include "indexer.h" #include "indexer.h"
#include "rclmain_w.h" #include "rclmain_w.h"
@ -83,7 +83,7 @@ void RclMain::updateIdxStatus()
// indexing, a possible need to exit, and cleanup exited viewers // indexing, a possible need to exit, and cleanup exited viewers
void RclMain::periodic100() void RclMain::periodic100()
{ {
LOGDEB2(("Periodic100\n")); LOGDEB2("Periodic100\n" );
if (m_idxproc) { if (m_idxproc) {
// An indexing process was launched. If its' done, see status. // An indexing process was launched. If its' done, see status.
int status; int status;
@ -268,7 +268,7 @@ void RclMain::rebuildIndex()
case IXST_NOTRUNNING: case IXST_NOTRUNNING:
{ {
if (m_idxproc) { if (m_idxproc) {
LOGERR(("RclMain::rebuildIndex: current indexer exec not null\n")); LOGERR("RclMain::rebuildIndex: current indexer exec not null\n" );
return; return;
} }
int rep = int rep =
@ -354,7 +354,7 @@ static string execToString(const string& cmd, const vector<string>& args)
void RclMain::specialIndex() void RclMain::specialIndex()
{ {
LOGDEB(("RclMain::specialIndex\n")); LOGDEB("RclMain::specialIndex\n" );
switch (m_indexerState) { switch (m_indexerState) {
case IXST_UNKNOWN: case IXST_UNKNOWN:
case IXST_RUNNINGMINE: case IXST_RUNNINGMINE:
@ -365,7 +365,7 @@ void RclMain::specialIndex()
break; break;
} }
if (m_idxproc) { if (m_idxproc) {
LOGERR(("RclMain::rebuildIndex: current indexer exec not null\n")); LOGERR("RclMain::rebuildIndex: current indexer exec not null\n" );
return; return;
} }
if (!specidx) // ?? if (!specidx) // ??
@ -418,8 +418,7 @@ void RclMain::specialIndex()
args.push_back(top); args.push_back(top);
} }
m_idxproc = new ExecCmd; m_idxproc = new ExecCmd;
LOGINFO(("specialIndex: exec: %s\n", LOGINFO("specialIndex: exec: " << execToString("recollindex", args) <<endl);
execToString("recollindex", args).c_str()));
m_idxproc->startExec("recollindex", args, false, false); m_idxproc->startExec("recollindex", args, false, false);
} }
@ -449,3 +448,4 @@ void RclMain::updateIdxForDocs(vector<Rcl::Doc>& docs)
actionSpecial_Indexing->setEnabled(false); actionSpecial_Indexing->setEnabled(false);
} }

View file

@ -19,7 +19,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QShortcut> #include <QShortcut>
#include "debuglog.h" #include "log.h"
#include "internfile.h" #include "internfile.h"
#include "rclzg.h" #include "rclzg.h"
#include "rclmain_w.h" #include "rclmain_w.h"
@ -31,12 +31,12 @@ static const QKeySequence quitKeySeq("Ctrl+q");
// where the current one is closed // where the current one is closed
void RclMain::previewClosed(Preview *w) void RclMain::previewClosed(Preview *w)
{ {
LOGDEB(("RclMain::previewClosed(%p)\n", w)); LOGDEB("RclMain::previewClosed(" << (w) << ")\n" );
if (w == curPreview) { if (w == curPreview) {
LOGDEB(("Active preview closed\n")); LOGDEB("Active preview closed\n" );
curPreview = 0; curPreview = 0;
} else { } else {
LOGDEB(("Old preview closed\n")); LOGDEB("Old preview closed\n" );
} }
delete w; delete w;
} }
@ -114,7 +114,7 @@ bool RclMain::containerUpToDate(Rcl::Doc& doc)
QMessageBox::Cancel : QMessageBox::NoButton); QMessageBox::Cancel : QMessageBox::NoButton);
if (m_indexerState == IXST_NOTRUNNING && rep == QMessageBox::Ok) { if (m_indexerState == IXST_NOTRUNNING && rep == QMessageBox::Ok) {
LOGDEB(("Requesting index update for %s\n", doc.url.c_str())); LOGDEB("Requesting index update for " << (doc.url) << "\n" );
vector<Rcl::Doc> docs(1, doc); vector<Rcl::Doc> docs(1, doc);
updateIdxForDocs(docs); updateIdxForDocs(docs);
} }
@ -135,7 +135,7 @@ bool RclMain::containerUpToDate(Rcl::Doc& doc)
*/ */
void RclMain::startPreview(int docnum, Rcl::Doc doc, int mod) void RclMain::startPreview(int docnum, Rcl::Doc doc, int mod)
{ {
LOGDEB(("startPreview(%d, doc, %d)\n", docnum, mod)); LOGDEB("startPreview(" << (docnum) << ", doc, " << (mod) << ")\n" );
if (!containerUpToDate(doc)) if (!containerUpToDate(doc))
return; return;
@ -221,8 +221,7 @@ void RclMain::previewPrevInTab(Preview * w, int sid, int docnum)
// Combined next/prev from result list in current preview tab // Combined next/prev from result list in current preview tab
void RclMain::previewPrevOrNextInTab(Preview * w, int sid, int docnum, bool nxt) void RclMain::previewPrevOrNextInTab(Preview * w, int sid, int docnum, bool nxt)
{ {
LOGDEB(("RclMain::previewNextInTab sid %d docnum %d, listId %d\n", LOGDEB("RclMain::previewNextInTab sid " << (sid) << " docnum " << (docnum) << ", listId " << (reslist->listId()) << "\n" );
sid, docnum, reslist->listId()));
if (w == 0) // ?? if (w == 0) // ??
return; return;
@ -256,10 +255,10 @@ void RclMain::previewPrevOrNextInTab(Preview * w, int sid, int docnum, bool nxt)
// displayed result list, tell reslist (to color the paragraph) // displayed result list, tell reslist (to color the paragraph)
void RclMain::previewExposed(Preview *, int sid, int docnum) void RclMain::previewExposed(Preview *, int sid, int docnum)
{ {
LOGDEB2(("RclMain::previewExposed: sid %d docnum %d, m_sid %d\n", LOGDEB2("RclMain::previewExposed: sid " << (sid) << " docnum " << (docnum) << ", m_sid " << (reslist->listId()) << "\n" );
sid, docnum, reslist->listId()));
if (sid != reslist->listId()) { if (sid != reslist->listId()) {
return; return;
} }
reslist->previewExposed(docnum); reslist->previewExposed(docnum);
} }

View file

@ -25,7 +25,7 @@
#include <QFileDialog> #include <QFileDialog>
#include "rclmain_w.h" #include "rclmain_w.h"
#include "debuglog.h" #include "log.h"
#include "readfile.h" #include "readfile.h"
#include "xmltosd.h" #include "xmltosd.h"
#include "searchdata.h" #include "searchdata.h"
@ -88,7 +88,7 @@ void RclMain::saveLastQuery()
string tofile((const char *)s.toLocal8Bit()); string tofile((const char *)s.toLocal8Bit());
LOGDEB(("RclMain::saveLastQuery: XML: [%s]\n", xml.c_str())); LOGDEB("RclMain::saveLastQuery: XML: [" << (xml) << "]\n" );
string reason; string reason;
if (!stringtofile(xml, tofile.c_str(), reason)) { if (!stringtofile(xml, tofile.c_str(), reason)) {
QMessageBox::warning(this, tr("Write failed"), QMessageBox::warning(this, tr("Write failed"),
@ -132,3 +132,4 @@ void RclMain::loadSavedQuery()
QMessageBox::warning(this, tr("Load error"), QMessageBox::warning(this, tr("Load error"),
tr("Could not load saved query")); tr("Could not load saved query"));
} }

View file

@ -24,7 +24,7 @@
#include "qxtconfirmationmessage.h" #include "qxtconfirmationmessage.h"
#include "debuglog.h" #include "log.h"
#include "fileudi.h" #include "fileudi.h"
#include "execmd.h" #include "execmd.h"
#include "transcode.h" #include "transcode.h"
@ -47,9 +47,7 @@ void RclMain::viewUrl()
return; return;
QUrl qurl(m_urltoview); QUrl qurl(m_urltoview);
LOGDEB(("RclMain::viewUrl: Path [%s] fragment [%s]\n", LOGDEB("RclMain::viewUrl: Path [" << ((const char *)qurl.path().toLocal8Bit()) << "] fragment [" << ((const char *)qurl.fragment().toLocal8Bit()) << "]\n" );
(const char *)qurl.path().toLocal8Bit(),
(const char *)qurl.fragment().toLocal8Bit()));
/* In theory, the url might not be for a file managed by the fs /* In theory, the url might not be for a file managed by the fs
indexer so that the make_udi() call here would be indexer so that the make_udi() call here would be
@ -124,7 +122,7 @@ static bool lookForHtmlBrowser(string &exefile)
void RclMain::openWith(Rcl::Doc doc, string cmdspec) void RclMain::openWith(Rcl::Doc doc, string cmdspec)
{ {
LOGDEB(("RclMain::openWith: %s\n", cmdspec.c_str())); LOGDEB("RclMain::openWith: " << (cmdspec) << "\n" );
// Split the command line // Split the command line
vector<string> lcmd; vector<string> lcmd;
@ -159,11 +157,7 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term)
{ {
string apptag; string apptag;
doc.getmeta(Rcl::Doc::keyapptg, &apptag); doc.getmeta(Rcl::Doc::keyapptg, &apptag);
LOGDEB(("RclMain::startNativeViewer: mtype [%s] apptag [%s] page %d " LOGDEB("RclMain::startNativeViewer: mtype [" << (doc.mimetype) << "] apptag [" << (apptag) << "] page " << (pagenum) << " term [" << ((const char *)(term.toUtf8())) << "] url [" << (doc.url) << "] ipath [" << (doc.ipath) << "]\n" );
"term [%s] url [%s] ipath [%s]\n",
doc.mimetype.c_str(), apptag.c_str(), pagenum,
(const char *)(term.toUtf8()), doc.url.c_str(), doc.ipath.c_str()
));
// Look for appropriate viewer // Look for appropriate viewer
string cmdplusattr = theconfig->getMimeViewerDef(doc.mimetype, apptag, string cmdplusattr = theconfig->getMimeViewerDef(doc.mimetype, apptag,
@ -293,8 +287,7 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term)
bool enterHistory = false; bool enterHistory = false;
bool istempfile = false; bool istempfile = false;
LOGDEB(("RclMain::startNV: groksipath %d wantsf %d wantsparentf %d\n", LOGDEB("RclMain::startNV: groksipath " << (groksipath) << " wantsf " << (wantsfile) << " wantsparentf " << (wantsparentfile) << "\n" );
groksipath, wantsfile, wantsparentfile));
// If the command wants a file but this is not a file url, or // If the command wants a file but this is not a file url, or
// there is an ipath that it won't understand, we need a temp file: // there is an ipath that it won't understand, we need a temp file:
@ -409,7 +402,7 @@ void RclMain::execViewer(const map<string, string>& subs, bool enterHistory,
for (vector<string>::const_iterator it = _lcmd.begin(); for (vector<string>::const_iterator it = _lcmd.begin();
it != _lcmd.end(); it++) { it != _lcmd.end(); it++) {
pcSubst(*it, ncmd, subs); pcSubst(*it, ncmd, subs);
LOGDEB(("%s->%s\n", it->c_str(), ncmd.c_str())); LOGDEB("" << *it << "->" << (ncmd) << "\n" );
lcmd.push_back(ncmd); lcmd.push_back(ncmd);
} }
@ -457,8 +450,7 @@ void RclMain::startManual(const string& index)
webhelp = path_cat(webhelp, "index.html"); webhelp = path_cat(webhelp, "index.html");
bool has_wh = path_exists(webhelp); bool has_wh = path_exists(webhelp);
LOGDEB(("RclMain::startManual: help index is %s\n", LOGDEB("RclMain::startManual: help index is " << (index.empty()?"(null)":index) << "\n" );
index.empty()?"(null)":index.c_str()));
bool indexempty = index.empty(); bool indexempty = index.empty();
#ifdef _WIN32 #ifdef _WIN32
@ -481,3 +473,4 @@ void RclMain::startManual(const string& index)
doc.mimetype = "text/html"; doc.mimetype = "text/html";
startNativeViewer(doc); startNativeViewer(doc);
} }

View file

@ -19,7 +19,7 @@
#include <QShortcut> #include <QShortcut>
#include <QMessageBox> #include <QMessageBox>
#include "debuglog.h" #include "log.h"
#include "internfile.h" #include "internfile.h"
#include "listdialog.h" #include "listdialog.h"
#include "confgui/confguiindex.h" #include "confgui/confguiindex.h"
@ -171,7 +171,7 @@ void RclMain::execIndexConfig()
} }
void RclMain::showIndexConfig(bool modal) void RclMain::showIndexConfig(bool modal)
{ {
LOGDEB(("showIndexConfig()\n")); LOGDEB("showIndexConfig()\n" );
if (indexConfig == 0) { if (indexConfig == 0) {
indexConfig = new ConfIndexW(0, theconfig); indexConfig = new ConfIndexW(0, theconfig);
connect(new QShortcut(quitKeySeq, indexConfig), SIGNAL (activated()), connect(new QShortcut(quitKeySeq, indexConfig), SIGNAL (activated()),
@ -205,7 +205,7 @@ void RclMain::showIndexSched(bool modal)
"to update the index")); "to update the index"));
return; return;
#endif #endif
LOGDEB(("showIndexSched()\n")); LOGDEB("showIndexSched()\n" );
if (indexSched == 0) { if (indexSched == 0) {
indexSched = new IdxSchedW(this); indexSched = new IdxSchedW(this);
connect(new QShortcut(quitKeySeq, indexSched), SIGNAL (activated()), connect(new QShortcut(quitKeySeq, indexSched), SIGNAL (activated()),
@ -246,7 +246,7 @@ void RclMain::execCronTool()
} }
void RclMain::showCronTool(bool modal) void RclMain::showCronTool(bool modal)
{ {
LOGDEB(("showCronTool()\n")); LOGDEB("showCronTool()\n" );
if (cronTool == 0) { if (cronTool == 0) {
cronTool = new CronToolW(0); cronTool = new CronToolW(0);
connect(new QShortcut(quitKeySeq, cronTool), SIGNAL (activated()), connect(new QShortcut(quitKeySeq, cronTool), SIGNAL (activated()),
@ -273,7 +273,7 @@ void RclMain::execRTITool()
} }
void RclMain::showRTITool(bool modal) void RclMain::showRTITool(bool modal)
{ {
LOGDEB(("showRTITool()\n")); LOGDEB("showRTITool()\n" );
if (rtiTool == 0) { if (rtiTool == 0) {
rtiTool = new RTIToolW(0); rtiTool = new RTIToolW(0);
connect(new QShortcut(quitKeySeq, rtiTool), SIGNAL (activated()), connect(new QShortcut(quitKeySeq, rtiTool), SIGNAL (activated()),
@ -453,3 +453,4 @@ void RclMain::showSnippets(Rcl::Doc doc)
sp, SLOT (close())); sp, SLOT (close()));
sp->show(); sp->show();
} }

View file

@ -43,7 +43,7 @@
#include <QToolBar> #include <QToolBar>
#include "recoll.h" #include "recoll.h"
#include "debuglog.h" #include "log.h"
#include "mimehandler.h" #include "mimehandler.h"
#include "pathut.h" #include "pathut.h"
#include "smallut.h" #include "smallut.h"
@ -585,7 +585,7 @@ void RclMain::initDbOpen()
void RclMain::setStemLang(QAction *id) void RclMain::setStemLang(QAction *id)
{ {
LOGDEB(("RclMain::setStemLang(%p)\n", id)); LOGDEB("RclMain::setStemLang(" << (id) << ")\n" );
// Check that the menu entry is for a stemming language change // Check that the menu entry is for a stemming language change
// (might also be "show prefs" etc. // (might also be "show prefs" etc.
bool isLangId = false; bool isLangId = false;
@ -615,8 +615,7 @@ void RclMain::setStemLang(QAction *id)
lang = id->text(); lang = id->text();
} }
prefs.queryStemLang = lang; prefs.queryStemLang = lang;
LOGDEB(("RclMain::setStemLang(%d): lang [%s]\n", LOGDEB("RclMain::setStemLang(" << (id) << "): lang [" << ((const char *)prefs.queryStemLang.toUtf8()) << "]\n" );
id, (const char *)prefs.queryStemLang.toUtf8()));
rwSettings(true); rwSettings(true);
emit stemLangChanged(lang); emit stemLangChanged(lang);
} }
@ -624,7 +623,7 @@ void RclMain::setStemLang(QAction *id)
// Set the checked stemming language item before showing the prefs menu // Set the checked stemming language item before showing the prefs menu
void RclMain::setStemLang(const QString& lang) void RclMain::setStemLang(const QString& lang)
{ {
LOGDEB(("RclMain::setStemLang(%s)\n", (const char *)lang.toUtf8())); LOGDEB("RclMain::setStemLang(" << ((const char *)lang.toUtf8()) << ")\n" );
QAction *id; QAction *id;
if (lang == "") { if (lang == "") {
id = m_idNoStem; id = m_idNoStem;
@ -658,7 +657,7 @@ void RclMain::showTrayMessage(const QString& text)
void RclMain::closeEvent(QCloseEvent *ev) void RclMain::closeEvent(QCloseEvent *ev)
{ {
LOGDEB(("RclMain::closeEvent\n")); LOGDEB("RclMain::closeEvent\n" );
if (prefs.closeToTray && m_trayicon && m_trayicon->isVisible()) { if (prefs.closeToTray && m_trayicon && m_trayicon->isVisible()) {
hide(); hide();
ev->ignore(); ev->ignore();
@ -669,7 +668,7 @@ void RclMain::closeEvent(QCloseEvent *ev)
void RclMain::fileExit() void RclMain::fileExit()
{ {
LOGDEB(("RclMain: fileExit\n")); LOGDEB("RclMain: fileExit\n" );
// Don't save geometry if we're currently fullscreened // Don't save geometry if we're currently fullscreened
if (!isFullScreen()) { if (!isFullScreen()) {
prefs.mainwidth = width(); prefs.mainwidth = width();
@ -697,10 +696,9 @@ void RclMain::fileExit()
// Start a db query and set the reslist docsource // Start a db query and set the reslist docsource
void RclMain::startSearch(STD_SHARED_PTR<Rcl::SearchData> sdata, bool issimple) void RclMain::startSearch(STD_SHARED_PTR<Rcl::SearchData> sdata, bool issimple)
{ {
LOGDEB(("RclMain::startSearch. Indexing %s Active %d\n", LOGDEB("RclMain::startSearch. Indexing " << (m_idxproc?"on":"off") << " Active " << (m_queryActive) << "\n" );
m_idxproc?"on":"off", m_queryActive));
if (m_queryActive) { if (m_queryActive) {
LOGDEB(("startSearch: already active\n")); LOGDEB("startSearch: already active\n" );
return; return;
} }
m_queryActive = true; m_queryActive = true;
@ -749,18 +747,15 @@ void RclMain::startSearch(STD_SHARED_PTR<Rcl::SearchData> sdata, bool issimple)
} }
class QueryThread : public QThread { class QueryThread : public QThread {
int loglevel;
STD_SHARED_PTR<DocSequence> m_source; STD_SHARED_PTR<DocSequence> m_source;
public: public:
QueryThread(STD_SHARED_PTR<DocSequence> source) QueryThread(STD_SHARED_PTR<DocSequence> source)
: m_source(source) : m_source(source)
{ {
loglevel = DebugLog::getdbl()->getlevel();
} }
~QueryThread() { } ~QueryThread() { }
virtual void run() virtual void run()
{ {
DebugLog::getdbl()->setloglevel(loglevel);
cnt = m_source->getResCnt(); cnt = m_source->getResCnt();
} }
int cnt; int cnt;
@ -830,7 +825,7 @@ void RclMain::onSortCtlChanged()
if (m_sortspecnochange) if (m_sortspecnochange)
return; return;
LOGDEB(("RclMain::onSortCtlChanged()\n")); LOGDEB("RclMain::onSortCtlChanged()\n" );
m_sortspec.reset(); m_sortspec.reset();
if (actionSortByDateAsc->isChecked()) { if (actionSortByDateAsc->isChecked()) {
m_sortspec.field = "mtime"; m_sortspec.field = "mtime";
@ -856,7 +851,7 @@ void RclMain::onSortCtlChanged()
void RclMain::onSortDataChanged(DocSeqSortSpec spec) void RclMain::onSortDataChanged(DocSeqSortSpec spec)
{ {
LOGDEB(("RclMain::onSortDataChanged\n")); LOGDEB("RclMain::onSortDataChanged\n" );
m_sortspecnochange = true; m_sortspecnochange = true;
if (spec.field.compare("mtime")) { if (spec.field.compare("mtime")) {
actionSortByDateDesc->setChecked(false); actionSortByDateDesc->setChecked(false);
@ -879,7 +874,7 @@ void RclMain::onSortDataChanged(DocSeqSortSpec spec)
void RclMain::on_actionShowResultsAsTable_toggled(bool on) void RclMain::on_actionShowResultsAsTable_toggled(bool on)
{ {
LOGDEB(("RclMain::on_actionShowResultsAsTable_toggled(%d)\n", int(on))); LOGDEB("RclMain::on_actionShowResultsAsTable_toggled(" << (int(on)) << ")\n" );
prefs.showResultsAsTable = on; prefs.showResultsAsTable = on;
displayingTable = on; displayingTable = on;
restable->setVisible(on); restable->setVisible(on);
@ -908,7 +903,7 @@ void RclMain::on_actionShowResultsAsTable_toggled(bool on)
void RclMain::on_actionSortByDateAsc_toggled(bool on) void RclMain::on_actionSortByDateAsc_toggled(bool on)
{ {
LOGDEB(("RclMain::on_actionSortByDateAsc_toggled(%d)\n", int(on))); LOGDEB("RclMain::on_actionSortByDateAsc_toggled(" << (int(on)) << ")\n" );
if (on) { if (on) {
if (actionSortByDateDesc->isChecked()) { if (actionSortByDateDesc->isChecked()) {
actionSortByDateDesc->setChecked(false); actionSortByDateDesc->setChecked(false);
@ -921,7 +916,7 @@ void RclMain::on_actionSortByDateAsc_toggled(bool on)
void RclMain::on_actionSortByDateDesc_toggled(bool on) void RclMain::on_actionSortByDateDesc_toggled(bool on)
{ {
LOGDEB(("RclMain::on_actionSortByDateDesc_toggled(%d)\n", int(on))); LOGDEB("RclMain::on_actionSortByDateDesc_toggled(" << (int(on)) << ")\n" );
if (on) { if (on) {
if (actionSortByDateAsc->isChecked()) { if (actionSortByDateAsc->isChecked()) {
actionSortByDateAsc->setChecked(false); actionSortByDateAsc->setChecked(false);
@ -951,7 +946,7 @@ void RclMain::saveDocToFile(Rcl::Doc doc)
void RclMain::showSubDocs(Rcl::Doc doc) void RclMain::showSubDocs(Rcl::Doc doc)
{ {
LOGDEB(("RclMain::showSubDocs\n")); LOGDEB("RclMain::showSubDocs\n" );
string reason; string reason;
if (!maybeOpenDb(reason)) { if (!maybeOpenDb(reason)) {
QMessageBox::critical(0, "Recoll", QString(reason.c_str())); QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
@ -980,14 +975,14 @@ void RclMain::showSubDocs(Rcl::Doc doc)
// significant terms, and add them to the simple search entry. // significant terms, and add them to the simple search entry.
void RclMain::docExpand(Rcl::Doc doc) void RclMain::docExpand(Rcl::Doc doc)
{ {
LOGDEB(("RclMain::docExpand()\n")); LOGDEB("RclMain::docExpand()\n" );
if (!rcldb) if (!rcldb)
return; return;
list<string> terms; list<string> terms;
terms = m_source->expand(doc); terms = m_source->expand(doc);
if (terms.empty()) { if (terms.empty()) {
LOGDEB(("RclMain::docExpand: no terms\n")); LOGDEB("RclMain::docExpand: no terms\n" );
return; return;
} }
// Do we keep the original query. I think we'd better not. // Do we keep the original query. I think we'd better not.
@ -1006,7 +1001,7 @@ void RclMain::docExpand(Rcl::Doc doc)
void RclMain::showDocHistory() void RclMain::showDocHistory()
{ {
LOGDEB(("RclMain::showDocHistory\n")); LOGDEB("RclMain::showDocHistory\n" );
emit searchReset(); emit searchReset();
m_source = STD_SHARED_PTR<DocSequence>(); m_source = STD_SHARED_PTR<DocSequence>();
curPreview = 0; curPreview = 0;
@ -1062,7 +1057,7 @@ void RclMain::setUIPrefs()
{ {
if (!uiprefs) if (!uiprefs)
return; return;
LOGDEB(("Recollmain::setUIPrefs\n")); LOGDEB("Recollmain::setUIPrefs\n" );
reslist->setFont(); reslist->setFont();
sSearch->setPrefs(); sSearch->setPrefs();
enbSynAction->setDisabled(prefs.synFile.isEmpty()); enbSynAction->setDisabled(prefs.synFile.isEmpty());
@ -1100,7 +1095,7 @@ void RclMain::catgFilter(QAction *act)
// User pressed a filter button: set filter params in reslist // User pressed a filter button: set filter params in reslist
void RclMain::catgFilter(int id) void RclMain::catgFilter(int id)
{ {
LOGDEB(("RclMain::catgFilter: id %d\n", id)); LOGDEB("RclMain::catgFilter: id " << (id) << "\n" );
if (id < 0 || id >= int(m_catgbutvec.size())) if (id < 0 || id >= int(m_catgbutvec.size()))
return; return;
@ -1173,3 +1168,4 @@ void RclMain::applyStyleSheet()
{ {
::applyStyleSheet(prefs.qssFile); ::applyStyleSheet(prefs.qssFile);
} }

View file

@ -20,7 +20,7 @@
#include "rclzg.h" #include "rclzg.h"
#include "debuglog.h" #include "log.h"
#include "pathut.h" #include "pathut.h"
#include <QString> #include <QString>
@ -78,9 +78,9 @@ void zg_send_event(ZgSendType, const Rcl::Doc& doc)
QtZeitgeist::DataModel::EventList events; QtZeitgeist::DataModel::EventList events;
events.push_back(event); events.push_back(event);
LOGDEB(("zg_send_event, sending for %s %s\n", LOGDEB("zg_send_event, sending for " << (doc.mimetype) << " " << (doc.url) << "\n" );
doc.mimetype.c_str(), doc.url.c_str()));
zglogger.insertEvents(events); zglogger.insertEvents(events);
} }
#endif #endif

View file

@ -6,6 +6,7 @@ DEFINES += BUILDING_RECOLL
@QMAKE_ENABLE_WEBKIT@ QT += webkit @QMAKE_ENABLE_WEBKIT@ QT += webkit
@QMAKE_DISABLE_WEBKIT@ QMAKE_CXXFLAGS += -DRESLIST_TEXTBROWSER -DSNIPPETS_TEXTBROWSER @QMAKE_DISABLE_WEBKIT@ QMAKE_CXXFLAGS += -DRESLIST_TEXTBROWSER -DSNIPPETS_TEXTBROWSER
QMAKE_CXXFLAGS += -std=c++11
@QMAKE_ENABLE_ZEITGEIST@ QT += dbus @QMAKE_ENABLE_ZEITGEIST@ QT += dbus
@QMAKE_ENABLE_ZEITGEIST@ QMAKE_CXXFLAGS += -DUSE_ZEITGEIST @QMAKE_ENABLE_ZEITGEIST@ QMAKE_CXXFLAGS += -DUSE_ZEITGEIST

View file

@ -38,7 +38,7 @@
//#include <qx11info_x11.h> //#include <qx11info_x11.h>
#endif #endif
#include "debuglog.h" #include "log.h"
#include "smallut.h" #include "smallut.h"
#include "recoll.h" #include "recoll.h"
#include "guiutils.h" #include "guiutils.h"
@ -116,7 +116,7 @@ void logdata(const char *data)
// /// QtGuiResListPager methods: // /// QtGuiResListPager methods:
bool QtGuiResListPager::append(const string& data) bool QtGuiResListPager::append(const string& data)
{ {
LOGDEB2(("QtGuiReslistPager::appendString : %s\n", data.c_str())); LOGDEB2("QtGuiReslistPager::appendString : " << (data) << "\n" );
logdata(data.c_str()); logdata(data.c_str());
m_reslist->append(QString::fromUtf8(data.c_str())); m_reslist->append(QString::fromUtf8(data.c_str()));
return true; return true;
@ -125,8 +125,7 @@ bool QtGuiResListPager::append(const string& data)
bool QtGuiResListPager::append(const string& data, int docnum, bool QtGuiResListPager::append(const string& data, int docnum,
const Rcl::Doc&) const Rcl::Doc&)
{ {
LOGDEB2(("QtGuiReslistPager::appendDoc: blockCount %d, %s\n", LOGDEB2("QtGuiReslistPager::appendDoc: blockCount " << (m_reslist->document()->blockCount()) << ", " << (data) << "\n" );
m_reslist->document()->blockCount(), data.c_str()));
logdata(data.c_str()); logdata(data.c_str());
#ifdef RESLIST_TEXTBROWSER #ifdef RESLIST_TEXTBROWSER
int blkcnt0 = m_reslist->document()->blockCount(); int blkcnt0 = m_reslist->document()->blockCount();
@ -208,7 +207,7 @@ void QtGuiResListPager::suggest(const vector<string>uterms,
if (noaspell) if (noaspell)
return; return;
if (!aspell) { if (!aspell) {
LOGERR(("QtGuiResListPager:: aspell not initialized\n")); LOGERR("QtGuiResListPager:: aspell not initialized\n" );
return; return;
} }
@ -225,8 +224,7 @@ void QtGuiResListPager::suggest(const vector<string>uterms,
// frequencies and propose something anyway if a possible // frequencies and propose something anyway if a possible
// variation is much more common (as google does) ? // variation is much more common (as google does) ?
if (!aspell->suggest(*rcldb, *uit, asuggs, reason)) { if (!aspell->suggest(*rcldb, *uit, asuggs, reason)) {
LOGERR(("QtGuiResListPager::suggest: aspell failed: %s\n", LOGERR("QtGuiResListPager::suggest: aspell failed: " << (reason) << "\n" );
reason.c_str()));
continue; continue;
} }
@ -261,16 +259,15 @@ string QtGuiResListPager::iconUrl(RclConfig *config, Rcl::Doc& doc)
ConfIndexer::docsToPaths(docs, paths); ConfIndexer::docsToPaths(docs, paths);
if (!paths.empty()) { if (!paths.empty()) {
string path; string path;
LOGDEB0(("ResList::iconUrl: source path [%s]\n", paths[0].c_str())); LOGDEB0("ResList::iconUrl: source path [" << (paths[0]) << "]\n" );
if (thumbPathForUrl(cstr_fileu + paths[0], 128, path)) { if (thumbPathForUrl(cstr_fileu + paths[0], 128, path)) {
LOGDEB0(("ResList::iconUrl: icon path [%s]\n", path.c_str())); LOGDEB0("ResList::iconUrl: icon path [" << (path) << "]\n" );
return cstr_fileu + path; return cstr_fileu + path;
} else { } else {
LOGDEB0(("ResList::iconUrl: no icon: path [%s]\n", LOGDEB0("ResList::iconUrl: no icon: path [" << (path) << "]\n" );
path.c_str()));
} }
} else { } else {
LOGDEB(("ResList::iconUrl: docsToPaths failed\n")); LOGDEB("ResList::iconUrl: docsToPaths failed\n" );
} }
} }
return ResListPager::iconUrl(config, doc); return ResListPager::iconUrl(config, doc);
@ -286,7 +283,7 @@ public:
string s1, s2; string s1, s2;
stringsToString<vector<string> >(m_hdata->groups[idx], s1); stringsToString<vector<string> >(m_hdata->groups[idx], s1);
stringsToString<vector<string> >(m_hdata->ugroups[m_hdata->grpsugidx[idx]], s2); stringsToString<vector<string> >(m_hdata->ugroups[m_hdata->grpsugidx[idx]], s2);
LOGDEB(("Reslist startmatch: group %s user group %s\n", s1.c_str(), s2.c_str())); LOGDEB("Reslist startmatch: group " << (s1) << " user group " << (s2) << "\n" );
} }
return string("<span class='rclmatch' style='color: ") return string("<span class='rclmatch' style='color: ")
@ -310,7 +307,7 @@ ResList::ResList(QWidget* parent, const char* name)
else else
setObjectName(name); setObjectName(name);
#ifdef RESLIST_TEXTBROWSER #ifdef RESLIST_TEXTBROWSER
LOGDEB(("Reslist: using QTextBrowser\n")); LOGDEB("Reslist: using QTextBrowser\n" );
setReadOnly(TRUE); setReadOnly(TRUE);
setUndoRedoEnabled(FALSE); setUndoRedoEnabled(FALSE);
setOpenLinks(FALSE); setOpenLinks(FALSE);
@ -319,7 +316,7 @@ ResList::ResList(QWidget* parent, const char* name)
connect(this, SIGNAL(anchorClicked(const QUrl &)), connect(this, SIGNAL(anchorClicked(const QUrl &)),
this, SLOT(linkWasClicked(const QUrl &))); this, SLOT(linkWasClicked(const QUrl &)));
#else #else
LOGDEB(("Reslist: using QWebView\n")); LOGDEB("Reslist: using QWebView\n" );
// signals and slots connections // signals and slots connections
connect(this, SIGNAL(linkClicked(const QUrl &)), connect(this, SIGNAL(linkClicked(const QUrl &)),
this, SLOT(linkWasClicked(const QUrl &))); this, SLOT(linkWasClicked(const QUrl &)));
@ -426,7 +423,7 @@ extern "C" int XFlush(void *);
void ResList::setDocSource(STD_SHARED_PTR<DocSequence> nsource) void ResList::setDocSource(STD_SHARED_PTR<DocSequence> nsource)
{ {
LOGDEB(("ResList::setDocSource()\n")); LOGDEB("ResList::setDocSource()\n" );
m_source = STD_SHARED_PTR<DocSequence>(new DocSource(theconfig, nsource)); m_source = STD_SHARED_PTR<DocSequence>(new DocSource(theconfig, nsource));
} }
@ -434,7 +431,7 @@ void ResList::setDocSource(STD_SHARED_PTR<DocSequence> nsource)
// re-read the results. // re-read the results.
void ResList::readDocSource() void ResList::readDocSource()
{ {
LOGDEB(("ResList::readDocSource()\n")); LOGDEB("ResList::readDocSource()\n" );
resetView(); resetView();
if (!m_source) if (!m_source)
return; return;
@ -449,7 +446,7 @@ void ResList::readDocSource()
void ResList::resetList() void ResList::resetList()
{ {
LOGDEB(("ResList::resetList()\n")); LOGDEB("ResList::resetList()\n" );
setDocSource(STD_SHARED_PTR<DocSequence>()); setDocSource(STD_SHARED_PTR<DocSequence>());
resetView(); resetView();
} }
@ -513,15 +510,14 @@ int ResList::docnumfromparnum(int block)
// Get range of paragraph numbers which make up the result for document number // Get range of paragraph numbers which make up the result for document number
pair<int,int> ResList::parnumfromdocnum(int docnum) pair<int,int> ResList::parnumfromdocnum(int docnum)
{ {
LOGDEB(("parnumfromdocnum: docnum %d\n", docnum)); LOGDEB("parnumfromdocnum: docnum " << (docnum) << "\n" );
if (m_pager->pageNumber() < 0) { if (m_pager->pageNumber() < 0) {
LOGDEB(("parnumfromdocnum: no page return -1,-1\n")); LOGDEB("parnumfromdocnum: no page return -1,-1\n" );
return pair<int,int>(-1,-1); return pair<int,int>(-1,-1);
} }
int winfirst = pageFirstDocNum(); int winfirst = pageFirstDocNum();
if (docnum - winfirst < 0) { if (docnum - winfirst < 0) {
LOGDEB(("parnumfromdocnum: docnum %d < winfirst %d return -1,-1\n", LOGDEB("parnumfromdocnum: docnum " << (docnum) << " < winfirst " << (winfirst) << " return -1,-1\n" );
docnum, winfirst));
return pair<int,int>(-1,-1); return pair<int,int>(-1,-1);
} }
docnum -= winfirst; docnum -= winfirst;
@ -535,11 +531,11 @@ pair<int,int> ResList::parnumfromdocnum(int docnum)
m_pageParaToReldocnums.end() && it1->second == docnum) { m_pageParaToReldocnums.end() && it1->second == docnum) {
last++; last++;
} }
LOGDEB(("parnumfromdocnum: return %d,%d\n", first, last)); LOGDEB("parnumfromdocnum: return " << (first) << "," << (last) << "\n" );
return pair<int,int>(first, last); return pair<int,int>(first, last);
} }
} }
LOGDEB(("parnumfromdocnum: not found return -1,-1\n")); LOGDEB("parnumfromdocnum: not found return -1,-1\n" );
return pair<int,int>(-1,-1); return pair<int,int>(-1,-1);
} }
#endif // TEXTBROWSER #endif // TEXTBROWSER
@ -550,8 +546,7 @@ pair<int,int> ResList::parnumfromdocnum(int docnum)
// result in a one-page change. // result in a one-page change.
bool ResList::getDoc(int docnum, Rcl::Doc &doc) bool ResList::getDoc(int docnum, Rcl::Doc &doc)
{ {
LOGDEB(("ResList::getDoc: docnum %d winfirst %d\n", docnum, LOGDEB("ResList::getDoc: docnum " << (docnum) << " winfirst " << (pageFirstDocNum()) << "\n" );
pageFirstDocNum()));
int winfirst = pageFirstDocNum(); int winfirst = pageFirstDocNum();
int winlast = m_pager->pageLastDocNum(); int winlast = m_pager->pageLastDocNum();
if (docnum < 0 || winfirst < 0 || winlast < 0) if (docnum < 0 || winfirst < 0 || winlast < 0)
@ -641,8 +636,7 @@ void ResList::resPageDownOrNext()
#ifdef RESLIST_TEXTBROWSER #ifdef RESLIST_TEXTBROWSER
int vpos = verticalScrollBar()->value(); int vpos = verticalScrollBar()->value();
verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepAdd); verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepAdd);
LOGDEB(("ResList::resPageDownOrNext: vpos before %d, after %d\n", LOGDEB("ResList::resPageDownOrNext: vpos before " << (vpos) << ", after " << (verticalScrollBar()->value()) << "\n" );
vpos, verticalScrollBar()->value()));
if (vpos == verticalScrollBar()->value()) if (vpos == verticalScrollBar()->value())
resultPageNext(); resultPageNext();
#else #else
@ -675,9 +669,9 @@ bool ResList::scrollIsAtBottom()
int max = frame->scrollBarMaximum(Qt::Vertical); int max = frame->scrollBarMaximum(Qt::Vertical);
int cur = frame->scrollBarValue(Qt::Vertical); int cur = frame->scrollBarValue(Qt::Vertical);
ret = (max != 0) && (cur == max); ret = (max != 0) && (cur == max);
LOGDEB2(("Scrollatbottom: cur %d max %d\n", cur, max)); LOGDEB2("Scrollatbottom: cur " << (cur) << " max " << (max) << "\n" );
} }
LOGDEB2(("scrollIsAtBottom: returning %d\n", ret)); LOGDEB2("scrollIsAtBottom: returning " << (ret) << "\n" );
return ret; return ret;
#endif #endif
} }
@ -694,10 +688,10 @@ bool ResList::scrollIsAtTop()
} else { } else {
int cur = frame->scrollBarValue(Qt::Vertical); int cur = frame->scrollBarValue(Qt::Vertical);
int min = frame->scrollBarMinimum(Qt::Vertical); int min = frame->scrollBarMinimum(Qt::Vertical);
LOGDEB(("Scrollattop: cur %d min %d\n", cur, min)); LOGDEB("Scrollattop: cur " << (cur) << " min " << (min) << "\n" );
ret = (cur == min); ret = (cur == min);
} }
LOGDEB2(("scrollIsAtTop: returning %d\n", ret)); LOGDEB2("scrollIsAtTop: returning " << (ret) << "\n" );
return ret; return ret;
#endif #endif
} }
@ -738,8 +732,7 @@ void ResList::resultPageFor(int docnum)
void ResList::append(const QString &text) void ResList::append(const QString &text)
{ {
LOGDEB2(("QtGuiReslistPager::appendQString : %s\n", LOGDEB2("QtGuiReslistPager::appendQString : " << ((const char*)text.toUtf8()) << "\n" );
(const char*)text.toUtf8()));
#ifdef RESLIST_TEXTBROWSER #ifdef RESLIST_TEXTBROWSER
QTextBrowser::append(text); QTextBrowser::append(text);
#else #else
@ -757,9 +750,7 @@ void ResList::displayPage()
setHtml(m_text); setHtml(m_text);
#endif #endif
LOGDEB0(("ResList::displayPg: hasNext %d atBot %d hasPrev %d at Top %d \n", LOGDEB0("ResList::displayPg: hasNext " << (m_pager->hasPrev()) << " atBot " << (scrollIsAtBottom()) << " hasPrev " << (m_pager->hasNext()) << " at Top " << (scrollIsAtTop()) << " \n" );
m_pager->hasPrev(), scrollIsAtBottom(),
m_pager->hasNext(), scrollIsAtTop()));
setupArrows(); setupArrows();
// Possibly color paragraph of current preview if any // Possibly color paragraph of current preview if any
@ -769,7 +760,7 @@ void ResList::displayPage()
// Color paragraph (if any) of currently visible preview // Color paragraph (if any) of currently visible preview
void ResList::previewExposed(int docnum) void ResList::previewExposed(int docnum)
{ {
LOGDEB(("ResList::previewExposed: doc %d\n", docnum)); LOGDEB("ResList::previewExposed: doc " << (docnum) << "\n" );
// Possibly erase old one to white // Possibly erase old one to white
if (m_curPvDoc != -1) { if (m_curPvDoc != -1) {
@ -788,14 +779,13 @@ void ResList::previewExposed(int docnum)
#else #else
QString sel = QString sel =
QString("div[rcldocnum=\"%1\"]").arg(m_curPvDoc - pageFirstDocNum()); QString("div[rcldocnum=\"%1\"]").arg(m_curPvDoc - pageFirstDocNum());
LOGDEB2(("Searching for element, selector: [%s]\n", LOGDEB2("Searching for element, selector: [" << (qs2utf8s(sel)) << "]\n" );
qs2utf8s(sel).c_str()));
QWebElement elt = page()->mainFrame()->findFirstElement(sel); QWebElement elt = page()->mainFrame()->findFirstElement(sel);
if (!elt.isNull()) { if (!elt.isNull()) {
LOGDEB2(("Found\n")); LOGDEB2("Found\n" );
elt.removeAttribute("style"); elt.removeAttribute("style");
} else { } else {
LOGDEB2(("Not Found\n")); LOGDEB2("Not Found\n" );
} }
#endif #endif
m_curPvDoc = -1; m_curPvDoc = -1;
@ -825,14 +815,13 @@ void ResList::previewExposed(int docnum)
#else #else
QString sel = QString sel =
QString("div[rcldocnum=\"%1\"]").arg(docnum - pageFirstDocNum()); QString("div[rcldocnum=\"%1\"]").arg(docnum - pageFirstDocNum());
LOGDEB2(("Searching for element, selector: [%s]\n", LOGDEB2("Searching for element, selector: [" << (qs2utf8s(sel)) << "]\n" );
qs2utf8s(sel).c_str()));
QWebElement elt = page()->mainFrame()->findFirstElement(sel); QWebElement elt = page()->mainFrame()->findFirstElement(sel);
if (!elt.isNull()) { if (!elt.isNull()) {
LOGDEB2(("Found\n")); LOGDEB2("Found\n" );
elt.setAttribute("style", "background: LightBlue;}"); elt.setAttribute("style", "background: LightBlue;}");
} else { } else {
LOGDEB2(("Not Found\n")); LOGDEB2("Not Found\n" );
} }
#endif #endif
} }
@ -864,7 +853,7 @@ void ResList::showQueryDetails()
void ResList::linkWasClicked(const QUrl &url) void ResList::linkWasClicked(const QUrl &url)
{ {
string ascurl = qs2utf8s(url.toString()); string ascurl = qs2utf8s(url.toString());
LOGDEB(("ResList::linkWasClicked: [%s]\n", ascurl.c_str())); LOGDEB("ResList::linkWasClicked: [" << (ascurl) << "]\n" );
int what = ascurl[0]; int what = ascurl[0];
switch (what) { switch (what) {
@ -877,7 +866,7 @@ void ResList::linkWasClicked(const QUrl &url)
int i = atoi(ascurl.c_str()+1) - 1; int i = atoi(ascurl.c_str()+1) - 1;
Rcl::Doc doc; Rcl::Doc doc;
if (!getDoc(i, doc)) { if (!getDoc(i, doc)) {
LOGERR(("ResList::linkWasClicked: can't get doc for %d\n", i)); LOGERR("ResList::linkWasClicked: can't get doc for " << (i) << "\n" );
return; return;
} }
emit(showSnippets(doc)); emit(showSnippets(doc));
@ -892,7 +881,7 @@ void ResList::linkWasClicked(const QUrl &url)
int i = atoi(ascurl.c_str()+1) - 1; int i = atoi(ascurl.c_str()+1) - 1;
Rcl::Doc doc; Rcl::Doc doc;
if (!getDoc(i, doc)) { if (!getDoc(i, doc)) {
LOGERR(("ResList::linkWasClicked: can't get doc for %d\n", i)); LOGERR("ResList::linkWasClicked: can't get doc for " << (i) << "\n" );
return; return;
} }
vector<Rcl::Doc> dups; vector<Rcl::Doc> dups;
@ -908,7 +897,7 @@ void ResList::linkWasClicked(const QUrl &url)
int i = atoi(ascurl.c_str()+1) - 1; int i = atoi(ascurl.c_str()+1) - 1;
Rcl::Doc doc; Rcl::Doc doc;
if (!getDoc(i, doc)) { if (!getDoc(i, doc)) {
LOGERR(("ResList::linkWasClicked: can't get doc for %d\n", i)); LOGERR("ResList::linkWasClicked: can't get doc for " << (i) << "\n" );
return; return;
} }
emit editRequested(ResultPopup::getParent(STD_SHARED_PTR<DocSequence>(), emit editRequested(ResultPopup::getParent(STD_SHARED_PTR<DocSequence>(),
@ -930,7 +919,7 @@ void ResList::linkWasClicked(const QUrl &url)
int i = atoi(ascurl.c_str()+1) - 1; int i = atoi(ascurl.c_str()+1) - 1;
Rcl::Doc doc; Rcl::Doc doc;
if (!getDoc(i, doc)) { if (!getDoc(i, doc)) {
LOGERR(("ResList::linkWasClicked: can't get doc for %d\n", i)); LOGERR("ResList::linkWasClicked: can't get doc for " << (i) << "\n" );
return; return;
} }
if (what == 'P') { if (what == 'P') {
@ -990,18 +979,18 @@ void ResList::linkWasClicked(const QUrl &url)
break; break;
default: default:
LOGERR(("ResList::linkWasClicked: bad link [%s]\n", ascurl.c_str())); LOGERR("ResList::linkWasClicked: bad link [" << (ascurl) << "]\n" );
break;// ?? break;// ??
} }
} }
void ResList::createPopupMenu(const QPoint& pos) void ResList::createPopupMenu(const QPoint& pos)
{ {
LOGDEB(("ResList::createPopupMenu(%d, %d)\n", pos.x(), pos.y())); LOGDEB("ResList::createPopupMenu(" << (pos.x()) << ", " << (pos.y()) << ")\n" );
#ifdef RESLIST_TEXTBROWSER #ifdef RESLIST_TEXTBROWSER
QTextCursor cursor = cursorForPosition(pos); QTextCursor cursor = cursorForPosition(pos);
int blocknum = cursor.blockNumber(); int blocknum = cursor.blockNumber();
LOGDEB(("ResList::createPopupMenu(): block %d\n", blocknum)); LOGDEB("ResList::createPopupMenu(): block " << (blocknum) << "\n" );
m_popDoc = docnumfromparnum(blocknum); m_popDoc = docnumfromparnum(blocknum);
#else #else
QWebHitTestResult htr = page()->mainFrame()->hitTestContent(pos); QWebHitTestResult htr = page()->mainFrame()->hitTestContent(pos);
@ -1122,3 +1111,4 @@ int ResList::pageFirstDocNum()
{ {
return m_pager->pageFirstDocNum(); return m_pager->pageFirstDocNum();
} }

View file

@ -20,7 +20,7 @@
#include <qmenu.h> #include <qmenu.h>
#include <qclipboard.h> #include <qclipboard.h>
#include "debuglog.h" #include "log.h"
#include "smallut.h" #include "smallut.h"
#include "recoll.h" #include "recoll.h"
#include "docseq.h" #include "docseq.h"
@ -33,10 +33,8 @@ QMenu *create(QWidget *me, int opts, STD_SHARED_PTR<DocSequence> source, Rcl::Do
{ {
QMenu *popup = new QMenu(me); QMenu *popup = new QMenu(me);
LOGDEB(("ResultPopup::create: opts %x haspages %d %s %s\n", opts, LOGDEB("ResultPopup::create: opts " << (opts) << " haspages " << (doc.haspages) << " " << (source ? "Source not null" : "Source is Null") << " " << (source ? (source->snippetsCapable() ?
doc.haspages, source ? "Source not null" : "Source is Null", "snippetsCapable" : "not snippetsCapable") : "") << "\n" );
source ? (source->snippetsCapable() ?
"snippetsCapable" : "not snippetsCapable") : ""));
string apptag; string apptag;
doc.getmeta(Rcl::Doc::keyapptg, &apptag); doc.getmeta(Rcl::Doc::keyapptg, &apptag);
@ -175,3 +173,4 @@ void copyURL(const Rcl::Doc &doc)
} }
} }

View file

@ -37,7 +37,7 @@
#include "recoll.h" #include "recoll.h"
#include MEMORY_INCLUDE #include MEMORY_INCLUDE
#include "docseq.h" #include "docseq.h"
#include "debuglog.h" #include "log.h"
#include "restable.h" #include "restable.h"
#include "guiutils.h" #include "guiutils.h"
#include "reslistpager.h" #include "reslistpager.h"
@ -271,7 +271,7 @@ RecollModel::RecollModel(const QStringList fields, QObject *parent)
int RecollModel::rowCount(const QModelIndex&) const int RecollModel::rowCount(const QModelIndex&) const
{ {
LOGDEB2(("RecollModel::rowCount\n")); LOGDEB2("RecollModel::rowCount\n" );
if (!m_source) if (!m_source)
return 0; return 0;
return m_source->getResCnt(); return m_source->getResCnt();
@ -279,20 +279,20 @@ int RecollModel::rowCount(const QModelIndex&) const
int RecollModel::columnCount(const QModelIndex&) const int RecollModel::columnCount(const QModelIndex&) const
{ {
LOGDEB2(("RecollModel::columnCount\n")); LOGDEB2("RecollModel::columnCount\n" );
return m_fields.size(); return m_fields.size();
} }
void RecollModel::readDocSource() void RecollModel::readDocSource()
{ {
LOGDEB(("RecollModel::readDocSource()\n")); LOGDEB("RecollModel::readDocSource()\n" );
beginResetModel(); beginResetModel();
endResetModel(); endResetModel();
} }
void RecollModel::setDocSource(STD_SHARED_PTR<DocSequence> nsource) void RecollModel::setDocSource(STD_SHARED_PTR<DocSequence> nsource)
{ {
LOGDEB(("RecollModel::setDocSource\n")); LOGDEB("RecollModel::setDocSource\n" );
if (!nsource) { if (!nsource) {
m_source = STD_SHARED_PTR<DocSequence>(); m_source = STD_SHARED_PTR<DocSequence>();
} else { } else {
@ -317,7 +317,7 @@ void RecollModel::deleteColumn(int col)
void RecollModel::addColumn(int col, const string& field) void RecollModel::addColumn(int col, const string& field)
{ {
LOGDEB(("AddColumn: col %d fld [%s]\n", col, field.c_str())); LOGDEB("AddColumn: col " << (col) << " fld [" << (field) << "]\n" );
if (col >= 0 && col < int(m_fields.size())) { if (col >= 0 && col < int(m_fields.size())) {
col++; col++;
vector<string>::iterator it = m_fields.begin(); vector<string>::iterator it = m_fields.begin();
@ -335,8 +335,7 @@ void RecollModel::addColumn(int col, const string& field)
QVariant RecollModel::headerData(int idx, Qt::Orientation orientation, QVariant RecollModel::headerData(int idx, Qt::Orientation orientation,
int role) const int role) const
{ {
LOGDEB2(("RecollModel::headerData: idx %d orientation %s role %d\n", LOGDEB2("RecollModel::headerData: idx " << (idx) << " orientation " << (orientation == Qt::Vertical ? "vertical":"horizontal") << " role " << (role) << "\n" );
idx, orientation == Qt::Vertical ? "vertical":"horizontal", role));
if (orientation == Qt::Vertical && role == Qt::DisplayRole) { if (orientation == Qt::Vertical && role == Qt::DisplayRole) {
return idx; return idx;
} }
@ -354,8 +353,7 @@ QVariant RecollModel::headerData(int idx, Qt::Orientation orientation,
QVariant RecollModel::data(const QModelIndex& index, int role) const QVariant RecollModel::data(const QModelIndex& index, int role) const
{ {
LOGDEB2(("RecollModel::data: row %d col %d role %d\n", index.row(), LOGDEB2("RecollModel::data: row " << (index.row()) << " col " << (index.column()) << " role " << (role) << "\n" );
index.column(), role));
if (!m_source || role != Qt::DisplayRole || !index.isValid() || if (!m_source || role != Qt::DisplayRole || !index.isValid() ||
index.column() >= int(m_fields.size())) { index.column() >= int(m_fields.size())) {
return QVariant(); return QVariant();
@ -410,7 +408,7 @@ void RecollModel::sort(int column, Qt::SortOrder order)
{ {
if (m_ignoreSort) if (m_ignoreSort)
return; return;
LOGDEB(("RecollModel::sort(%d, %d)\n", column, int(order))); LOGDEB("RecollModel::sort(" << (column) << ", " << (int(order)) << ")\n" );
DocSeqSortSpec spec; DocSeqSortSpec spec;
if (column >= 0 && column < int(m_fields.size())) { if (column >= 0 && column < int(m_fields.size())) {
@ -592,7 +590,7 @@ int ResTable::getDetailDocNumOrTopRow()
void ResTable::makeRowVisible(int row) void ResTable::makeRowVisible(int row)
{ {
LOGDEB(("ResTable::showRow(%d)\n", row)); LOGDEB("ResTable::showRow(" << (row) << ")\n" );
QModelIndex modelIndex = m_model->index(row, 0); QModelIndex modelIndex = m_model->index(row, 0);
tableView->scrollTo(modelIndex, QAbstractItemView::PositionAtTop); tableView->scrollTo(modelIndex, QAbstractItemView::PositionAtTop);
tableView->selectionModel()->clear(); tableView->selectionModel()->clear();
@ -611,7 +609,7 @@ void ResTable::saveColState()
QHeaderView *header = tableView->horizontalHeader(); QHeaderView *header = tableView->horizontalHeader();
const vector<string>& vf = m_model->getFields(); const vector<string>& vf = m_model->getFields();
if (!header) { if (!header) {
LOGERR(("ResTable::saveColState: no table header ??\n")); LOGERR("ResTable::saveColState: no table header ??\n" );
return; return;
} }
@ -622,7 +620,7 @@ void ResTable::saveColState()
for (int vi = 0; vi < header->count(); vi++) { for (int vi = 0; vi < header->count(); vi++) {
int li = header->logicalIndex(vi); int li = header->logicalIndex(vi);
if (li < 0 || li >= int(vf.size())) { if (li < 0 || li >= int(vf.size())) {
LOGERR(("saveColState: logical index beyond list size!\n")); LOGERR("saveColState: logical index beyond list size!\n" );
continue; continue;
} }
newfields.push_back(QString::fromUtf8(vf[li].c_str())); newfields.push_back(QString::fromUtf8(vf[li].c_str()));
@ -634,8 +632,7 @@ void ResTable::saveColState()
void ResTable::onTableView_currentChanged(const QModelIndex& index) void ResTable::onTableView_currentChanged(const QModelIndex& index)
{ {
LOGDEB2(("ResTable::onTableView_currentChanged(%d, %d)\n", LOGDEB2("ResTable::onTableView_currentChanged(" << (index.row()) << ", " << (index.column()) << ")\n" );
index.row(), index.column()));
if (!m_model || !m_model->getDocSource()) if (!m_model || !m_model->getDocSource())
return; return;
@ -653,21 +650,20 @@ void ResTable::onTableView_currentChanged(const QModelIndex& index)
void ResTable::on_tableView_entered(const QModelIndex& index) void ResTable::on_tableView_entered(const QModelIndex& index)
{ {
LOGDEB2(("ResTable::on_tableView_entered(%d, %d)\n", LOGDEB2("ResTable::on_tableView_entered(" << (index.row()) << ", " << (index.column()) << ")\n" );
index.row(), index.column()));
if (!tableView->selectionModel()->hasSelection()) if (!tableView->selectionModel()->hasSelection())
onTableView_currentChanged(index); onTableView_currentChanged(index);
} }
void ResTable::takeFocus() void ResTable::takeFocus()
{ {
// LOGDEB(("resTable: take focus\n")); // LOGDEB("resTable: take focus\n" );
tableView->setFocus(Qt::ShortcutFocusReason); tableView->setFocus(Qt::ShortcutFocusReason);
} }
void ResTable::setDocSource(STD_SHARED_PTR<DocSequence> nsource) void ResTable::setDocSource(STD_SHARED_PTR<DocSequence> nsource)
{ {
LOGDEB(("ResTable::setDocSource\n")); LOGDEB("ResTable::setDocSource\n" );
if (m_model) if (m_model)
m_model->setDocSource(nsource); m_model->setDocSource(nsource);
if (m_pager) if (m_pager)
@ -679,13 +675,13 @@ void ResTable::setDocSource(STD_SHARED_PTR<DocSequence> nsource)
void ResTable::resetSource() void ResTable::resetSource()
{ {
LOGDEB(("ResTable::resetSource\n")); LOGDEB("ResTable::resetSource\n" );
setDocSource(STD_SHARED_PTR<DocSequence>()); setDocSource(STD_SHARED_PTR<DocSequence>());
} }
void ResTable::saveAsCSV() void ResTable::saveAsCSV()
{ {
LOGDEB(("ResTable::saveAsCSV\n")); LOGDEB("ResTable::saveAsCSV\n" );
if (!m_model) if (!m_model)
return; return;
QString s = QString s =
@ -709,8 +705,7 @@ void ResTable::saveAsCSV()
// This is called when the sort order is changed from another widget // This is called when the sort order is changed from another widget
void ResTable::onSortDataChanged(DocSeqSortSpec spec) void ResTable::onSortDataChanged(DocSeqSortSpec spec)
{ {
LOGDEB(("ResTable::onSortDataChanged: [%s] desc %d\n", LOGDEB("ResTable::onSortDataChanged: [" << (spec.field) << "] desc " << (int(spec.desc)) << "\n" );
spec.field.c_str(), int(spec.desc)));
QHeaderView *header = tableView->horizontalHeader(); QHeaderView *header = tableView->horizontalHeader();
if (!header || !m_model) if (!header || !m_model)
return; return;
@ -734,7 +729,7 @@ void ResTable::onSortDataChanged(DocSeqSortSpec spec)
void ResTable::resetSort() void ResTable::resetSort()
{ {
LOGDEB(("ResTable::resetSort()\n")); LOGDEB("ResTable::resetSort()\n" );
QHeaderView *header = tableView->horizontalHeader(); QHeaderView *header = tableView->horizontalHeader();
if (header) if (header)
header->setSortIndicator(-1, Qt::AscendingOrder); header->setSortIndicator(-1, Qt::AscendingOrder);
@ -745,7 +740,7 @@ void ResTable::resetSort()
void ResTable::readDocSource(bool resetPos) void ResTable::readDocSource(bool resetPos)
{ {
LOGDEB(("ResTable::readDocSource(%d)\n", int(resetPos))); LOGDEB("ResTable::readDocSource(" << (int(resetPos)) << ")\n" );
if (resetPos) if (resetPos)
tableView->verticalScrollBar()->setSliderPosition(0); tableView->verticalScrollBar()->setSliderPosition(0);
@ -761,7 +756,7 @@ void ResTable::linkWasClicked(const QUrl &url)
} }
QString s = url.toString(); QString s = url.toString();
const char *ascurl = s.toUtf8(); const char *ascurl = s.toUtf8();
LOGDEB(("ResTable::linkWasClicked: [%s]\n", ascurl)); LOGDEB("ResTable::linkWasClicked: [" << (ascurl) << "]\n" );
int i = atoi(ascurl+1) -1; int i = atoi(ascurl+1) -1;
int what = ascurl[0]; int what = ascurl[0];
@ -821,7 +816,7 @@ void ResTable::linkWasClicked(const QUrl &url)
break; break;
default: default:
LOGERR(("ResTable::linkWasClicked: bad link [%s]\n", ascurl)); LOGERR("ResTable::linkWasClicked: bad link [" << (ascurl) << "]\n" );
break;// ?? break;// ??
} }
} }
@ -844,7 +839,7 @@ void ResTable::onDoubleClick(const QModelIndex& index)
void ResTable::createPopupMenu(const QPoint& pos) void ResTable::createPopupMenu(const QPoint& pos)
{ {
LOGDEB(("ResTable::createPopupMenu: m_detaildocnum %d\n", m_detaildocnum)); LOGDEB("ResTable::createPopupMenu: m_detaildocnum " << (m_detaildocnum) << "\n" );
if (m_detaildocnum >= 0 && m_model) { if (m_detaildocnum >= 0 && m_model) {
int opts = m_ismainres? ResultPopup::isMain : 0; int opts = m_ismainres? ResultPopup::isMain : 0;
@ -975,7 +970,7 @@ void ResTable::menuShowSubDocs()
void ResTable::createHeaderPopupMenu(const QPoint& pos) void ResTable::createHeaderPopupMenu(const QPoint& pos)
{ {
LOGDEB(("ResTable::createHeaderPopupMenu(%d, %d)\n", pos.x(), pos.y())); LOGDEB("ResTable::createHeaderPopupMenu(" << (pos.x()) << ", " << (pos.y()) << ")\n" );
QHeaderView *header = tableView->horizontalHeader(); QHeaderView *header = tableView->horizontalHeader();
if (!header || !m_model) if (!header || !m_model)
return; return;
@ -1021,7 +1016,7 @@ void ResTable::addColumn()
if (!m_model) if (!m_model)
return; return;
QAction *action = (QAction *)sender(); QAction *action = (QAction *)sender();
LOGDEB(("addColumn: text %s, data %s\n", qs2utf8s(action->text()).c_str(), LOGDEB("addColumn: text " << (qs2utf8s(action->text())) << ", data " << (qs2utf8s(action->data().toString())) << "\n" );
qs2utf8s(action->data().toString()).c_str()));
m_model->addColumn(m_popcolumn, qs2utf8s(action->data().toString())); m_model->addColumn(m_popcolumn, qs2utf8s(action->data().toString()));
} }

View file

@ -17,8 +17,7 @@
#include "autoconfig.h" #include "autoconfig.h"
#include "recoll.h" #include "recoll.h"
#include "debuglog.h" #include "log.h"
#include "searchclause_w.h" #include "searchclause_w.h"
#include <qvariant.h> #include <qvariant.h>
@ -142,7 +141,7 @@ SearchDataClause *SearchClauseW::getClause()
void SearchClauseW::setFromClause(SearchDataClauseSimple *cl) void SearchClauseW::setFromClause(SearchDataClauseSimple *cl)
{ {
LOGDEB(("SearchClauseW::setFromClause\n")); LOGDEB("SearchClauseW::setFromClause\n" );
switch(cl->getTp()) { switch(cl->getTp()) {
case SCLT_OR: if (cl->getexclude()) tpChange(2); else tpChange(0); break; case SCLT_OR: if (cl->getexclude()) tpChange(2); else tpChange(0); break;
case SCLT_AND: tpChange(1); break; case SCLT_AND: tpChange(1); break;
@ -151,7 +150,7 @@ void SearchClauseW::setFromClause(SearchDataClauseSimple *cl)
case SCLT_FILENAME: tpChange(5); break; case SCLT_FILENAME: tpChange(5); break;
default: return; default: return;
} }
LOGDEB(("SearchClauseW::setFromClause: calling erase\n")); LOGDEB("SearchClauseW::setFromClause: calling erase\n" );
clear(); clear();
QString text = QString::fromUtf8(cl->gettext().c_str()); QString text = QString::fromUtf8(cl->gettext().c_str());
@ -220,3 +219,4 @@ void SearchClauseW::tpChange(int index)
fldCMB->show(); fldCMB->show();
} }
} }

View file

@ -32,7 +32,7 @@ using namespace std;
#endif #endif
#include <QShortcut> #include <QShortcut>
#include "debuglog.h" #include "log.h"
#include "recoll.h" #include "recoll.h"
#include "snippets_w.h" #include "snippets_w.h"
#include "guiutils.h" #include "guiutils.h"
@ -170,7 +170,7 @@ void SnippetsW::init()
} }
list<string> lr; list<string> lr;
if (!g_hiliter.plaintorich(it->snippet, lr, hdata)) { if (!g_hiliter.plaintorich(it->snippet, lr, hdata)) {
LOGDEB1(("No match for [%s]\n", it->snippet.c_str())); LOGDEB1("No match for [" << (it->snippet) << "]\n" );
continue; continue;
} }
nomatch = false; nomatch = false;
@ -238,7 +238,7 @@ void SnippetsW::slotSearchTextChanged(const QString& txt)
void SnippetsW::linkWasClicked(const QUrl &url) void SnippetsW::linkWasClicked(const QUrl &url)
{ {
string ascurl = (const char *)url.toString().toUtf8(); string ascurl = (const char *)url.toString().toUtf8();
LOGDEB(("Snippets::linkWasClicked: [%s]\n", ascurl.c_str())); LOGDEB("Snippets::linkWasClicked: [" << (ascurl) << "]\n" );
if (ascurl.size() > 3) { if (ascurl.size() > 3) {
int what = ascurl[0]; int what = ascurl[0];
@ -259,6 +259,7 @@ void SnippetsW::linkWasClicked(const QUrl &url)
} }
} }
} }
LOGERR(("Snippets::linkWasClicked: bad link [%s]\n", ascurl.c_str())); LOGERR("Snippets::linkWasClicked: bad link [" << (ascurl) << "]\n" );
} }

View file

@ -35,7 +35,7 @@
#include <QClipboard> #include <QClipboard>
#include <QKeyEvent> #include <QKeyEvent>
#include "debuglog.h" #include "log.h"
#include "recoll.h" #include "recoll.h"
#include "spell_w.h" #include "spell_w.h"
#include "guiutils.h" #include "guiutils.h"
@ -147,7 +147,7 @@ void SpellW::doExpand()
string reason; string reason;
if (!maybeOpenDb(reason)) { if (!maybeOpenDb(reason)) {
QMessageBox::critical(0, "Recoll", QString(reason.c_str())); QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
LOGDEB(("SpellW::doExpand: db error: %s\n", reason.c_str())); LOGDEB("SpellW::doExpand: db error: " << (reason) << "\n" );
return; return;
} }
@ -178,7 +178,7 @@ void SpellW::doExpand()
string l_stemlang = qs2utf8s(stemLangCMB->currentText()); string l_stemlang = qs2utf8s(stemLangCMB->currentText());
if (!rcldb->termMatch(mt, l_stemlang, expr, res, maxexpand)) { if (!rcldb->termMatch(mt, l_stemlang, expr, res, maxexpand)) {
LOGERR(("SpellW::doExpand:rcldb::termMatch failed\n")); LOGERR("SpellW::doExpand:rcldb::termMatch failed\n" );
return; return;
} }
statsLBL->setText(tr("Index: %1 documents, average length %2 terms." statsLBL->setText(tr("Index: %1 documents, average length %2 terms."
@ -192,19 +192,19 @@ void SpellW::doExpand()
#ifdef RCL_USE_ASPELL #ifdef RCL_USE_ASPELL
case TYPECMB_ASPELL: case TYPECMB_ASPELL:
{ {
LOGDEB(("SpellW::doExpand: aspelling\n")); LOGDEB("SpellW::doExpand: aspelling\n" );
if (!aspell) { if (!aspell) {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll",
tr("Aspell init failed. " tr("Aspell init failed. "
"Aspell not installed?")); "Aspell not installed?"));
LOGDEB(("SpellW::doExpand: aspell init error\n")); LOGDEB("SpellW::doExpand: aspell init error\n" );
return; return;
} }
list<string> suggs; list<string> suggs;
if (!aspell->suggest(*rcldb, expr, suggs, reason)) { if (!aspell->suggest(*rcldb, expr, suggs, reason)) {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll",
tr("Aspell expansion error. ")); tr("Aspell expansion error. "));
LOGERR(("SpellW::doExpand:suggest failed: %s\n", reason.c_str())); LOGERR("SpellW::doExpand:suggest failed: " << (reason) << "\n" );
} }
for (list<string>::const_iterator it = suggs.begin(); for (list<string>::const_iterator it = suggs.begin();
it != suggs.end(); it++) it != suggs.end(); it++)
@ -253,7 +253,7 @@ void SpellW::doExpand()
for (vector<Rcl::TermMatchEntry>::iterator it = res.entries.begin(); for (vector<Rcl::TermMatchEntry>::iterator it = res.entries.begin();
it != res.entries.end(); it++) { it != res.entries.end(); it++) {
LOGDEB2(("SpellW::expand: %6d [%s]\n", it->wcf, it->term.c_str())); LOGDEB2("SpellW::expand: " << (it->wcf) << " [" << (it->term) << "]\n" );
char num[30]; char num[30];
if (it->wcf) if (it->wcf)
sprintf(num, "%d / %d", it->docs, it->wcf); sprintf(num, "%d / %d", it->docs, it->wcf);
@ -275,7 +275,7 @@ void SpellW::showStats()
Rcl::DbStats res; Rcl::DbStats res;
if (!rcldb->dbStats(res)) { if (!rcldb->dbStats(res)) {
LOGERR(("SpellW::doExpand:rcldb::dbStats failed\n")); LOGERR("SpellW::doExpand:rcldb::dbStats failed\n" );
return; return;
} }
@ -365,7 +365,7 @@ void SpellW::showStats()
STD_SHARED_PTR<Rcl::SearchData> rq(sd); STD_SHARED_PTR<Rcl::SearchData> rq(sd);
Rcl::Query query(rcldb); Rcl::Query query(rcldb);
if (!query.setQuery(rq)) { if (!query.setQuery(rq)) {
LOGERR(("Query setup failed: %s",query.getReason().c_str())); LOGERR("Query setup failed: " << (query.getReason()) << "" );
return; return;
} }
int cnt = query.getResCnt(); int cnt = query.getResCnt();
@ -521,3 +521,4 @@ bool SpellW::eventFilter(QObject *target, QEvent *event)
} }
return false; return false;
} }

View file

@ -33,7 +33,7 @@
#include <QTimer> #include <QTimer>
#include <QCompleter> #include <QCompleter>
#include "debuglog.h" #include "log.h"
#include "guiutils.h" #include "guiutils.h"
#include "searchdata.h" #include "searchdata.h"
#include "ssearch_w.h" #include "ssearch_w.h"
@ -95,7 +95,7 @@ void SSearch::init()
void SSearch::takeFocus() void SSearch::takeFocus()
{ {
LOGDEB2(("SSearch: take focus\n")); LOGDEB2("SSearch: take focus\n" );
queryText->setFocus(Qt::ShortcutFocusReason); queryText->setFocus(Qt::ShortcutFocusReason);
// If the focus was already in the search entry, the text is not selected. // If the focus was already in the search entry, the text is not selected.
// Do it for consistency // Do it for consistency
@ -105,15 +105,14 @@ void SSearch::takeFocus()
void SSearch::timerDone() void SSearch::timerDone()
{ {
QString qs = queryText->currentText(); QString qs = queryText->currentText();
LOGDEB1(("SSearch::timerDone: qs [%s]\n", qs2utf8s(qs).c_str())); LOGDEB1("SSearch::timerDone: qs [" << (qs2utf8s(qs)) << "]\n" );
searchTextChanged(qs); searchTextChanged(qs);
} }
void SSearch::searchTextChanged(const QString& text) void SSearch::searchTextChanged(const QString& text)
{ {
QString qs = queryText->currentText(); QString qs = queryText->currentText();
LOGDEB1(("SSearch::searchTextChanged. ks %d qs [%s]\n", LOGDEB1("SSearch::searchTextChanged. ks " << (m_keystroke) << " qs [" << (qs2utf8s(text)) << "]\n" );
m_keystroke, qs2utf8s(text).c_str()));
if (text.isEmpty()) { if (text.isEmpty()) {
searchPB->setEnabled(false); searchPB->setEnabled(false);
clearqPB->setEnabled(false); clearqPB->setEnabled(false);
@ -130,8 +129,7 @@ void SSearch::searchTextChanged(const QString& text)
m_disableAutosearch = true; m_disableAutosearch = true;
string s; string s;
int cs = partialWord(s); int cs = partialWord(s);
LOGDEB1(("SSearch::searchTextChanged: autosearch. cs %d s [%s]\n", LOGDEB1("SSearch::searchTextChanged: autosearch. cs " << (cs) << " s [" << (s) << "]\n" );
cs, s.c_str()));
if (cs < 0) { if (cs < 0) {
startSimpleSearch(); startSimpleSearch();
} else if (!m_stroketimeout->isActive() && s.size() >= 2) { } else if (!m_stroketimeout->isActive() && s.size() >= 2) {
@ -146,7 +144,7 @@ void SSearch::searchTextChanged(const QString& text)
void SSearch::searchTypeChanged(int typ) void SSearch::searchTypeChanged(int typ)
{ {
LOGDEB(("Search type now %d\n", typ)); LOGDEB("Search type now " << (typ) << "\n" );
// Adjust context help // Adjust context help
if (typ == SST_LANG) if (typ == SST_LANG)
HelpClient::installMap((const char *)this->objectName().toUtf8(), HelpClient::installMap((const char *)this->objectName().toUtf8(),
@ -188,7 +186,7 @@ void SSearch::searchTypeChanged(int typ)
void SSearch::startSimpleSearch() void SSearch::startSimpleSearch()
{ {
QString qs = queryText->currentText(); QString qs = queryText->currentText();
LOGDEB(("SSearch::startSimpleSearch(): qs [%s]\n", qs2utf8s(qs).c_str())); LOGDEB("SSearch::startSimpleSearch(): qs [" << (qs2utf8s(qs)) << "]\n" );
if (qs.length() == 0) if (qs.length() == 0)
return; return;
@ -201,7 +199,7 @@ void SSearch::startSimpleSearch()
if (!startSimpleSearch(u8)) if (!startSimpleSearch(u8))
return; return;
LOGDEB(("startSimpleSearch: updating history\n")); LOGDEB("startSimpleSearch: updating history\n" );
// Search terms history: // Search terms history:
// We want to have the new text at the top and any older identical // We want to have the new text at the top and any older identical
// entry to be erased. There is no standard qt policy to do this ? // entry to be erased. There is no standard qt policy to do this ?
@ -242,7 +240,7 @@ string SSearch::asXML()
bool SSearch::startSimpleSearch(const string& u8, int maxexp) bool SSearch::startSimpleSearch(const string& u8, int maxexp)
{ {
LOGDEB(("SSearch::startSimpleSearch(%s)\n", u8.c_str())); LOGDEB("SSearch::startSimpleSearch(" << (u8) << ")\n" );
string stemlang = prefs.stemlang(); string stemlang = prefs.stemlang();
ostringstream xml; ostringstream xml;
@ -309,7 +307,7 @@ bool SSearch::startSimpleSearch(const string& u8, int maxexp)
xml << "</SD>\n"; xml << "</SD>\n";
m_xml = xml.str(); m_xml = xml.str();
LOGDEB(("SSearch::startSimpleSearch:xml:[%s]\n", m_xml.c_str())); LOGDEB("SSearch::startSimpleSearch:xml:[" << (m_xml) << "]\n" );
STD_SHARED_PTR<Rcl::SearchData> rsdata(sdata); STD_SHARED_PTR<Rcl::SearchData> rsdata(sdata);
emit startSearch(rsdata, true); emit startSearch(rsdata, true);
@ -392,7 +390,7 @@ bool SSearch::hasSearchString()
static const char* punct = " \t()<>\"'[]{}!^*.,:;\n\r"; static const char* punct = " \t()<>\"'[]{}!^*.,:;\n\r";
void SSearch::addTerm(QString term) void SSearch::addTerm(QString term)
{ {
LOGDEB(("SSearch::AddTerm: [%s]\n", (const char *)term.toUtf8())); LOGDEB("SSearch::AddTerm: [" << ((const char *)term.toUtf8()) << "]\n" );
string t = (const char *)term.toUtf8(); string t = (const char *)term.toUtf8();
string::size_type pos = t.find_last_not_of(punct); string::size_type pos = t.find_last_not_of(punct);
if (pos == string::npos) if (pos == string::npos)
@ -414,8 +412,7 @@ void SSearch::addTerm(QString term)
void SSearch::onWordReplace(const QString& o, const QString& n) void SSearch::onWordReplace(const QString& o, const QString& n)
{ {
LOGDEB(("SSearch::onWordReplace: o [%s] n [%s]\n", LOGDEB("SSearch::onWordReplace: o [" << (qs2utf8s(o)) << "] n [" << (qs2utf8s(n)) << "]\n" );
qs2utf8s(o).c_str(), qs2utf8s(n).c_str()));
QString txt = queryText->currentText(); QString txt = queryText->currentText();
QRegExp exp = QRegExp(QString("\\b") + o + QString("\\b")); QRegExp exp = QRegExp(QString("\\b") + o + QString("\\b"));
exp.setCaseSensitivity(Qt::CaseInsensitive); exp.setCaseSensitivity(Qt::CaseInsensitive);
@ -476,7 +473,7 @@ int SSearch::completionList(string s, QStringList& lst, int max)
// Complete last word in input by querying db for all possible terms. // Complete last word in input by querying db for all possible terms.
void SSearch::completion() void SSearch::completion()
{ {
LOGDEB(("SSearch::completion\n")); LOGDEB("SSearch::completion\n" );
m_disableAutosearch = true; m_disableAutosearch = true;
m_stroketimeout->stop(); m_stroketimeout->stop();
@ -506,7 +503,7 @@ void SSearch::completion()
return; return;
} }
if (lst.size() >= maxdpy) { if (lst.size() >= maxdpy) {
LOGDEB0(("SSearch::completion(): truncating list\n")); LOGDEB0("SSearch::completion(): truncating list\n" );
lst = lst.mid(0, maxdpy); lst = lst.mid(0, maxdpy);
lst.append("[...]"); lst.append("[...]");
} }
@ -542,7 +539,7 @@ void SSearch::completionTermChosen(const QString& text)
void SSearch::wrapupCompletion() void SSearch::wrapupCompletion()
{ {
LOGDEB(("SSearch::wrapupCompletion\n")); LOGDEB("SSearch::wrapupCompletion\n" );
queryText->clear(); queryText->clear();
queryText->addItems(prefs.ssearchHistory); queryText->addItems(prefs.ssearchHistory);
@ -707,9 +704,7 @@ bool SSearch::eventFilter(QObject *target, QEvent *event)
event->type() == QEvent::UpdateRequest || event->type() == QEvent::UpdateRequest ||
event->type() == QEvent::Paint) event->type() == QEvent::Paint)
return false; return false;
LOGDEB2(("SSearch::eventFilter: target %p (%p) type %s\n", LOGDEB2("SSearch::eventFilter: target " << (target) << " (" << (queryText->lineEdit()) << ") type " << (eventTypeToStr(event->type())) << "\n" );
target, queryText->lineEdit(),
eventTypeToStr(event->type())));
#endif #endif
if (target == queryText->view()) { if (target == queryText->view()) {
@ -725,16 +720,15 @@ bool SSearch::eventFilter(QObject *target, QEvent *event)
if (event->type() == QEvent::KeyPress) { if (event->type() == QEvent::KeyPress) {
QKeyEvent *ke = (QKeyEvent *)event; QKeyEvent *ke = (QKeyEvent *)event;
LOGDEB1(("SSearch::eventFilter: keyPress (m_escape %d) key %d\n", LOGDEB1("SSearch::eventFilter: keyPress (m_escape " << (m_escape) << ") key " << (ke->key()) << "\n" );
m_escape, ke->key()));
if (ke->key() == Qt::Key_Escape) { if (ke->key() == Qt::Key_Escape) {
LOGDEB(("Escape\n")); LOGDEB("Escape\n" );
m_escape = true; m_escape = true;
m_disableAutosearch = true; m_disableAutosearch = true;
m_stroketimeout->stop(); m_stroketimeout->stop();
return true; return true;
} else if (m_escape && ke->key() == Qt::Key_Space) { } else if (m_escape && ke->key() == Qt::Key_Space) {
LOGDEB(("Escape space\n")); LOGDEB("Escape space\n" );
ke->accept(); ke->accept();
completion(); completion();
m_escape = false; m_escape = false;
@ -750,11 +744,11 @@ bool SSearch::eventFilter(QObject *target, QEvent *event)
if (prefs.ssearchAsYouType) { if (prefs.ssearchAsYouType) {
m_disableAutosearch = false; m_disableAutosearch = false;
QString qs = queryText->currentText(); QString qs = queryText->currentText();
LOGDEB0(("SSearch::eventFilter: start timer, qs [%s]\n", LOGDEB0("SSearch::eventFilter: start timer, qs [" << (qs2utf8s(qs)) << "]\n" );
qs2utf8s(qs).c_str()));
m_stroketimeout->start(strokeTimeoutMS); m_stroketimeout->start(strokeTimeoutMS);
} }
} }
} }
return false; return false;
} }

View file

@ -49,7 +49,7 @@
#include "pathut.h" #include "pathut.h"
#include "uiprefs_w.h" #include "uiprefs_w.h"
#include "viewaction_w.h" #include "viewaction_w.h"
#include "debuglog.h" #include "log.h"
#include "editdialog.h" #include "editdialog.h"
#include "rclmain_w.h" #include "rclmain_w.h"
#include "ptrans_w.h" #include "ptrans_w.h"
@ -606,7 +606,7 @@ void UIPrefsDialog::addExtraDbPB_clicked()
} }
} }
LOGDEB(("ExtraDbDial: got: [%s]\n", dbdir.c_str())); LOGDEB("ExtraDbDial: got: [" << (dbdir) << "]\n" );
path_catslash(dbdir); path_catslash(dbdir);
bool stripped; bool stripped;
if (!Rcl::Db::testDbDir(dbdir, &stripped)) { if (!Rcl::Db::testDbDir(dbdir, &stripped)) {
@ -642,3 +642,4 @@ void UIPrefsDialog::addExtraDbPB_clicked()
item->setCheckState(Qt::Checked); item->setCheckState(Qt::Checked);
idxLV->sortItems(); idxLV->sortItems();
} }

View file

@ -34,7 +34,7 @@ using namespace std;
#include <qlayout.h> #include <qlayout.h>
#include "recoll.h" #include "recoll.h"
#include "debuglog.h" #include "log.h"
#include "guiutils.h" #include "guiutils.h"
#include "viewaction_w.h" #include "viewaction_w.h"
@ -234,3 +234,4 @@ void ViewAction::editActions()
theconfig->setMimeViewerAllEx(s); theconfig->setMimeViewerAllEx(s);
fillLists(); fillLists();
} }

View file

@ -22,7 +22,7 @@
#include "ssearch_w.h" #include "ssearch_w.h"
#include "guiutils.h" #include "guiutils.h"
#include "debuglog.h" #include "log.h"
#include "xmltosd.h" #include "xmltosd.h"
#include "smallut.h" #include "smallut.h"
#include "recoll.h" #include "recoll.h"
@ -82,21 +82,13 @@ bool SDHXMLHandler::startElement(const QString & /* namespaceURI */,
const QString &qName, const QString &qName,
const QXmlAttributes &attrs) const QXmlAttributes &attrs)
{ {
LOGDEB2(("SDHXMLHandler::startElement: name [%s]\n", LOGDEB2("SDHXMLHandler::startElement: name [" << ((const char *)qName.toUtf8()) << "]\n" );
(const char *)qName.toUtf8()));
if (qName == "SD") { if (qName == "SD") {
// Advanced search history entries have no type. So we're good // Advanced search history entries have no type. So we're good
// either if type is absent, or if it's searchdata // either if type is absent, or if it's searchdata
int idx = attrs.index("type"); int idx = attrs.index("type");
if (idx >= 0 && attrs.value(idx).compare("searchdata")) { if (idx >= 0 && attrs.value(idx).compare("searchdata")) {
LOGDEB(("XMLTOSD: bad type\n")) LOGDEB("XMLTOSD: bad type\n" );
return false;
}
resetTemps();
// A new search descriptor. Allocate data structure
sd = STD_SHARED_PTR<SearchData>(new SearchData);
if (!sd) {
LOGERR(("SDHXMLHandler::startElement: out of memory\n"));
return false; return false;
} }
} }
@ -107,8 +99,7 @@ bool SDHXMLHandler::endElement(const QString & /* namespaceURI */,
const QString & /* localName */, const QString & /* localName */,
const QString &qName) const QString &qName)
{ {
LOGDEB2(("SDHXMLHandler::endElement: name [%s]\n", LOGDEB2("SDHXMLHandler::endElement: name [" << ((const char *)qName.toUtf8()) << "]\n" );
(const char *)qName.toUtf8()));
if (qName == "CLT") { if (qName == "CLT") {
if (currentText == "OR") { if (currentText == "OR") {
@ -147,7 +138,7 @@ bool SDHXMLHandler::endElement(const QString & /* namespaceURI */,
c = new SearchDataClauseDist(SCLT_NEAR, text, slack, field); c = new SearchDataClauseDist(SCLT_NEAR, text, slack, field);
c->setexclude(exclude); c->setexclude(exclude);
} else { } else {
LOGERR(("Bad clause type [%s]\n", qs2utf8s(whatclause).c_str())); LOGERR("Bad clause type [" << (qs2utf8s(whatclause)) << "]\n" );
return false; return false;
} }
sd->addClause(c); sd->addClause(c);
@ -219,8 +210,7 @@ STD_SHARED_PTR<Rcl::SearchData> xmlToSearchData(const string& xml)
xmlInputSource.setData(QString::fromUtf8(xml.c_str())); xmlInputSource.setData(QString::fromUtf8(xml.c_str()));
if (!reader.parse(xmlInputSource) || !handler.isvalid) { if (!reader.parse(xmlInputSource) || !handler.isvalid) {
LOGERR(("xmlToSearchData: parse failed for [%s]\n", LOGERR("xmlToSearchData: parse failed for [" << (xml) << "]\n" );
xml.c_str()));
return STD_SHARED_PTR<SearchData>(); return STD_SHARED_PTR<SearchData>();
} }
return handler.sd; return handler.sd;
@ -270,13 +260,12 @@ bool SSHXMLHandler::startElement(const QString & /* namespaceURI */,
const QString &qName, const QString &qName,
const QXmlAttributes &attrs) const QXmlAttributes &attrs)
{ {
LOGDEB2(("SSHXMLHandler::startElement: name [%s]\n", LOGDEB2("SSHXMLHandler::startElement: name [" << ((const char *)qName.toUtf8()) << "]\n" );
(const char *)qName.toUtf8()));
if (qName == "SD") { if (qName == "SD") {
// Simple search saved data has a type='ssearch' attribute. // Simple search saved data has a type='ssearch' attribute.
int idx = attrs.index("type"); int idx = attrs.index("type");
if (idx < 0 && attrs.value(idx).compare("ssearch")) { if (idx < 0 && attrs.value(idx).compare("ssearch")) {
LOGDEB(("XMLTOSSS: bad type\n")); LOGDEB("XMLTOSSS: bad type\n" );
return false; return false;
} }
resetTemps(); resetTemps();
@ -288,8 +277,7 @@ bool SSHXMLHandler::endElement(const QString & /* namespaceURI */,
const QString & /* localName */, const QString & /* localName */,
const QString &qName) const QString &qName)
{ {
LOGDEB2(("SSHXMLHandler::endElement: name [%s]\n", LOGDEB2("SSHXMLHandler::endElement: name [" << ((const char *)qName.toUtf8()) << "]\n" );
(const char *)qName.toUtf8()));
currentText = currentText.trimmed(); currentText = currentText.trimmed();
@ -309,7 +297,7 @@ bool SSHXMLHandler::endElement(const QString & /* namespaceURI */,
} else if (!currentText.compare("AND")) { } else if (!currentText.compare("AND")) {
data.mode = SSearch::SST_ALL; data.mode = SSearch::SST_ALL;
} else { } else {
LOGERR(("BAD SEARCH MODE: [%s]\n", qs2utf8s(currentText).c_str())); LOGERR("BAD SEARCH MODE: [" << (qs2utf8s(currentText)) << "]\n" );
return false; return false;
} }
} else if (qName == "AS") { } else if (qName == "AS") {
@ -336,10 +324,10 @@ bool xmlToSSearch(const string& xml, SSearchDef& data)
xmlInputSource.setData(QString::fromUtf8(xml.c_str())); xmlInputSource.setData(QString::fromUtf8(xml.c_str()));
if (!reader.parse(xmlInputSource) || !handler.isvalid) { if (!reader.parse(xmlInputSource) || !handler.isvalid) {
LOGERR(("xmlToSSearch: parse failed for [%s]\n", LOGERR("xmlToSSearch: parse failed for [" << (xml) << "]\n" );
xml.c_str()));
return false; return false;
} }
data = handler.data; data = handler.data;
return true; return true;
} }

View file

@ -19,7 +19,7 @@
#include "docseq.h" #include "docseq.h"
#include "filtseq.h" #include "filtseq.h"
#include "sortseq.h" #include "sortseq.h"
#include "debuglog.h" #include "log.h"
#include "internfile.h" #include "internfile.h"
PTMutexInit DocSequence::o_dblock; PTMutexInit DocSequence::o_dblock;
@ -43,7 +43,7 @@ bool DocSequence::getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc)
{ {
Rcl::Db *db = getDb(); Rcl::Db *db = getDb();
if (db == 0) { if (db == 0) {
LOGERR(("DocSequence::getEnclosing: no db\n")); LOGERR("DocSequence::getEnclosing: no db\n" );
return false; return false;
} }
PTMutexLocker locker(o_dblock); PTMutexLocker locker(o_dblock);
@ -67,7 +67,7 @@ void DocSource::stripStack()
bool DocSource::buildStack() bool DocSource::buildStack()
{ {
LOGDEB2(("DocSource::buildStack()\n")); LOGDEB2("DocSource::buildStack()\n" );
stripStack(); stripStack();
if (!m_seq) if (!m_seq)
@ -77,7 +77,7 @@ bool DocSource::buildStack()
// truncates the original list) // truncates the original list)
if (m_seq->canFilter()) { if (m_seq->canFilter()) {
if (!m_seq->setFiltSpec(m_fspec)) { if (!m_seq->setFiltSpec(m_fspec)) {
LOGERR(("DocSource::buildStack: setfiltspec failed\n")); LOGERR("DocSource::buildStack: setfiltspec failed\n" );
} }
} else { } else {
if (m_fspec.isNotNull()) { if (m_fspec.isNotNull()) {
@ -88,7 +88,7 @@ bool DocSource::buildStack()
if (m_seq->canSort()) { if (m_seq->canSort()) {
if (!m_seq->setSortSpec(m_sspec)) { if (!m_seq->setSortSpec(m_sspec)) {
LOGERR(("DocSource::buildStack: setsortspec failed\n")); LOGERR("DocSource::buildStack: setsortspec failed\n" );
} }
} else { } else {
if (m_sspec.isNotNull()) { if (m_sspec.isNotNull()) {
@ -114,7 +114,7 @@ string DocSource::title()
bool DocSource::setFiltSpec(const DocSeqFiltSpec &f) bool DocSource::setFiltSpec(const DocSeqFiltSpec &f)
{ {
LOGDEB2(("DocSource::setFiltSpec\n")); LOGDEB2("DocSource::setFiltSpec\n" );
m_fspec = f; m_fspec = f;
buildStack(); buildStack();
return true; return true;
@ -122,9 +122,10 @@ bool DocSource::setFiltSpec(const DocSeqFiltSpec &f)
bool DocSource::setSortSpec(const DocSeqSortSpec &s) bool DocSource::setSortSpec(const DocSeqSortSpec &s)
{ {
LOGDEB2(("DocSource::setSortSpec\n")); LOGDEB2("DocSource::setSortSpec\n" );
m_sspec = s; m_sspec = s;
buildStack(); buildStack();
return true; return true;
} }

View file

@ -23,7 +23,7 @@
#include "docseqdb.h" #include "docseqdb.h"
#include "rcldb.h" #include "rcldb.h"
#include "debuglog.h" #include "log.h"
#include "wasatorcl.h" #include "wasatorcl.h"
using std::list; using std::list;
@ -77,7 +77,7 @@ static const string cstr_mre("[...]");
// We ignore most abstract/snippets preferences. // We ignore most abstract/snippets preferences.
bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<Rcl::Snippet>& vpabs) bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<Rcl::Snippet>& vpabs)
{ {
LOGDEB(("DocSequenceDb::getAbstract/pair\n")); LOGDEB("DocSequenceDb::getAbstract/pair\n" );
PTMutexLocker locker(o_dblock); PTMutexLocker locker(o_dblock);
if (!setQuery()) if (!setQuery())
return false; return false;
@ -89,8 +89,7 @@ bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<Rcl::Snippet>& vpabs)
ret = m_q->makeDocAbstract(doc, vpabs, maxoccs, ret = m_q->makeDocAbstract(doc, vpabs, maxoccs,
m_q->whatDb()->getAbsCtxLen()+ 2); m_q->whatDb()->getAbsCtxLen()+ 2);
} }
LOGDEB(("DocSequenceDb::getAbstract: got ret %d vpabs len %u\n", ret, LOGDEB("DocSequenceDb::getAbstract: got ret " << (ret) << " vpabs len " << (vpabs.size()) << "\n" );
vpabs.size()));
if (vpabs.empty()) { if (vpabs.empty()) {
return true; return true;
} }
@ -161,7 +160,7 @@ string DocSequenceDb::title()
bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs) bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs)
{ {
LOGDEB(("DocSequenceDb::setFiltSpec\n")); LOGDEB("DocSequenceDb::setFiltSpec\n" );
PTMutexLocker locker(o_dblock); PTMutexLocker locker(o_dblock);
if (fs.isNotNull()) { if (fs.isNotNull()) {
// We build a search spec by adding a filtering layer to the base one. // We build a search spec by adding a filtering layer to the base one.
@ -209,8 +208,7 @@ bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs)
bool DocSequenceDb::setSortSpec(const DocSeqSortSpec &spec) bool DocSequenceDb::setSortSpec(const DocSeqSortSpec &spec)
{ {
LOGDEB(("DocSequenceDb::setSortSpec: fld [%s] %s\n", LOGDEB("DocSequenceDb::setSortSpec: fld [" << (spec.field) << "] " << (spec.desc ? "desc" : "asc") << "\n" );
spec.field.c_str(), spec.desc ? "desc" : "asc"));
PTMutexLocker locker(o_dblock); PTMutexLocker locker(o_dblock);
if (spec.isNotNull()) { if (spec.isNotNull()) {
m_q->setSortBy(spec.field, !spec.desc); m_q->setSortBy(spec.field, !spec.desc);
@ -233,8 +231,7 @@ bool DocSequenceDb::setQuery()
m_lastSQStatus = m_q->setQuery(m_fsdata); m_lastSQStatus = m_q->setQuery(m_fsdata);
if (!m_lastSQStatus) { if (!m_lastSQStatus) {
m_reason = m_q->getReason(); m_reason = m_q->getReason();
LOGERR(("DocSequenceDb::setQuery: rclquery::setQuery failed: %s\n", LOGERR("DocSequenceDb::setQuery: rclquery::setQuery failed: " << (m_reason) << "\n" );
m_reason.c_str()));
} }
return m_lastSQStatus; return m_lastSQStatus;
} }
@ -248,3 +245,4 @@ bool DocSequenceDb::docDups(const Rcl::Doc& doc, std::vector<Rcl::Doc>& dups)
return false; return false;
} }
} }

View file

@ -26,7 +26,7 @@ using std::list;
#include "rcldb.h" #include "rcldb.h"
#include "fileudi.h" #include "fileudi.h"
#include "base64.h" #include "base64.h"
#include "debuglog.h" #include "log.h"
#include "smallut.h" #include "smallut.h"
// Encode document history entry: // Encode document history entry:
@ -77,7 +77,7 @@ bool RclDHistoryEntry::decode(const string &value)
// Old style entry found, make an udi, using the fs udi maker // Old style entry found, make an udi, using the fs udi maker
make_udi(fn, ipath, udi); make_udi(fn, ipath, udi);
} }
LOGDEB1(("RclDHistoryEntry::decode: udi [%s]\n", udi.c_str())); LOGDEB1("RclDHistoryEntry::decode: udi [" << (udi) << "]\n" );
return true; return true;
} }
@ -89,8 +89,7 @@ bool RclDHistoryEntry::equal(const DynConfEntry& other)
bool historyEnterDoc(RclDynConf *dncf, const string& udi) bool historyEnterDoc(RclDynConf *dncf, const string& udi)
{ {
LOGDEB1(("historyEnterDoc: [%s] into %s\n", LOGDEB1("historyEnterDoc: [" << (udi) << "] into " << (dncf->getFilename()) << "\n" );
udi.c_str(), dncf->getFilename().c_str()));
RclDHistoryEntry ne(time(0), udi); RclDHistoryEntry ne(time(0), udi);
RclDHistoryEntry scratch; RclDHistoryEntry scratch;
return dncf->insertNew(docHistSubKey, ne, scratch, 200); return dncf->insertNew(docHistSubKey, ne, scratch, 200);
@ -161,3 +160,4 @@ int DocSequenceHistory::getResCnt()
m_hlist = getDocHistory(m_hist); m_hlist = getDocHistory(m_hist);
return int(m_hlist.size()); return int(m_hlist.size());
} }

View file

@ -23,7 +23,7 @@
#include "dynconf.h" #include "dynconf.h"
#include "base64.h" #include "base64.h"
#include "smallut.h" #include "smallut.h"
#include "debuglog.h" #include "log.h"
using namespace std; using namespace std;
@ -44,13 +44,13 @@ bool RclDynConf::insertNew(const string &sk, DynConfEntry &n, DynConfEntry &s,
for (it = names.begin(); it != names.end(); it++) { for (it = names.begin(); it != names.end(); it++) {
string oval; string oval;
if (!m_data.get(*it, oval, sk)) { if (!m_data.get(*it, oval, sk)) {
LOGDEB(("No data for %s\n", (*it).c_str())); LOGDEB("No data for " << ((*it)) << "\n" );
continue; continue;
} }
s.decode(oval); s.decode(oval);
if (s.equal(n)) { if (s.equal(n)) {
LOGDEB(("Erasing old entry\n")); LOGDEB("Erasing old entry\n" );
m_data.erase(*it, sk); m_data.erase(*it, sk);
changed = true; changed = true;
} }
@ -80,9 +80,9 @@ bool RclDynConf::insertNew(const string &sk, DynConfEntry &n, DynConfEntry &s,
string value; string value;
n.encode(value); n.encode(value);
LOGDEB1(("Encoded value [%s] (%d)\n", value.c_str(), value.size())); LOGDEB1("Encoded value [" << (value) << "] (" << (value.size()) << ")\n" );
if (!m_data.set(string(nname), value, sk)) { if (!m_data.set(string(nname), value, sk)) {
LOGERR(("RclDHistory::insertNew: set failed\n")); LOGERR("RclDHistory::insertNew: set failed\n" );
return false; return false;
} }
return true; return true;
@ -124,7 +124,8 @@ list<string> RclDynConf::getStringList(const string sk)
#include <iostream> #include <iostream>
#include "history.h" #include "history.h"
#include "debuglog.h" #include "log.h"
#ifndef NO_NAMESPACES #ifndef NO_NAMESPACES
using namespace std; using namespace std;
@ -211,3 +212,4 @@ int main(int argc, char **argv)
} }
#endif #endif

View file

@ -15,7 +15,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "debuglog.h" #include "log.h"
#include "filtseq.h" #include "filtseq.h"
#include "rclconfig.h" #include "rclconfig.h"
@ -23,20 +23,19 @@ using std::string;
static bool filter(const DocSeqFiltSpec& fs, const Rcl::Doc *x) static bool filter(const DocSeqFiltSpec& fs, const Rcl::Doc *x)
{ {
LOGDEB2((" Filter: ncrits %d\n", fs.crits.size())); LOGDEB2(" Filter: ncrits " << (fs.crits.size()) << "\n" );
// Compare using each criterion in term. We're doing an or: // Compare using each criterion in term. We're doing an or:
// 1st ok ends // 1st ok ends
for (unsigned int i = 0; i < fs.crits.size(); i++) { for (unsigned int i = 0; i < fs.crits.size(); i++) {
switch (fs.crits[i]) { switch (fs.crits[i]) {
case DocSeqFiltSpec::DSFS_MIMETYPE: case DocSeqFiltSpec::DSFS_MIMETYPE:
LOGDEB2((" filter: MIMETYPE: me [%s] doc [%s]\n", LOGDEB2(" filter: MIMETYPE: me [" << (fs.values[i]) << "] doc [" << (x->mimetype) << "]\n" );
fs.values[i].c_str(), x->mimetype.c_str()));
if (x->mimetype == fs.values[i]) if (x->mimetype == fs.values[i])
return true; return true;
break; break;
case DocSeqFiltSpec::DSFS_QLANG: case DocSeqFiltSpec::DSFS_QLANG:
{ {
LOGDEB((" filter: QLANG [%s]!!\n", fs.values[i].c_str())); LOGDEB(" filter: QLANG [" << (fs.values[i]) << "]!!\n" );
} }
break; break;
case DocSeqFiltSpec::DSFS_PASSALL: case DocSeqFiltSpec::DSFS_PASSALL:
@ -56,7 +55,7 @@ DocSeqFiltered::DocSeqFiltered(RclConfig *conf, STD_SHARED_PTR<DocSequence> iseq
bool DocSeqFiltered::setFiltSpec(const DocSeqFiltSpec &filtspec) bool DocSeqFiltered::setFiltSpec(const DocSeqFiltSpec &filtspec)
{ {
LOGDEB0(("DocSeqFiltered::setFiltSpec\n")); LOGDEB0("DocSeqFiltered::setFiltSpec\n" );
for (unsigned int i = 0; i < filtspec.crits.size(); i++) { for (unsigned int i = 0; i < filtspec.crits.size(); i++) {
switch (filtspec.crits[i]) { switch (filtspec.crits[i]) {
case DocSeqFiltSpec::DSFS_MIMETYPE: case DocSeqFiltSpec::DSFS_MIMETYPE:
@ -74,7 +73,7 @@ bool DocSeqFiltered::setFiltSpec(const DocSeqFiltSpec &filtspec)
m_config->getMimeCatTypes(catg, tps); m_config->getMimeCatTypes(catg, tps);
for (vector<string>::const_iterator it = tps.begin(); for (vector<string>::const_iterator it = tps.begin();
it != tps.end(); it++) { it != tps.end(); it++) {
LOGDEB2(("Adding mime: [%s]\n", it->c_str())); LOGDEB2("Adding mime: [" << (it) << "]\n" );
m_spec.orCrit(DocSeqFiltSpec::DSFS_MIMETYPE, *it); m_spec.orCrit(DocSeqFiltSpec::DSFS_MIMETYPE, *it);
} }
} }
@ -94,7 +93,7 @@ bool DocSeqFiltered::setFiltSpec(const DocSeqFiltSpec &filtspec)
bool DocSeqFiltered::getDoc(int idx, Rcl::Doc &doc, string *) bool DocSeqFiltered::getDoc(int idx, Rcl::Doc &doc, string *)
{ {
LOGDEB2(("DocSeqFiltered::getDoc() fetching %d\n", idx)); LOGDEB2("DocSeqFiltered::getDoc() fetching " << (idx) << "\n" );
if (idx >= (int)m_dbindices.size()) { if (idx >= (int)m_dbindices.size()) {
// Have to fetch docs and filter until we get enough or // Have to fetch docs and filter until we get enough or
@ -122,3 +121,4 @@ bool DocSeqFiltered::getDoc(int idx, Rcl::Doc &doc, string *)
} }
return true; return true;
} }

View file

@ -31,7 +31,7 @@ using std::set;
#include "rcldb.h" #include "rcldb.h"
#include "rclconfig.h" #include "rclconfig.h"
#include "debuglog.h" #include "log.h"
#include "textsplit.h" #include "textsplit.h"
#include "utf8iter.h" #include "utf8iter.h"
#include "smallut.h" #include "smallut.h"
@ -86,14 +86,12 @@ class TextSplitPTR : public TextSplit {
string dumb = term; string dumb = term;
if (o_index_stripchars) { if (o_index_stripchars) {
if (!unacmaybefold(term, dumb, "UTF-8", UNACOP_UNACFOLD)) { if (!unacmaybefold(term, dumb, "UTF-8", UNACOP_UNACFOLD)) {
LOGINFO(("PlainToRich::takeword: unac failed for [%s]\n", LOGINFO("PlainToRich::takeword: unac failed for [" << (term) << "]\n" );
term.c_str()));
return true; return true;
} }
} }
//LOGDEB2(("Input dumbbed term: '%s' %d %d %d\n", dumb.c_str(), //LOGDEB2("Input dumbbed term: '" << (dumb) << "' " << (// pos) << " " << (bts) << " " << (bte) << "\n" );
// pos, bts, bte));
// If this word is a search term, remember its byte-offset span. // If this word is a search term, remember its byte-offset span.
map<string, size_t>::const_iterator it = m_terms.find(dumb); map<string, size_t>::const_iterator it = m_terms.find(dumb);
@ -106,7 +104,7 @@ class TextSplitPTR : public TextSplit {
// Term group (phrase/near) handling // Term group (phrase/near) handling
m_plists[dumb].push_back(pos); m_plists[dumb].push_back(pos);
m_gpostobytes[pos] = pair<int,int>(bts, bte); m_gpostobytes[pos] = pair<int,int>(bts, bte);
//LOGDEB2(("Recorded bpos for %d: %d %d\n", pos, bts, bte)); //LOGDEB2("Recorded bpos for " << (pos) << ": " << (bts) << " " << (bte) << "\n" );
} }
// Check for cancellation request // Check for cancellation request
@ -169,8 +167,7 @@ static bool do_proximity_test(int window, vector<vector<int>* >& plists,
unsigned int i, int min, int max, unsigned int i, int min, int max,
int *sp, int *ep, int minpos) int *sp, int *ep, int minpos)
{ {
LOGDEB1(("do_prox_test: win %d i %d min %d max %d minpos %d\n", LOGDEB1("do_prox_test: win " << (window) << " i " << (i) << " min " << (min) << " max " << (max) << " minpos " << (minpos) << "\n" );
window, i, min, max, minpos));
int tmp = max + 1 - window; int tmp = max + 1 - window;
if (tmp < minpos) if (tmp < minpos)
tmp = minpos; tmp = minpos;
@ -207,8 +204,7 @@ bool TextSplitPTR::matchGroup(unsigned int grpidx)
const vector<string>& terms = m_hdata.groups[grpidx]; const vector<string>& terms = m_hdata.groups[grpidx];
int window = int(m_hdata.groups[grpidx].size() + m_hdata.slacks[grpidx]); int window = int(m_hdata.groups[grpidx].size() + m_hdata.slacks[grpidx]);
LOGDEB1(("TextSplitPTR::matchGroup:d %d: %s\n", window, LOGDEB1("TextSplitPTR::matchGroup:d " << (window) << ": " << (vecStringToString(terms)) << "\n" );
vecStringToString(terms).c_str()));
// The position lists we are going to work with. We extract them from the // The position lists we are going to work with. We extract them from the
// (string->plist) map // (string->plist) map
@ -224,8 +220,7 @@ bool TextSplitPTR::matchGroup(unsigned int grpidx)
it != terms.end(); it++) { it != terms.end(); it++) {
map<string, vector<int> >::iterator pl = m_plists.find(*it); map<string, vector<int> >::iterator pl = m_plists.find(*it);
if (pl == m_plists.end()) { if (pl == m_plists.end()) {
LOGDEB1(("TextSplitPTR::matchGroup: [%s] not found in m_plists\n", LOGDEB1("TextSplitPTR::matchGroup: [" << ((*it)) << "] not found in m_plists\n" );
(*it).c_str()));
return false; return false;
} }
plists.push_back(&(pl->second)); plists.push_back(&(pl->second));
@ -234,7 +229,7 @@ bool TextSplitPTR::matchGroup(unsigned int grpidx)
// I think this can't actually happen, was useful when we used to // I think this can't actually happen, was useful when we used to
// prune the groups, but doesn't hurt. // prune the groups, but doesn't hurt.
if (plists.size() < 2) { if (plists.size() < 2) {
LOGDEB1(("TextSplitPTR::matchGroup: no actual groups found\n")); LOGDEB1("TextSplitPTR::matchGroup: no actual groups found\n" );
return false; return false;
} }
// Sort the positions lists so that the shorter is first // Sort the positions lists so that the shorter is first
@ -245,11 +240,10 @@ bool TextSplitPTR::matchGroup(unsigned int grpidx)
it = plistToTerm.find(plists[0]); it = plistToTerm.find(plists[0]);
if (it == plistToTerm.end()) { if (it == plistToTerm.end()) {
// SuperWeird // SuperWeird
LOGERR(("matchGroup: term for first list not found !?!\n")); LOGERR("matchGroup: term for first list not found !?!\n" );
return false; return false;
} }
LOGDEB1(("matchGroup: walking the shortest plist. Term [%s], len %d\n", LOGDEB1("matchGroup: walking the shortest plist. Term [" << (it->second) << "], len " << (plists[0]->size()) << "\n" );
it->second.c_str(), plists[0]->size()));
} }
// Minpos is the highest end of a found match. While looking for // Minpos is the highest end of a found match. While looking for
@ -262,10 +256,9 @@ bool TextSplitPTR::matchGroup(unsigned int grpidx)
it != plists[0]->end(); it++) { it != plists[0]->end(); it++) {
int pos = *it; int pos = *it;
int sta = INT_MAX, sto = 0; int sta = INT_MAX, sto = 0;
LOGDEB2(("MatchGroup: Testing at pos %d\n", pos)); LOGDEB2("MatchGroup: Testing at pos " << (pos) << "\n" );
if (do_proximity_test(window,plists, 1, pos, pos, &sta, &sto, minpos)) { if (do_proximity_test(window,plists, 1, pos, pos, &sta, &sto, minpos)) {
LOGDEB1(("TextSplitPTR::matchGroup: MATCH termpos [%d,%d]\n", LOGDEB1("TextSplitPTR::matchGroup: MATCH termpos [" << (sta) << "," << (sto) << "]\n" );
sta, sto));
// Maybe extend the window by 1st term position, this was not // Maybe extend the window by 1st term position, this was not
// done by do_prox.. // done by do_prox..
SETMINMAX(pos, sta, sto); SETMINMAX(pos, sta, sto);
@ -274,15 +267,14 @@ bool TextSplitPTR::matchGroup(unsigned int grpidx)
map<int, pair<int, int> >::iterator i1 = m_gpostobytes.find(sta); map<int, pair<int, int> >::iterator i1 = m_gpostobytes.find(sta);
map<int, pair<int, int> >::iterator i2 = m_gpostobytes.find(sto); map<int, pair<int, int> >::iterator i2 = m_gpostobytes.find(sto);
if (i1 != m_gpostobytes.end() && i2 != m_gpostobytes.end()) { if (i1 != m_gpostobytes.end() && i2 != m_gpostobytes.end()) {
LOGDEB2(("TextSplitPTR::matchGroup: pushing bpos %d %d\n", LOGDEB2("TextSplitPTR::matchGroup: pushing bpos " << (i1->second.first) << " " << (i2->second.second) << "\n" );
i1->second.first, i2->second.second));
tboffs.push_back(MatchEntry(i1->second.first, tboffs.push_back(MatchEntry(i1->second.first,
i2->second.second, grpidx)); i2->second.second, grpidx));
} else { } else {
LOGDEB0(("matchGroup: no bpos found for %d or %d\n", sta, sto)); LOGDEB0("matchGroup: no bpos found for " << (sta) << " or " << (sto) << "\n" );
} }
} else { } else {
LOGDEB1(("matchGroup: no group match found at this position\n")); LOGDEB1("matchGroup: no group match found at this position\n" );
} }
} }
@ -333,7 +325,7 @@ bool PlainToRich::plaintorich(const string& in,
{ {
Chrono chron; Chrono chron;
bool ret = true; bool ret = true;
LOGDEB1(("plaintorichich: in: [%s]\n", in.c_str())); LOGDEB1("plaintorichich: in: [" << (in) << "]\n" );
m_hdata = &hdata; m_hdata = &hdata;
// Compute the positions for the query terms. We use the text // Compute the positions for the query terms. We use the text
@ -343,10 +335,10 @@ bool PlainToRich::plaintorich(const string& in,
// Note: the splitter returns the term locations in byte, not // Note: the splitter returns the term locations in byte, not
// character, offsets. // character, offsets.
splitter.text_to_words(in); splitter.text_to_words(in);
LOGDEB2(("plaintorich: split done %d mS\n", chron.millis())); LOGDEB2("plaintorich: split done " << (chron.millis()) << " mS\n" );
// Compute the positions for NEAR and PHRASE groups. // Compute the positions for NEAR and PHRASE groups.
splitter.matchGroups(); splitter.matchGroups();
LOGDEB2(("plaintorich: group match done %d mS\n", chron.millis())); LOGDEB2("plaintorich: group match done " << (chron.millis()) << " mS\n" );
out.clear(); out.clear();
out.push_back(""); out.push_back("");
@ -359,7 +351,7 @@ bool PlainToRich::plaintorich(const string& in,
// a term match when we are actually looking for a group match // a term match when we are actually looking for a group match
// (the snippet generator does this...). // (the snippet generator does this...).
if (splitter.tboffs.empty()) { if (splitter.tboffs.empty()) {
LOGDEB1(("plaintorich: no term matches\n")); LOGDEB1("plaintorich: no term matches\n" );
ret = false; ret = false;
} }
@ -372,7 +364,7 @@ bool PlainToRich::plaintorich(const string& in,
#if 0 #if 0
for (vector<pair<int, int> >::const_iterator it = splitter.tboffs.begin(); for (vector<pair<int, int> >::const_iterator it = splitter.tboffs.begin();
it != splitter.tboffs.end(); it++) { it != splitter.tboffs.end(); it++) {
LOGDEB2(("plaintorich: region: %d %d\n", it->first, it->second)); LOGDEB2("plaintorich: region: " << (it->first) << " " << (it->second) << "\n" );
} }
#endif #endif
@ -532,6 +524,7 @@ bool PlainToRich::plaintorich(const string& in,
fclose(fp); fclose(fp);
} }
#endif #endif
LOGDEB2(("plaintorich: done %d mS\n", chron.millis())); LOGDEB2("plaintorich: done " << (chron.millis()) << " mS\n" );
return ret; return ret;
} }

View file

@ -31,7 +31,7 @@
#include "rclconfig.h" #include "rclconfig.h"
#include "pathut.h" #include "pathut.h"
#include "rclinit.h" #include "rclinit.h"
#include "debuglog.h" #include "log.h"
#include "wasatorcl.h" #include "wasatorcl.h"
#include "internfile.h" #include "internfile.h"
#include "wipedir.h" #include "wipedir.h"
@ -427,3 +427,4 @@ endopts:
return 0; return 0;
} }

View file

@ -31,7 +31,7 @@ using std::list;
#include "cstr.h" #include "cstr.h"
#include "reslistpager.h" #include "reslistpager.h"
#include "debuglog.h" #include "log.h"
#include "rclconfig.h" #include "rclconfig.h"
#include "smallut.h" #include "smallut.h"
#include "rclutil.h" #include "rclutil.h"
@ -67,13 +67,12 @@ ResListPager::ResListPager(int pagesize)
void ResListPager::resultPageNext() void ResListPager::resultPageNext()
{ {
if (!m_docSource) { if (!m_docSource) {
LOGDEB(("ResListPager::resultPageNext: null source\n")); LOGDEB("ResListPager::resultPageNext: null source\n" );
return; return;
} }
int resCnt = m_docSource->getResCnt(); int resCnt = m_docSource->getResCnt();
LOGDEB(("ResListPager::resultPageNext: rescnt %d, winfirst %d\n", LOGDEB("ResListPager::resultPageNext: rescnt " << (resCnt) << ", winfirst " << (m_winfirst) << "\n" );
resCnt, m_winfirst));
if (m_winfirst < 0) { if (m_winfirst < 0) {
m_winfirst = 0; m_winfirst = 0;
@ -125,13 +124,12 @@ static string maybeEscapeHtml(const string& fld)
void ResListPager::resultPageFor(int docnum) void ResListPager::resultPageFor(int docnum)
{ {
if (!m_docSource) { if (!m_docSource) {
LOGDEB(("ResListPager::resultPageFor: null source\n")); LOGDEB("ResListPager::resultPageFor: null source\n" );
return; return;
} }
int resCnt = m_docSource->getResCnt(); int resCnt = m_docSource->getResCnt();
LOGDEB(("ResListPager::resultPageFor(%d): rescnt %d, winfirst %d\n", LOGDEB("ResListPager::resultPageFor(" << (docnum) << "): rescnt " << (resCnt) << ", winfirst " << (m_winfirst) << "\n" );
docnum, resCnt, m_winfirst));
m_winfirst = (docnum / m_pagesize) * m_pagesize; m_winfirst = (docnum / m_pagesize) * m_pagesize;
// Get the next page of results. // Get the next page of results.
@ -324,7 +322,7 @@ void ResListPager::displayDoc(RclConfig *config, int i, Rcl::Doc& doc,
// the table approach for 1.15 for now (in guiutils.cpp) // the table approach for 1.15 for now (in guiutils.cpp)
// chunk << "<br style='clear:both;height:0;line-height:0;'>" << endl; // chunk << "<br style='clear:both;height:0;line-height:0;'>" << endl;
LOGDEB2(("Chunk: [%s]\n", (const char *)chunk.rdbuf()->str().c_str())); LOGDEB2("Chunk: [" << ((const char *)chunk.rdbuf()->str()) << "]\n" );
append(chunk.rdbuf()->str(), i, doc); append(chunk.rdbuf()->str(), i, doc);
} }
@ -340,13 +338,13 @@ bool ResListPager::getDoc(int num, Rcl::Doc& doc)
void ResListPager::displayPage(RclConfig *config) void ResListPager::displayPage(RclConfig *config)
{ {
LOGDEB(("ResListPager::displayPage\n")); LOGDEB("ResListPager::displayPage\n" );
if (!m_docSource) { if (!m_docSource) {
LOGDEB(("ResListPager::displayPage: null source\n")); LOGDEB("ResListPager::displayPage: null source\n" );
return; return;
} }
if (m_winfirst < 0 && !pageEmpty()) { if (m_winfirst < 0 && !pageEmpty()) {
LOGDEB(("ResListPager::displayPage: sequence error: winfirst < 0\n")); LOGDEB("ResListPager::displayPage: sequence error: winfirst < 0\n" );
return; return;
} }
@ -526,3 +524,4 @@ const string &ResListPager::dateFormat()
return cstr_format; return cstr_format;
} }

View file

@ -16,7 +16,7 @@
*/ */
#include <algorithm> #include <algorithm>
#include "debuglog.h" #include "log.h"
#include "sortseq.h" #include "sortseq.h"
using std::string; using std::string;
@ -30,7 +30,7 @@ public:
// behaves as operator< // behaves as operator<
int operator()(const Rcl::Doc *x, const Rcl::Doc *y) int operator()(const Rcl::Doc *x, const Rcl::Doc *y)
{ {
LOGDEB1(("Comparing .. \n")); LOGDEB1("Comparing .. \n" );
map<string,string>::const_iterator xit, yit; map<string,string>::const_iterator xit, yit;
xit = x->meta.find(ss.field); xit = x->meta.find(ss.field);
@ -43,15 +43,15 @@ public:
bool DocSeqSorted::setSortSpec(const DocSeqSortSpec &sortspec) bool DocSeqSorted::setSortSpec(const DocSeqSortSpec &sortspec)
{ {
LOGDEB(("DocSeqSorted::setSortSpec\n")); LOGDEB("DocSeqSorted::setSortSpec\n" );
m_spec = sortspec; m_spec = sortspec;
int count = m_seq->getResCnt(); int count = m_seq->getResCnt();
LOGDEB(("DocSeqSorted:: count %d\n", count)); LOGDEB("DocSeqSorted:: count " << (count) << "\n" );
m_docs.resize(count); m_docs.resize(count);
int i; int i;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (!m_seq->getDoc(i, m_docs[i])) { if (!m_seq->getDoc(i, m_docs[i])) {
LOGERR(("DocSeqSorted: getDoc failed for doc %d\n", i)); LOGERR("DocSeqSorted: getDoc failed for doc " << (i) << "\n" );
count = i; count = i;
break; break;
} }
@ -68,9 +68,10 @@ bool DocSeqSorted::setSortSpec(const DocSeqSortSpec &sortspec)
bool DocSeqSorted::getDoc(int num, Rcl::Doc &doc, string *) bool DocSeqSorted::getDoc(int num, Rcl::Doc &doc, string *)
{ {
LOGDEB(("DocSeqSorted::getDoc(%d)\n", num)); LOGDEB("DocSeqSorted::getDoc(" << (num) << ")\n" );
if (num < 0 || num >= int(m_docsp.size())) if (num < 0 || num >= int(m_docsp.size()))
return false; return false;
doc = *m_docsp[num]; doc = *m_docsp[num];
return true; return true;
} }

View file

@ -21,7 +21,7 @@
#include "wasatorcl.h" #include "wasatorcl.h"
#include "wasaparserdriver.h" #include "wasaparserdriver.h"
#include "searchdata.h" #include "searchdata.h"
#include "debuglog.h" #include "log.h"
#define YYDEBUG 1 #define YYDEBUG 1
@ -177,14 +177,12 @@ bool WasaParserDriver::addClause(SearchData *sd,
if (!fld.compare("date")) { if (!fld.compare("date")) {
DateInterval di; DateInterval di;
if (!parsedateinterval(cl->gettext(), &di)) { if (!parsedateinterval(cl->gettext(), &di)) {
LOGERR(("Bad date interval format: %s\n", LOGERR("Bad date interval format: " << (cl->gettext()) << "\n" );
cl->gettext().c_str()));
m_reason = "Bad date interval format"; m_reason = "Bad date interval format";
delete cl; delete cl;
return false; return false;
} }
LOGDEB(("addClause:: date span: %d-%d-%d/%d-%d-%d\n", LOGDEB("addClause:: date span: " << (di.y1) << "-" << (di.m1) << "-" << (di.d1) << "/" << (di.y2) << "-" << (di.m2) << "-" << (di.d2) << "\n" );
di.y1,di.m1,di.d1, di.y2,di.m2,di.d2));
m_haveDates = true; m_haveDates = true;
m_dates = di; m_dates = di;
delete cl; delete cl;
@ -268,3 +266,4 @@ bool WasaParserDriver::addClause(SearchData *sd,
} }
return sd->addClause(cl); return sd->addClause(cl);
} }

View file

@ -31,7 +31,7 @@ using namespace std;
#include <xapian.h> #include <xapian.h>
#include "debuglog.h" #include "log.h"
#include "rclconfig.h" #include "rclconfig.h"
namespace Rcl { namespace Rcl {
@ -124,3 +124,4 @@ Xapian::Query date_range_filter(int y1, int m1, int d1, int y2, int m2, int d2)
} }

View file

@ -20,7 +20,7 @@
#include MEMORY_INCLUDE #include MEMORY_INCLUDE
#include "debuglog.h" #include "log.h"
#include "utf8iter.h" #include "utf8iter.h"
#include "smallut.h" #include "smallut.h"
#include "chrono.h" #include "chrono.h"
@ -41,8 +41,7 @@ namespace Rcl {
bool createExpansionDbs(Xapian::WritableDatabase& wdb, bool createExpansionDbs(Xapian::WritableDatabase& wdb,
const vector<string>& langs) const vector<string>& langs)
{ {
LOGDEB(("StemDb::createExpansionDbs: languages: %s\n", LOGDEB("StemDb::createExpansionDbs: languages: " << (stringsToString(langs)) << "\n" );
stringsToString(langs).c_str()));
Chrono cron; Chrono cron;
// Erase and recreate all the expansion groups // Erase and recreate all the expansion groups
@ -102,7 +101,7 @@ bool createExpansionDbs(Xapian::WritableDatabase& wdb,
if (utfit.eof()) // Empty term?? Seems to happen. if (utfit.eof()) // Empty term?? Seems to happen.
continue; continue;
if (TextSplit::isCJK(*utfit)) { if (TextSplit::isCJK(*utfit)) {
// LOGDEB(("stemskipped: Skipping CJK\n")); // LOGDEB("stemskipped: Skipping CJK\n" );
continue; continue;
} }
@ -119,7 +118,7 @@ bool createExpansionDbs(Xapian::WritableDatabase& wdb,
// Dont' apply stemming to terms which don't look like // Dont' apply stemming to terms which don't look like
// natural language words. // natural language words.
if (!Db::isSpellingCandidate(*it)) { if (!Db::isSpellingCandidate(*it)) {
LOGDEB1(("createExpansionDbs: skipped: [%s]\n", (*it).c_str())); LOGDEB1("createExpansionDbs: skipped: [" << ((*it)) << "]\n" );
continue; continue;
} }
@ -145,12 +144,13 @@ bool createExpansionDbs(Xapian::WritableDatabase& wdb,
} }
} XCATCHERROR(ermsg); } XCATCHERROR(ermsg);
if (!ermsg.empty()) { if (!ermsg.empty()) {
LOGERR(("Db::createStemDb: map build failed: %s\n", ermsg.c_str())); LOGERR("Db::createStemDb: map build failed: " << (ermsg) << "\n" );
return false; return false;
} }
LOGDEB(("StemDb::createExpansionDbs: done: %.2f S\n", cron.secs())); LOGDEB("StemDb::createExpansionDbs: done: " << (cron.secs()) << " S\n" );
return true; return true;
} }
} }

View file

@ -20,7 +20,7 @@
#include <map> #include <map>
#include "debuglog.h" #include "log.h"
#include "rcldb.h" #include "rcldb.h"
#include "rcldb_p.h" #include "rcldb_p.h"
#include "rclquery.h" #include "rclquery.h"
@ -50,7 +50,7 @@ static void listList(const string& what, const vector<string>&l)
for (vector<string>::const_iterator it = l.begin(); it != l.end(); it++) { for (vector<string>::const_iterator it = l.begin(); it != l.end(); it++) {
a = a + *it + " "; a = a + *it + " ";
} }
LOGDEB(("%s: %s\n", what.c_str(), a.c_str())); LOGDEB("" << (what) << ": " << (a) << "\n" );
} }
#else #else
#define LOGABS LOGDEB2 #define LOGABS LOGDEB2
@ -82,7 +82,7 @@ static void noPrefixList(const vector<string>& in, vector<string>& out)
bool Query::Native::getMatchTerms(unsigned long xdocid, vector<string>& terms) bool Query::Native::getMatchTerms(unsigned long xdocid, vector<string>& terms)
{ {
if (!xenquire) { if (!xenquire) {
LOGERR(("Query::getMatchTerms: no query opened\n")); LOGERR("Query::getMatchTerms: no query opened\n" );
return false; return false;
} }
@ -95,7 +95,7 @@ bool Query::Native::getMatchTerms(unsigned long xdocid, vector<string>& terms)
xenquire->get_matching_terms_end(id)), xenquire->get_matching_terms_end(id)),
m_q->m_db->m_ndb->xrdb, m_q->m_reason); m_q->m_db->m_ndb->xrdb, m_q->m_reason);
if (!m_q->m_reason.empty()) { if (!m_q->m_reason.empty()) {
LOGERR(("getMatchTerms: xapian error: %s\n", m_q->m_reason.c_str())); LOGERR("getMatchTerms: xapian error: " << (m_q->m_reason) << "\n" );
return false; return false;
} }
noPrefixList(iterms, terms); noPrefixList(iterms, terms);
@ -178,7 +178,7 @@ double Query::Native::qualityTerms(Xapian::docid docid,
if (eit != hld.terms.end()) { if (eit != hld.terms.end()) {
byRoot[eit->second].push_back(*qit); byRoot[eit->second].push_back(*qit);
} else { } else {
LOGDEB0(("qualityTerms: [%s] not found in hld\n", (*qit).c_str())); LOGDEB0("qualityTerms: [" << ((*qit)) << "] not found in hld\n" );
byRoot[*qit].push_back(*qit); byRoot[*qit].push_back(*qit);
} }
} }
@ -257,7 +257,7 @@ double Query::Native::qualityTerms(Xapian::docid docid,
int Query::Native::getFirstMatchPage(Xapian::docid docid, string& term) int Query::Native::getFirstMatchPage(Xapian::docid docid, string& term)
{ {
if (!m_q|| !m_q->m_db || !m_q->m_db->m_ndb || !m_q->m_db->m_ndb->m_isopen) { if (!m_q|| !m_q->m_db || !m_q->m_db->m_ndb || !m_q->m_db->m_ndb->m_isopen) {
LOGERR(("Query::getFirstMatchPage: no db\n")); LOGERR("Query::getFirstMatchPage: no db\n" );
return -1; return -1;
} }
Rcl::Db::Native *ndb(m_q->m_db->m_ndb); Rcl::Db::Native *ndb(m_q->m_db->m_ndb);
@ -267,7 +267,7 @@ int Query::Native::getFirstMatchPage(Xapian::docid docid, string& term)
getMatchTerms(docid, terms); getMatchTerms(docid, terms);
if (terms.empty()) { if (terms.empty()) {
LOGDEB(("getFirstMatchPage: empty match term list (field match?)\n")); LOGDEB("getFirstMatchPage: empty match term list (field match?)\n" );
return -1; return -1;
} }
@ -322,7 +322,7 @@ int Query::Native::makeAbstract(Xapian::docid docid,
vector<string> matchedTerms; vector<string> matchedTerms;
getMatchTerms(docid, matchedTerms); getMatchTerms(docid, matchedTerms);
if (matchedTerms.empty()) { if (matchedTerms.empty()) {
LOGDEB(("makeAbstract::Empty term list\n")); LOGDEB("makeAbstract::Empty term list\n" );
return ABSRES_ERROR; return ABSRES_ERROR;
} }
@ -342,7 +342,7 @@ int Query::Native::makeAbstract(Xapian::docid docid,
LOGABS(("makeAbstract:%d: computed Qcoefs.\n", chron.ms())); LOGABS(("makeAbstract:%d: computed Qcoefs.\n", chron.ms()));
// This can't happen, but would crash us // This can't happen, but would crash us
if (totalweight == 0.0) { if (totalweight == 0.0) {
LOGERR(("makeAbstract: totalweight == 0.0 !\n")); LOGERR("makeAbstract: totalweight == 0.0 !\n" );
return ABSRES_ERROR; return ABSRES_ERROR;
} }
@ -494,7 +494,7 @@ int Query::Native::makeAbstract(Xapian::docid docid,
// This can happen if there are term occurences in the keywords // This can happen if there are term occurences in the keywords
// etc. but not elsewhere ? // etc. but not elsewhere ?
if (totaloccs == 0) { if (totaloccs == 0) {
LOGDEB(("makeAbstract: no occurrences\n")); LOGDEB("makeAbstract: no occurrences\n" );
return ABSRES_OK; return ABSRES_OK;
} }
@ -513,8 +513,7 @@ int Query::Native::makeAbstract(Xapian::docid docid,
continue; continue;
if (m_q->m_snipMaxPosWalk > 0 && cutoff-- < 0) { if (m_q->m_snipMaxPosWalk > 0 && cutoff-- < 0) {
ret |= ABSRES_TERMMISS; ret |= ABSRES_TERMMISS;
LOGDEB0(("makeAbstract: max term count cutoff %d\n", LOGDEB0("makeAbstract: max term count cutoff " << (m_q->m_snipMaxPosWalk) << "\n" );
m_q->m_snipMaxPosWalk));
break; break;
} }
@ -524,8 +523,7 @@ int Query::Native::makeAbstract(Xapian::docid docid,
pos != xrdb.positionlist_end(docid, *term); pos++) { pos != xrdb.positionlist_end(docid, *term); pos++) {
if (m_q->m_snipMaxPosWalk > 0 && cutoff-- < 0) { if (m_q->m_snipMaxPosWalk > 0 && cutoff-- < 0) {
ret |= ABSRES_TERMMISS; ret |= ABSRES_TERMMISS;
LOGDEB0(("makeAbstract: max term count cutoff %d\n", LOGDEB0("makeAbstract: max term count cutoff " << (m_q->m_snipMaxPosWalk) << "\n" );
m_q->m_snipMaxPosWalk));
break; break;
} }
// If we are beyond the max possible position, stop // If we are beyond the max possible position, stop
@ -539,8 +537,7 @@ int Query::Native::makeAbstract(Xapian::docid docid,
// at the same position, we want to keep only the // at the same position, we want to keep only the
// first one (ie: dockes and dockes@wanadoo.fr) // first one (ie: dockes and dockes@wanadoo.fr)
if (vit->second.empty()) { if (vit->second.empty()) {
LOGDEB2(("makeAbstract: populating: [%s] at %d\n", LOGDEB2("makeAbstract: populating: [" << ((*term)) << "] at " << (*pos) << "\n" );
(*term).c_str(), *pos));
sparseDoc[*pos] = *term; sparseDoc[*pos] = *term;
} }
} }
@ -557,11 +554,11 @@ int Query::Native::makeAbstract(Xapian::docid docid,
it++, ipos++) { it++, ipos++) {
if (it->empty()) { if (it->empty()) {
if (!epty) if (!epty)
LOGDEB(("makeAbstract:vec[%d]: [%s]\n", ipos, it->c_str())); LOGDEB("makeAbstract:vec[" << (ipos) << "]: [" << (it) << "]\n" );
epty=true; epty=true;
} else { } else {
epty = false; epty = false;
LOGDEB(("makeAbstract:vec[%d]: [%s]\n", ipos, it->c_str())); LOGDEB("makeAbstract:vec[" << (ipos) << "]: [" << (it) << "]\n" );
} }
} }
#endif #endif
@ -579,9 +576,9 @@ int Query::Native::makeAbstract(Xapian::docid docid,
string term; string term;
for (map<unsigned int, string>::const_iterator it = sparseDoc.begin(); for (map<unsigned int, string>::const_iterator it = sparseDoc.begin();
it != sparseDoc.end(); it++) { it != sparseDoc.end(); it++) {
LOGDEB2(("Abtract:output %u -> [%s]\n", it->first, it->second.c_str())); LOGDEB2("Abtract:output " << (it->first) << " -> [" << (it->second) << "]\n" );
if (!occupiedmarker.compare(it->second)) { if (!occupiedmarker.compare(it->second)) {
LOGDEB(("Abstract: qtrm position not filled ??\n")); LOGDEB("Abstract: qtrm position not filled ??\n" );
continue; continue;
} }
if (chunk.empty() && !vpbreaks.empty()) { if (chunk.empty() && !vpbreaks.empty()) {
@ -611,9 +608,10 @@ int Query::Native::makeAbstract(Xapian::docid docid,
if (!chunk.empty()) if (!chunk.empty())
vabs.push_back(Snippet(page, chunk).setTerm(term)); vabs.push_back(Snippet(page, chunk).setTerm(term));
LOGDEB2(("makeAbtract: done in %d mS\n", chron.millis())); LOGDEB2("makeAbtract: done in " << (chron.millis()) << " mS\n" );
return ret; return ret;
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -27,7 +27,6 @@
#ifdef IDX_THREADS #ifdef IDX_THREADS
#include "workqueue.h" #include "workqueue.h"
#endif // IDX_THREADS #endif // IDX_THREADS
#include "debuglog.h"
#include "xmacros.h" #include "xmacros.h"
#include "ptmutex.h" #include "ptmutex.h"
@ -82,7 +81,6 @@ class Db::Native {
bool m_noversionwrite; //Set if open failed because of version mismatch! bool m_noversionwrite; //Set if open failed because of version mismatch!
#ifdef IDX_THREADS #ifdef IDX_THREADS
WorkQueue<DbUpdTask*> m_wqueue; WorkQueue<DbUpdTask*> m_wqueue;
int m_loglevel;
PTMutexInit m_mutex; PTMutexInit m_mutex;
long long m_totalworkns; long long m_totalworkns;
bool m_havewriteq; bool m_havewriteq;

View file

@ -17,7 +17,7 @@
#include "autoconfig.h" #include "autoconfig.h"
#include "rcldoc.h" #include "rcldoc.h"
#include "debuglog.h" #include "log.h"
#include "rclutil.h" #include "rclutil.h"
namespace Rcl { namespace Rcl {
@ -50,27 +50,26 @@ namespace Rcl {
void Doc::dump(bool dotext) const void Doc::dump(bool dotext) const
{ {
LOGDEB(("Rcl::Doc::dump: url: [%s]\n", url.c_str())); LOGDEB("Rcl::Doc::dump: url: [" << (url) << "]\n" );
LOGDEB(("Rcl::Doc::dump: idxurl: [%s]\n", idxurl.c_str())); LOGDEB("Rcl::Doc::dump: idxurl: [" << (idxurl) << "]\n" );
LOGDEB(("Rcl::Doc::dump: ipath: [%s]\n", ipath.c_str())); LOGDEB("Rcl::Doc::dump: ipath: [" << (ipath) << "]\n" );
LOGDEB(("Rcl::Doc::dump: mimetype: [%s]\n", mimetype.c_str())); LOGDEB("Rcl::Doc::dump: mimetype: [" << (mimetype) << "]\n" );
LOGDEB(("Rcl::Doc::dump: fmtime: [%s]\n", fmtime.c_str())); LOGDEB("Rcl::Doc::dump: fmtime: [" << (fmtime) << "]\n" );
LOGDEB(("Rcl::Doc::dump: dmtime: [%s]\n", dmtime.c_str())); LOGDEB("Rcl::Doc::dump: dmtime: [" << (dmtime) << "]\n" );
LOGDEB(("Rcl::Doc::dump: origcharset: [%s]\n", origcharset.c_str())); LOGDEB("Rcl::Doc::dump: origcharset: [" << (origcharset) << "]\n" );
LOGDEB(("Rcl::Doc::dump: syntabs: [%d]\n", syntabs)); LOGDEB("Rcl::Doc::dump: syntabs: [" << (syntabs) << "]\n" );
LOGDEB(("Rcl::Doc::dump: pcbytes: [%s]\n", pcbytes.c_str())); LOGDEB("Rcl::Doc::dump: pcbytes: [" << (pcbytes) << "]\n" );
LOGDEB(("Rcl::Doc::dump: fbytes: [%s]\n", fbytes.c_str())); LOGDEB("Rcl::Doc::dump: fbytes: [" << (fbytes) << "]\n" );
LOGDEB(("Rcl::Doc::dump: dbytes: [%s]\n", dbytes.c_str())); LOGDEB("Rcl::Doc::dump: dbytes: [" << (dbytes) << "]\n" );
LOGDEB(("Rcl::Doc::dump: sig: [%s]\n", sig.c_str())); LOGDEB("Rcl::Doc::dump: sig: [" << (sig) << "]\n" );
LOGDEB(("Rcl::Doc::dump: pc: [%d]\n", pc)); LOGDEB("Rcl::Doc::dump: pc: [" << (pc) << "]\n" );
LOGDEB(("Rcl::Doc::dump: xdocid: [%lu]\n", (unsigned long)xdocid)); LOGDEB("Rcl::Doc::dump: xdocid: [" << ((unsigned long)xdocid) << "]\n" );
for (map<string, string>::const_iterator it = meta.begin(); for (map<string, string>::const_iterator it = meta.begin();
it != meta.end(); it++) { it != meta.end(); it++) {
LOGDEB(("Rcl::Doc::dump: meta[%s]: [%s]\n", LOGDEB("Rcl::Doc::dump: meta[" << ((*it).first) << "]: [" << ((*it).second) << "]\n" );
(*it).first.c_str(), (*it).second.c_str()));
} }
if (dotext) if (dotext)
LOGDEB(("Rcl::Doc::dump: text: \n[%s]\n", text.c_str())); LOGDEB("Rcl::Doc::dump: text: \n[" << (text) << "]\n" );
} }
// Copy ensuring no shared string data, for threading issues. // Copy ensuring no shared string data, for threading issues.
@ -100,3 +99,4 @@ namespace Rcl {
} }
} }

View file

@ -24,7 +24,7 @@ using namespace std;
#include <xapian.h> #include <xapian.h>
#include "debuglog.h" #include "log.h"
#include "rcldb.h" #include "rcldb.h"
#include "rcldb_p.h" #include "rcldb_p.h"
#include "xmacros.h" #include "xmacros.h"
@ -39,11 +39,11 @@ namespace Rcl {
bool Db::docDups(const Doc& idoc, vector<Doc>& odocs) bool Db::docDups(const Doc& idoc, vector<Doc>& odocs)
{ {
if (m_ndb == 0) { if (m_ndb == 0) {
LOGERR(("Db::docDups: no db\n")); LOGERR("Db::docDups: no db\n" );
return false; return false;
} }
if (idoc.xdocid == 0) { if (idoc.xdocid == 0) {
LOGERR(("Db::docDups: null xdocid in input doc\n")); LOGERR("Db::docDups: null xdocid in input doc\n" );
return false; return false;
} }
// Get the xapian doc // Get the xapian doc
@ -51,7 +51,7 @@ bool Db::docDups(const Doc& idoc, vector<Doc>& odocs)
XAPTRY(xdoc = m_ndb->xrdb.get_document(Xapian::docid(idoc.xdocid)), XAPTRY(xdoc = m_ndb->xrdb.get_document(Xapian::docid(idoc.xdocid)),
m_ndb->xrdb, m_reason); m_ndb->xrdb, m_reason);
if (!m_reason.empty()) { if (!m_reason.empty()) {
LOGERR(("Db::docDups: xapian error: %s\n", m_reason.c_str())); LOGERR("Db::docDups: xapian error: " << (m_reason) << "\n" );
return false; return false;
} }
@ -59,11 +59,11 @@ bool Db::docDups(const Doc& idoc, vector<Doc>& odocs)
string digest; string digest;
XAPTRY(digest = xdoc.get_value(VALUE_MD5), m_ndb->xrdb, m_reason); XAPTRY(digest = xdoc.get_value(VALUE_MD5), m_ndb->xrdb, m_reason);
if (!m_reason.empty()) { if (!m_reason.empty()) {
LOGERR(("Db::docDups: xapian error: %s\n", m_reason.c_str())); LOGERR("Db::docDups: xapian error: " << (m_reason) << "\n" );
return false; return false;
} }
if (digest.empty()) { if (digest.empty()) {
LOGDEB(("Db::docDups: doc has no md5\n")); LOGDEB("Db::docDups: doc has no md5\n" );
return false; return false;
} }
string md5; string md5;
@ -79,14 +79,14 @@ bool Db::docDups(const Doc& idoc, vector<Doc>& odocs)
Query query(this); Query query(this);
query.setCollapseDuplicates(0); query.setCollapseDuplicates(0);
if (!query.setQuery(sd)) { if (!query.setQuery(sd)) {
LOGERR(("Db::docDups: setQuery failed\n")); LOGERR("Db::docDups: setQuery failed\n" );
return false; return false;
} }
int cnt = query.getResCnt(); int cnt = query.getResCnt();
for (int i = 0; i < cnt; i++) { for (int i = 0; i < cnt; i++) {
Doc doc; Doc doc;
if (!query.getDoc(i, doc)) { if (!query.getDoc(i, doc)) {
LOGERR(("Db::docDups: getDoc failed at %d (cnt %d)\n", i, cnt)); LOGERR("Db::docDups: getDoc failed at " << (i) << " (cnt " << (cnt) << ")\n" );
return false; return false;
} }
odocs.push_back(doc); odocs.push_back(doc);
@ -98,18 +98,19 @@ bool Db::docDups(const Doc& idoc, vector<Doc>& odocs)
{ {
vector<Doc> dups; vector<Doc> dups;
bool ret; bool ret;
LOGDEB(("DOCDUPS\n")); LOGDEB("DOCDUPS\n" );
ret = m_db->docDups(doc, dups); ret = m_db->docDups(doc, dups);
if (!ret) { if (!ret) {
LOGDEB(("docDups failed\n")); LOGDEB("docDups failed\n" );
} else if (dups.size() == 1) { } else if (dups.size() == 1) {
LOGDEB(("No dups\n")); LOGDEB("No dups\n" );
} else { } else {
for (unsigned int i = 0; i < dups.size(); i++) { for (unsigned int i = 0; i < dups.size(); i++) {
LOGDEB(("Dup: %s\n", dups[i].url.c_str())); LOGDEB("Dup: " << (dups[i].url) << "\n" );
} }
} }
} }
#endif #endif
} }

View file

@ -27,7 +27,7 @@
#include "cstr.h" #include "cstr.h"
#include "rclconfig.h" #include "rclconfig.h"
#include "debuglog.h" #include "log.h"
#include "rcldb.h" #include "rcldb.h"
#include "rcldb_p.h" #include "rcldb_p.h"
#include "rclquery.h" #include "rclquery.h"
@ -132,7 +132,7 @@ public:
sortterm = sortterm.substr(i1, sortterm.size()-i1); sortterm = sortterm.substr(i1, sortterm.size()-i1);
} }
LOGDEB2(("QSorter: [%s] -> [%s]\n", term.c_str(), sortterm.c_str())); LOGDEB2("QSorter: [" << (term) << "] -> [" << (sortterm) << "]\n" );
return sortterm; return sortterm;
} }
@ -166,8 +166,7 @@ void Query::setSortBy(const string& fld, bool ascending) {
m_sortField = m_db->getConf()->fieldQCanon(fld); m_sortField = m_db->getConf()->fieldQCanon(fld);
m_sortAscending = ascending; m_sortAscending = ascending;
} }
LOGDEB0(("RclQuery::setSortBy: [%s] %s\n", m_sortField.c_str(), LOGDEB0("RclQuery::setSortBy: [" << (m_sortField) << "] " << (m_sortAscending ? "ascending" : "descending") << "\n" );
m_sortAscending ? "ascending" : "descending"));
} }
//#define ISNULL(X) (X).isNull() //#define ISNULL(X) (X).isNull()
@ -176,10 +175,10 @@ void Query::setSortBy(const string& fld, bool ascending) {
// Prepare query out of user search data // Prepare query out of user search data
bool Query::setQuery(STD_SHARED_PTR<SearchData> sdata) bool Query::setQuery(STD_SHARED_PTR<SearchData> sdata)
{ {
LOGDEB(("Query::setQuery:\n")); LOGDEB("Query::setQuery:\n" );
if (!m_db || ISNULL(m_nq)) { if (!m_db || ISNULL(m_nq)) {
LOGERR(("Query::setQuery: not initialised!\n")); LOGERR("Query::setQuery: not initialised!\n" );
return false; return false;
} }
m_resCnt = -1; m_resCnt = -1;
@ -233,7 +232,7 @@ bool Query::setQuery(STD_SHARED_PTR<SearchData> sdata)
} }
if (!m_reason.empty()) { if (!m_reason.empty()) {
LOGDEB(("Query::SetQuery: xapian error %s\n", m_reason.c_str())); LOGDEB("Query::SetQuery: xapian error " << (m_reason) << "\n" );
return false; return false;
} }
@ -242,7 +241,7 @@ bool Query::setQuery(STD_SHARED_PTR<SearchData> sdata)
sdata->setDescription(d); sdata->setDescription(d);
m_sd = sdata; m_sd = sdata;
LOGDEB(("Query::SetQuery: Q: %s\n", sdata->getDescription().c_str())); LOGDEB("Query::SetQuery: Q: " << (sdata->getDescription()) << "\n" );
return true; return true;
} }
@ -261,7 +260,7 @@ bool Query::getQueryTerms(vector<string>& terms)
} }
} XCATCHERROR(ermsg); } XCATCHERROR(ermsg);
if (!ermsg.empty()) { if (!ermsg.empty()) {
LOGERR(("getQueryTerms: xapian error: %s\n", ermsg.c_str())); LOGERR("getQueryTerms: xapian error: " << (ermsg) << "\n" );
return false; return false;
} }
return true; return true;
@ -271,17 +270,16 @@ int Query::makeDocAbstract(const Doc &doc,
vector<Snippet>& abstract, vector<Snippet>& abstract,
int maxoccs, int ctxwords) int maxoccs, int ctxwords)
{ {
LOGDEB(("makeDocAbstract: maxoccs %d ctxwords %d\n", maxoccs, ctxwords)); LOGDEB("makeDocAbstract: maxoccs " << (maxoccs) << " ctxwords " << (ctxwords) << "\n" );
if (!m_db || !m_db->m_ndb || !m_db->m_ndb->m_isopen || !m_nq) { if (!m_db || !m_db->m_ndb || !m_db->m_ndb->m_isopen || !m_nq) {
LOGERR(("Query::makeDocAbstract: no db or no nq\n")); LOGERR("Query::makeDocAbstract: no db or no nq\n" );
return ABSRES_ERROR; return ABSRES_ERROR;
} }
int ret = ABSRES_ERROR; int ret = ABSRES_ERROR;
XAPTRY(ret = m_nq->makeAbstract(doc.xdocid, abstract, maxoccs, ctxwords), XAPTRY(ret = m_nq->makeAbstract(doc.xdocid, abstract, maxoccs, ctxwords),
m_db->m_ndb->xrdb, m_reason); m_db->m_ndb->xrdb, m_reason);
if (!m_reason.empty()) { if (!m_reason.empty()) {
LOGDEB(("makeDocAbstract: makeAbstract error, reason: %s\n", LOGDEB("makeDocAbstract: makeAbstract error, reason: " << (m_reason) << "\n" );
m_reason.c_str()));
return ABSRES_ERROR; return ABSRES_ERROR;
} }
return ret; return ret;
@ -321,9 +319,9 @@ bool Query::makeDocAbstract(const Doc &doc, string& abstract)
int Query::getFirstMatchPage(const Doc &doc, string& term) int Query::getFirstMatchPage(const Doc &doc, string& term)
{ {
LOGDEB1(("Db::getFirstMatchPage\n"));; LOGDEB1("Db::getFirstMatchPage\n" );;
if (!m_nq) { if (!m_nq) {
LOGERR(("Query::getFirstMatchPage: no nq\n")); LOGERR("Query::getFirstMatchPage: no nq\n" );
return false; return false;
} }
int pagenum = -1; int pagenum = -1;
@ -341,7 +339,7 @@ static const int qquantum = 50;
int Query::getResCnt() int Query::getResCnt()
{ {
if (ISNULL(m_nq) || !m_nq->xenquire) { if (ISNULL(m_nq) || !m_nq->xenquire) {
LOGERR(("Query::getResCnt: no query opened\n")); LOGERR("Query::getResCnt: no query opened\n" );
return -1; return -1;
} }
if (m_resCnt >= 0) if (m_resCnt >= 0)
@ -356,9 +354,9 @@ int Query::getResCnt()
m_resCnt = m_nq->xmset.get_matches_lower_bound(), m_resCnt = m_nq->xmset.get_matches_lower_bound(),
m_db->m_ndb->xrdb, m_reason); m_db->m_ndb->xrdb, m_reason);
LOGDEB(("Query::getResCnt: %d %d mS\n", m_resCnt, chron.millis())); LOGDEB("Query::getResCnt: " << (m_resCnt) << " " << (chron.millis()) << " mS\n" );
if (!m_reason.empty()) if (!m_reason.empty())
LOGERR(("xenquire->get_mset: exception: %s\n", m_reason.c_str())); LOGERR("xenquire->get_mset: exception: " << (m_reason) << "\n" );
} else { } else {
m_resCnt = m_nq->xmset.get_matches_lower_bound(); m_resCnt = m_nq->xmset.get_matches_lower_bound();
} }
@ -375,9 +373,9 @@ int Query::getResCnt()
// on subsequent calls is probably only due to disk caching. // on subsequent calls is probably only due to disk caching.
bool Query::getDoc(int xapi, Doc &doc) bool Query::getDoc(int xapi, Doc &doc)
{ {
LOGDEB1(("Query::getDoc: xapian enquire index %d\n", xapi)); LOGDEB1("Query::getDoc: xapian enquire index " << (xapi) << "\n" );
if (ISNULL(m_nq) || !m_nq->xenquire) { if (ISNULL(m_nq) || !m_nq->xenquire) {
LOGERR(("Query::getDoc: no query opened\n")); LOGERR("Query::getDoc: no query opened\n" );
return false; return false;
} }
@ -385,28 +383,24 @@ bool Query::getDoc(int xapi, Doc &doc)
int last = first + m_nq->xmset.size() -1; int last = first + m_nq->xmset.size() -1;
if (!(xapi >= first && xapi <= last)) { if (!(xapi >= first && xapi <= last)) {
LOGDEB(("Fetching for first %d, count %d\n", xapi, qquantum)); LOGDEB("Fetching for first " << (xapi) << ", count " << (qquantum) << "\n" );
XAPTRY(m_nq->xmset = m_nq->xenquire->get_mset(xapi, qquantum, XAPTRY(m_nq->xmset = m_nq->xenquire->get_mset(xapi, qquantum,
(const Xapian::RSet *)0), (const Xapian::RSet *)0),
m_db->m_ndb->xrdb, m_reason); m_db->m_ndb->xrdb, m_reason);
if (!m_reason.empty()) { if (!m_reason.empty()) {
LOGERR(("enquire->get_mset: exception: %s\n", m_reason.c_str())); LOGERR("enquire->get_mset: exception: " << (m_reason) << "\n" );
return false; return false;
} }
if (m_nq->xmset.empty()) { if (m_nq->xmset.empty()) {
LOGDEB(("enquire->get_mset: got empty result\n")); LOGDEB("enquire->get_mset: got empty result\n" );
return false; return false;
} }
first = m_nq->xmset.get_firstitem(); first = m_nq->xmset.get_firstitem();
last = first + m_nq->xmset.size() -1; last = first + m_nq->xmset.size() -1;
} }
LOGDEB1(("Query::getDoc: Qry [%s] win [%d-%d] Estimated results: %d",
m_nq->query.get_description().c_str(),
first, last, m_nq->xmset.get_matches_lower_bound()));
Xapian::Document xdoc; Xapian::Document xdoc;
Xapian::docid docid = 0; Xapian::docid docid = 0;
int pc = 0; int pc = 0;
@ -424,8 +418,7 @@ bool Query::getDoc(int xapi, Doc &doc)
m_reason.erase(); m_reason.erase();
Chrono chron; Chrono chron;
m_db->m_ndb->xdocToUdi(xdoc, udi); m_db->m_ndb->xdocToUdi(xdoc, udi);
LOGDEB2(("Query::getDoc: %d ms for udi [%s], collapse count %d\n", LOGDEB2("Query::getDoc: " << (chron.millis()) << " ms for udi [" << (udi) << "], collapse count " << (collapsecount) << "\n" );
chron.millis(), udi.c_str(), collapsecount));
break; break;
} catch (Xapian::DatabaseModifiedError &error) { } catch (Xapian::DatabaseModifiedError &error) {
// retry or end of loop // retry or end of loop
@ -436,7 +429,7 @@ bool Query::getDoc(int xapi, Doc &doc)
break; break;
} }
if (!m_reason.empty()) { if (!m_reason.empty()) {
LOGERR(("Query::getDoc: %s\n", m_reason.c_str())); LOGERR("Query::getDoc: " << (m_reason) << "\n" );
return false; return false;
} }
doc.meta[Rcl::Doc::keyudi] = udi; doc.meta[Rcl::Doc::keyudi] = udi;
@ -461,10 +454,10 @@ bool Query::getDoc(int xapi, Doc &doc)
vector<string> Query::expand(const Doc &doc) vector<string> Query::expand(const Doc &doc)
{ {
LOGDEB(("Rcl::Query::expand()\n")); LOGDEB("Rcl::Query::expand()\n" );
vector<string> res; vector<string> res;
if (ISNULL(m_nq) || !m_nq->xenquire) { if (ISNULL(m_nq) || !m_nq->xenquire) {
LOGERR(("Query::expand: no query opened\n")); LOGERR("Query::expand: no query opened\n" );
return res; return res;
} }
@ -474,11 +467,11 @@ vector<string> Query::expand(const Doc &doc)
rset.add_document(Xapian::docid(doc.xdocid)); rset.add_document(Xapian::docid(doc.xdocid));
// We don't exclude the original query terms. // We don't exclude the original query terms.
Xapian::ESet eset = m_nq->xenquire->get_eset(20, rset, false); Xapian::ESet eset = m_nq->xenquire->get_eset(20, rset, false);
LOGDEB(("ESet terms:\n")); LOGDEB("ESet terms:\n" );
// We filter out the special terms // We filter out the special terms
for (Xapian::ESetIterator it = eset.begin(); for (Xapian::ESetIterator it = eset.begin();
it != eset.end(); it++) { it != eset.end(); it++) {
LOGDEB((" [%s]\n", (*it).c_str())); LOGDEB(" [" << ((*it)) << "]\n" );
if ((*it).empty() || has_prefix(*it)) if ((*it).empty() || has_prefix(*it))
continue; continue;
res.push_back(*it); res.push_back(*it);
@ -496,7 +489,7 @@ vector<string> Query::expand(const Doc &doc)
} }
if (!m_reason.empty()) { if (!m_reason.empty()) {
LOGERR(("Query::expand: xapian error %s\n", m_reason.c_str())); LOGERR("Query::expand: xapian error " << (m_reason) << "\n" );
res.clear(); res.clear();
} }
@ -504,3 +497,4 @@ vector<string> Query::expand(const Doc &doc)
} }
} }

View file

@ -22,7 +22,7 @@
#include <string> #include <string>
#include "debuglog.h" #include "log.h"
#include "rcldb.h" #include "rcldb.h"
#include "rcldb_p.h" #include "rcldb_p.h"
#include "stemdb.h" #include "stemdb.h"
@ -49,7 +49,7 @@ bool Db::filenameWildExp(const string& fnexp, vector<string>& names, int max)
pattern = "*" + pattern + "*"; pattern = "*" + pattern + "*";
} // else let it be } // else let it be
LOGDEB(("Rcl::Db::filenameWildExp: pattern: [%s]\n", pattern.c_str())); LOGDEB("Rcl::Db::filenameWildExp: pattern: [" << (pattern) << "]\n" );
// We inconditionnally lowercase and strip the pattern, as is done // We inconditionnally lowercase and strip the pattern, as is done
// during indexing. This seems to be the only sane possible // during indexing. This seems to be the only sane possible
@ -79,12 +79,12 @@ bool Db::filenameWildExp(const string& fnexp, vector<string>& names, int max)
// Walk the Y terms and return min/max // Walk the Y terms and return min/max
bool Db::maxYearSpan(int *minyear, int *maxyear) bool Db::maxYearSpan(int *minyear, int *maxyear)
{ {
LOGDEB(("Rcl::Db:maxYearSpan\n")); LOGDEB("Rcl::Db:maxYearSpan\n" );
*minyear = 1000000; *minyear = 1000000;
*maxyear = -1000000; *maxyear = -1000000;
TermMatchResult result; TermMatchResult result;
if (!idxTermMatch(ET_WILD, string(), "*", result, -1, "xapyear")) { if (!idxTermMatch(ET_WILD, string(), "*", result, -1, "xapyear")) {
LOGINFO(("Rcl::Db:maxYearSpan: termMatch failed\n")); LOGINFO("Rcl::Db:maxYearSpan: termMatch failed\n" );
return false; return false;
} }
for (vector<TermMatchEntry>::const_iterator it = result.entries.begin(); for (vector<TermMatchEntry>::const_iterator it = result.entries.begin();
@ -165,11 +165,7 @@ bool Db::termMatch(int typ_sens, const string &lang, const string &_term,
bool diac_sensitive = (typ_sens & ET_DIACSENS) != 0; bool diac_sensitive = (typ_sens & ET_DIACSENS) != 0;
bool case_sensitive = (typ_sens & ET_CASESENS) != 0; bool case_sensitive = (typ_sens & ET_CASESENS) != 0;
LOGDEB0(("Db::TermMatch: typ %s diacsens %d casesens %d lang [%s] term [%s]" LOGDEB0("Db::TermMatch: typ " << (tmtptostr(matchtyp)) << " diacsens " << (diac_sensitive) << " casesens " << (case_sensitive) << " lang [" << (lang) << "] term [" << (_term) << "] max " << (max) << " field [" << (field) << "] stripped " << (o_index_stripchars) << " init res.size " << (res.entries.size()) << "\n" );
" max %d field [%s] stripped %d init res.size %u\n",
tmtptostr(matchtyp), diac_sensitive, case_sensitive, lang.c_str(),
_term.c_str(), max, field.c_str(), o_index_stripchars,
res.entries.size()));
// If index is stripped, no case or diac expansion can be needed: // If index is stripped, no case or diac expansion can be needed:
// for the processing inside this routine, everything looks like // for the processing inside this routine, everything looks like
@ -179,7 +175,7 @@ bool Db::termMatch(int typ_sens, const string &lang, const string &_term,
if (o_index_stripchars) { if (o_index_stripchars) {
diac_sensitive = case_sensitive = true; diac_sensitive = case_sensitive = true;
if (!unacmaybefold(_term, term, "UTF-8", UNACOP_UNACFOLD)) { if (!unacmaybefold(_term, term, "UTF-8", UNACOP_UNACFOLD)) {
LOGERR(("Db::termMatch: unac failed for [%s]\n", _term.c_str())); LOGERR("Db::termMatch: unac failed for [" << (_term) << "]\n" );
return false; return false;
} }
} }
@ -270,19 +266,17 @@ bool Db::termMatch(int typ_sens, const string &lang, const string &_term,
exp1.swap(lexp); exp1.swap(lexp);
sort(lexp.begin(), lexp.end()); sort(lexp.begin(), lexp.end());
lexp.erase(unique(lexp.begin(), lexp.end()), lexp.end()); lexp.erase(unique(lexp.begin(), lexp.end()), lexp.end());
LOGDEB(("ExpTerm: stemexp: %s\n", LOGDEB("ExpTerm: stemexp: " << (stringsToString(lexp)) << "\n" );
stringsToString(lexp).c_str()));
} }
if (m_syngroups.ok() && (typ_sens & ET_SYNEXP)) { if (m_syngroups.ok() && (typ_sens & ET_SYNEXP)) {
LOGDEB(("ExpTerm: got syngroups\n")); LOGDEB("ExpTerm: got syngroups\n" );
vector<string> exp1(lexp); vector<string> exp1(lexp);
for (vector<string>::const_iterator it = lexp.begin(); for (vector<string>::const_iterator it = lexp.begin();
it != lexp.end(); it++) { it != lexp.end(); it++) {
vector<string> sg = m_syngroups.getgroup(*it); vector<string> sg = m_syngroups.getgroup(*it);
if (!sg.empty()) { if (!sg.empty()) {
LOGDEB(("ExpTerm: syns: %s -> %s\n", LOGDEB("ExpTerm: syns: " << *it << " -> " << (stringsToString(sg)) << "\n" );
it->c_str(), stringsToString(sg).c_str()));
for (vector<string>::const_iterator it1 = sg.begin(); for (vector<string>::const_iterator it1 = sg.begin();
it1 != sg.end(); it1++) { it1 != sg.end(); it1++) {
if (it1->find_first_of(" ") != string::npos) { if (it1->find_first_of(" ") != string::npos) {
@ -313,7 +307,7 @@ bool Db::termMatch(int typ_sens, const string &lang, const string &_term,
} }
// Filter the result and get the stats, possibly add prefixes. // Filter the result and get the stats, possibly add prefixes.
LOGDEB(("ExpandTerm:TM: lexp: %s\n", stringsToString(lexp).c_str())); LOGDEB("ExpandTerm:TM: lexp: " << (stringsToString(lexp)) << "\n" );
for (vector<string>::const_iterator it = lexp.begin(); for (vector<string>::const_iterator it = lexp.begin();
it != lexp.end(); it++) { it != lexp.end(); it++) {
idxTermMatch(Rcl::Db::ET_WILD, "", *it, res, max, field); idxTermMatch(Rcl::Db::ET_WILD, "", *it, res, max, field);
@ -341,13 +335,10 @@ bool Db::idxTermMatch(int typ_sens, const string &lang, const string &root,
TermMatchResult& res, int max, const string& field) TermMatchResult& res, int max, const string& field)
{ {
int typ = matchTypeTp(typ_sens); int typ = matchTypeTp(typ_sens);
LOGDEB1(("Db::idxTermMatch: typ %s lang [%s] term [%s] " LOGDEB1("Db::idxTermMatch: typ " << (tmtptostr(typ)) << " lang [" << (lang) << "] term [" << (root) << "] max " << (max) << " field [" << (field) << "] init res.size " << (res.entries.size()) << "\n" );
"max %d field [%s] init res.size %u\n",
tmtptostr(typ), lang.c_str(), root.c_str(),
max, field.c_str(), res.entries.size()));
if (typ == ET_STEM) { if (typ == ET_STEM) {
LOGFATAL(("RCLDB: internal error: idxTermMatch called with ET_STEM\n")); LOGFATAL("RCLDB: internal error: idxTermMatch called with ET_STEM\n" );
abort(); abort();
} }
@ -357,8 +348,7 @@ bool Db::idxTermMatch(int typ_sens, const string &lang, const string &root,
if (!field.empty()) { if (!field.empty()) {
const FieldTraits *ftp = 0; const FieldTraits *ftp = 0;
if (!fieldToTraits(field, &ftp, true) || ftp->pfx.empty()) { if (!fieldToTraits(field, &ftp, true) || ftp->pfx.empty()) {
LOGDEB(("Db::termMatch: field is not indexed (no prefix): [%s]\n", LOGDEB("Db::termMatch: field is not indexed (no prefix): [" << (field) << "]\n" );
field.c_str()));
} else { } else {
prefix = wrap_prefix(ftp->pfx); prefix = wrap_prefix(ftp->pfx);
} }
@ -369,8 +359,7 @@ bool Db::idxTermMatch(int typ_sens, const string &lang, const string &root,
if (typ == ET_REGEXP) { if (typ == ET_REGEXP) {
matcher = STD_SHARED_PTR<StrMatcher>(new StrRegexpMatcher(root)); matcher = STD_SHARED_PTR<StrMatcher>(new StrRegexpMatcher(root));
if (!matcher->ok()) { if (!matcher->ok()) {
LOGERR(("termMatch: regcomp failed: %s\n", LOGERR("termMatch: regcomp failed: " << (matcher->getreason()));
matcher->getreason().c_str()))
return false; return false;
} }
} else if (typ == ET_WILD) { } else if (typ == ET_WILD) {
@ -394,7 +383,7 @@ bool Db::idxTermMatch(int typ_sens, const string &lang, const string &root,
} else { } else {
is = prefix + root.substr(0, es); is = prefix + root.substr(0, es);
} }
LOGDEB2(("termMatch: initsec: [%s]\n", is.c_str())); LOGDEB2("termMatch: initsec: [" << (is) << "]\n" );
for (int tries = 0; tries < 2; tries++) { for (int tries = 0; tries < 2; tries++) {
try { try {
@ -446,7 +435,7 @@ bool Db::idxTermMatch(int typ_sens, const string &lang, const string &root,
break; break;
} }
if (!m_reason.empty()) { if (!m_reason.empty()) {
LOGERR(("termMatch: %s\n", m_reason.c_str())); LOGERR("termMatch: " << (m_reason) << "\n" );
return false; return false;
} }
@ -468,7 +457,7 @@ TermIter *Db::termWalkOpen()
tit->db = m_ndb->xrdb; tit->db = m_ndb->xrdb;
XAPTRY(tit->it = tit->db.allterms_begin(), tit->db, m_reason); XAPTRY(tit->it = tit->db.allterms_begin(), tit->db, m_reason);
if (!m_reason.empty()) { if (!m_reason.empty()) {
LOGERR(("Db::termWalkOpen: xapian error: %s\n", m_reason.c_str())); LOGERR("Db::termWalkOpen: xapian error: " << (m_reason) << "\n" );
return 0; return 0;
} }
} }
@ -484,7 +473,7 @@ bool Db::termWalkNext(TermIter *tit, string &term)
, tit->db, m_reason); , tit->db, m_reason);
if (!m_reason.empty()) { if (!m_reason.empty()) {
LOGERR(("Db::termWalkOpen: xapian error: %s\n", m_reason.c_str())); LOGERR("Db::termWalkOpen: xapian error: " << (m_reason) << "\n" );
} }
return false; return false;
} }
@ -504,7 +493,7 @@ bool Db::termExists(const string& word)
m_ndb->xrdb, m_reason); m_ndb->xrdb, m_reason);
if (!m_reason.empty()) { if (!m_reason.empty()) {
LOGERR(("Db::termWalkOpen: xapian error: %s\n", m_reason.c_str())); LOGERR("Db::termWalkOpen: xapian error: " << (m_reason) << "\n" );
return false; return false;
} }
return true; return true;
@ -515,8 +504,7 @@ bool Db::stemDiffers(const string& lang, const string& word,
{ {
Xapian::Stem stemmer(lang); Xapian::Stem stemmer(lang);
if (!stemmer(word).compare(stemmer(base))) { if (!stemmer(word).compare(stemmer(base))) {
LOGDEB2(("Rcl::Db::stemDiffers: same for %s and %s\n", LOGDEB2("Rcl::Db::stemDiffers: same for " << (word) << " and " << (base) << "\n" );
word.c_str(), base.c_str()));
return false; return false;
} }
return true; return true;

View file

@ -34,7 +34,7 @@ using namespace std;
#include "rcldb.h" #include "rcldb.h"
#include "rcldb_p.h" #include "rcldb_p.h"
#include "searchdata.h" #include "searchdata.h"
#include "debuglog.h" #include "log.h"
#include "smallut.h" #include "smallut.h"
#include "textsplit.h" #include "textsplit.h"
#include "unacpp.h" #include "unacpp.h"
@ -68,7 +68,7 @@ void SearchData::commoninit()
SearchData::~SearchData() SearchData::~SearchData()
{ {
LOGDEB0(("SearchData::~SearchData\n")); LOGDEB0("SearchData::~SearchData\n" );
for (qlist_it_t it = m_query.begin(); it != m_query.end(); it++) for (qlist_it_t it = m_query.begin(); it != m_query.end(); it++)
delete *it; delete *it;
} }
@ -79,13 +79,13 @@ SearchData::~SearchData()
// We remove very common terms from the query to avoid performance issues. // We remove very common terms from the query to avoid performance issues.
bool SearchData::maybeAddAutoPhrase(Rcl::Db& db, double freqThreshold) bool SearchData::maybeAddAutoPhrase(Rcl::Db& db, double freqThreshold)
{ {
LOGDEB0(("SearchData::maybeAddAutoPhrase()\n")); LOGDEB0("SearchData::maybeAddAutoPhrase()\n" );
// cerr << "BEFORE SIMPLIFY\n"; dump(cerr); // cerr << "BEFORE SIMPLIFY\n"; dump(cerr);
simplify(); simplify();
// cerr << "AFTER SIMPLIFY\n"; dump(cerr); // cerr << "AFTER SIMPLIFY\n"; dump(cerr);
if (!m_query.size()) { if (!m_query.size()) {
LOGDEB2(("SearchData::maybeAddAutoPhrase: empty query\n")); LOGDEB2("SearchData::maybeAddAutoPhrase: empty query\n" );
return false; return false;
} }
@ -96,27 +96,27 @@ bool SearchData::maybeAddAutoPhrase(Rcl::Db& db, double freqThreshold)
for (qlist_it_t it = m_query.begin(); it != m_query.end(); it++) { for (qlist_it_t it = m_query.begin(); it != m_query.end(); it++) {
SClType tp = (*it)->m_tp; SClType tp = (*it)->m_tp;
if (tp != SCLT_AND) { if (tp != SCLT_AND) {
LOGDEB2(("SearchData::maybeAddAutoPhrase: wrong tp %d\n", tp)); LOGDEB2("SearchData::maybeAddAutoPhrase: wrong tp " << (tp) << "\n" );
return false; return false;
} }
SearchDataClauseSimple *clp = SearchDataClauseSimple *clp =
dynamic_cast<SearchDataClauseSimple*>(*it); dynamic_cast<SearchDataClauseSimple*>(*it);
if (clp == 0) { if (clp == 0) {
LOGDEB2(("SearchData::maybeAddAutoPhrase: dyncast failed\n")); LOGDEB2("SearchData::maybeAddAutoPhrase: dyncast failed\n" );
return false; return false;
} }
if (it == m_query.begin()) { if (it == m_query.begin()) {
field = clp->getfield(); field = clp->getfield();
} else { } else {
if (clp->getfield().compare(field)) { if (clp->getfield().compare(field)) {
LOGDEB2(("SearchData::maybeAddAutoPhrase: diff. fields\n")); LOGDEB2("SearchData::maybeAddAutoPhrase: diff. fields\n" );
return false; return false;
} }
} }
// If there are wildcards or quotes in there, bail out // If there are wildcards or quotes in there, bail out
if (clp->gettext().find_first_of("\"*[?") != string::npos) { if (clp->gettext().find_first_of("\"*[?") != string::npos) {
LOGDEB2(("SearchData::maybeAddAutoPhrase: wildcards\n")); LOGDEB2("SearchData::maybeAddAutoPhrase: wildcards\n" );
return false; return false;
} }
@ -145,8 +145,8 @@ bool SearchData::maybeAddAutoPhrase(Rcl::Db& db, double freqThreshold)
swords.append(1, ' '); swords.append(1, ' ');
swords += *it; swords += *it;
} else { } else {
LOGDEB0(("SearchData::Autophrase: [%s] too frequent (%.2f %%)\n", LOGDEB0("SearchData::Autophrase: [" << *it << "] too frequent ("
it->c_str(), 100 * freq)); << (100 * freq) << " %" << ")\n" );
slack++; slack++;
} }
} }
@ -154,7 +154,7 @@ bool SearchData::maybeAddAutoPhrase(Rcl::Db& db, double freqThreshold)
// We can't make a phrase with a single word :) // We can't make a phrase with a single word :)
int nwords = TextSplit::countWords(swords); int nwords = TextSplit::countWords(swords);
if (nwords <= 1) { if (nwords <= 1) {
LOGDEB2(("SearchData::maybeAddAutoPhrase: ended with 1 word\n")); LOGDEB2("SearchData::maybeAddAutoPhrase: ended with 1 word\n" );
return false; return false;
} }
@ -171,7 +171,7 @@ bool SearchData::maybeAddAutoPhrase(Rcl::Db& db, double freqThreshold)
bool SearchData::addClause(SearchDataClause* cl) bool SearchData::addClause(SearchDataClause* cl)
{ {
if (m_tp == SCLT_OR && cl->getexclude()) { if (m_tp == SCLT_OR && cl->getexclude()) {
LOGERR(("SearchData::addClause: cant add EXCL to OR list\n")); LOGERR("SearchData::addClause: cant add EXCL to OR list\n" );
m_reason = "No Negative (AND_NOT) clauses allowed in OR queries"; m_reason = "No Negative (AND_NOT) clauses allowed in OR queries";
return false; return false;
} }
@ -373,3 +373,4 @@ void SearchDataClauseSub::dump(ostream& o) const
} }
} // Namespace Rcl } // Namespace Rcl

View file

@ -34,7 +34,7 @@ using namespace std;
#include "rcldb.h" #include "rcldb.h"
#include "rcldb_p.h" #include "rcldb_p.h"
#include "searchdata.h" #include "searchdata.h"
#include "debuglog.h" #include "log.h"
#include "smallut.h" #include "smallut.h"
#include "textsplit.h" #include "textsplit.h"
#include "unacpp.h" #include "unacpp.h"
@ -62,7 +62,7 @@ bool SearchData::expandFileTypes(Db &db, vector<string>& tps)
{ {
const RclConfig *cfg = db.getConf(); const RclConfig *cfg = db.getConf();
if (!cfg) { if (!cfg) {
LOGFATAL(("Db::expandFileTypes: null configuration!!\n")); LOGFATAL("Db::expandFileTypes: null configuration!!\n" );
return false; return false;
} }
vector<string> exptps; vector<string> exptps;
@ -113,13 +113,12 @@ bool SearchData::clausesToQuery(Rcl::Db &db, SClType tp,
for (qlist_it_t it = query.begin(); it != query.end(); it++) { for (qlist_it_t it = query.begin(); it != query.end(); it++) {
Xapian::Query nq; Xapian::Query nq;
if (!(*it)->toNativeQuery(db, &nq)) { if (!(*it)->toNativeQuery(db, &nq)) {
LOGERR(("SearchData::clausesToQuery: toNativeQuery failed: %s\n", LOGERR("SearchData::clausesToQuery: toNativeQuery failed: " << ((*it)->getReason()) << "\n" );
(*it)->getReason().c_str()));
reason += (*it)->getReason() + " "; reason += (*it)->getReason() + " ";
return false; return false;
} }
if (nq.empty()) { if (nq.empty()) {
LOGDEB(("SearchData::clausesToQuery: skipping empty clause\n")); LOGDEB("SearchData::clausesToQuery: skipping empty clause\n" );
continue; continue;
} }
// If this structure is an AND list, must use AND_NOT for excl clauses. // If this structure is an AND list, must use AND_NOT for excl clauses.
@ -144,7 +143,7 @@ bool SearchData::clausesToQuery(Rcl::Db &db, SClType tp,
xq = Xapian::Query(op, xq, nq); xq = Xapian::Query(op, xq, nq);
} }
if (int(xq.get_length()) >= getMaxCl()) { if (int(xq.get_length()) >= getMaxCl()) {
LOGERR(("%s\n", maxXapClauseMsg)); LOGERR("" << (maxXapClauseMsg) << "\n" );
m_reason += maxXapClauseMsg; m_reason += maxXapClauseMsg;
if (!o_index_stripchars) if (!o_index_stripchars)
m_reason += maxXapClauseCaseDiacMsg; m_reason += maxXapClauseCaseDiacMsg;
@ -152,7 +151,7 @@ bool SearchData::clausesToQuery(Rcl::Db &db, SClType tp,
} }
} }
LOGDEB0(("SearchData::clausesToQuery: got %d clauses\n", xq.get_length())); LOGDEB0("SearchData::clausesToQuery: got " << (xq.get_length()) << " clauses\n" );
if (xq.empty()) if (xq.empty())
xq = Xapian::Query::MatchAll; xq = Xapian::Query::MatchAll;
@ -163,7 +162,7 @@ bool SearchData::clausesToQuery(Rcl::Db &db, SClType tp,
bool SearchData::toNativeQuery(Rcl::Db &db, void *d) bool SearchData::toNativeQuery(Rcl::Db &db, void *d)
{ {
LOGDEB(("SearchData::toNativeQuery: stemlang [%s]\n", m_stemlang.c_str())); LOGDEB("SearchData::toNativeQuery: stemlang [" << (m_stemlang) << "]\n" );
m_reason.erase(); m_reason.erase();
db.getConf()->getConfParam("maxTermExpand", &m_maxexp); db.getConf()->getConfParam("maxTermExpand", &m_maxexp);
@ -175,8 +174,7 @@ bool SearchData::toNativeQuery(Rcl::Db &db, void *d)
// Xapian query tree // Xapian query tree
Xapian::Query xq; Xapian::Query xq;
if (!clausesToQuery(db, m_tp, m_query, m_reason, &xq)) { if (!clausesToQuery(db, m_tp, m_query, m_reason, &xq)) {
LOGERR(("SearchData::toNativeQuery: clausesToQuery failed. reason: %s\n", LOGERR("SearchData::toNativeQuery: clausesToQuery failed. reason: " << (m_reason) << "\n" );
m_reason.c_str()));
return false; return false;
} }
@ -185,7 +183,7 @@ bool SearchData::toNativeQuery(Rcl::Db &db, void *d)
if (m_dates.y1 == 0 || m_dates.y2 == 0) { if (m_dates.y1 == 0 || m_dates.y2 == 0) {
int minyear = 1970, maxyear = 2100; int minyear = 1970, maxyear = 2100;
if (!db.maxYearSpan(&minyear, &maxyear)) { if (!db.maxYearSpan(&minyear, &maxyear)) {
LOGERR(("Can't retrieve index min/max dates\n")); LOGERR("Can't retrieve index min/max dates\n" );
//whatever, go on. //whatever, go on.
} }
@ -200,18 +198,16 @@ bool SearchData::toNativeQuery(Rcl::Db &db, void *d)
m_dates.d2 = 31; m_dates.d2 = 31;
} }
} }
LOGDEB(("Db::toNativeQuery: date interval: %d-%d-%d/%d-%d-%d\n", LOGDEB("Db::toNativeQuery: date interval: " << (m_dates.y1) << "-" << (m_dates.m1) << "-" << (m_dates.d1) << "/" << (m_dates.y2) << "-" << (m_dates.m2) << "-" << (m_dates.d2) << "\n" );
m_dates.y1, m_dates.m1, m_dates.d1,
m_dates.y2, m_dates.m2, m_dates.d2));
Xapian::Query dq = date_range_filter(m_dates.y1, m_dates.m1, m_dates.d1, Xapian::Query dq = date_range_filter(m_dates.y1, m_dates.m1, m_dates.d1,
m_dates.y2, m_dates.m2, m_dates.d2); m_dates.y2, m_dates.m2, m_dates.d2);
if (dq.empty()) { if (dq.empty()) {
LOGINFO(("Db::toNativeQuery: date filter is empty\n")); LOGINFO("Db::toNativeQuery: date filter is empty\n" );
} }
// If no probabilistic query is provided then promote the daterange // If no probabilistic query is provided then promote the daterange
// filter to be THE query instead of filtering an empty query. // filter to be THE query instead of filtering an empty query.
if (xq.empty()) { if (xq.empty()) {
LOGINFO(("Db::toNativeQuery: proba query is empty\n")); LOGINFO("Db::toNativeQuery: proba query is empty\n" );
xq = dq; xq = dq;
} else { } else {
xq = Xapian::Query(Xapian::Query::OP_FILTER, xq, dq); xq = Xapian::Query(Xapian::Query::OP_FILTER, xq, dq);
@ -243,7 +239,7 @@ bool SearchData::toNativeQuery(Rcl::Db &db, void *d)
// If no probabilistic query is provided then promote the // If no probabilistic query is provided then promote the
// filter to be THE query instead of filtering an empty query. // filter to be THE query instead of filtering an empty query.
if (xq.empty()) { if (xq.empty()) {
LOGINFO(("Db::toNativeQuery: proba query is empty\n")); LOGINFO("Db::toNativeQuery: proba query is empty\n" );
xq = sq; xq = sq;
} else { } else {
xq = Xapian::Query(Xapian::Query::OP_FILTER, xq, sq); xq = Xapian::Query(Xapian::Query::OP_FILTER, xq, sq);
@ -267,7 +263,7 @@ bool SearchData::toNativeQuery(Rcl::Db &db, void *d)
for (vector<string>::iterator it = m_filetypes.begin(); for (vector<string>::iterator it = m_filetypes.begin();
it != m_filetypes.end(); it++) { it != m_filetypes.end(); it++) {
string term = wrap_prefix(mimetype_prefix) + *it; string term = wrap_prefix(mimetype_prefix) + *it;
LOGDEB0(("Adding file type term: [%s]\n", term.c_str())); LOGDEB0("Adding file type term: [" << (term) << "]\n" );
tq = tq.empty() ? Xapian::Query(term) : tq = tq.empty() ? Xapian::Query(term) :
Xapian::Query(Xapian::Query::OP_OR, tq, Xapian::Query(term)); Xapian::Query(Xapian::Query::OP_OR, tq, Xapian::Query(term));
} }
@ -282,7 +278,7 @@ bool SearchData::toNativeQuery(Rcl::Db &db, void *d)
for (vector<string>::iterator it = m_nfiletypes.begin(); for (vector<string>::iterator it = m_nfiletypes.begin();
it != m_nfiletypes.end(); it++) { it != m_nfiletypes.end(); it++) {
string term = wrap_prefix(mimetype_prefix) + *it; string term = wrap_prefix(mimetype_prefix) + *it;
LOGDEB0(("Adding negative file type term: [%s]\n", term.c_str())); LOGDEB0("Adding negative file type term: [" << (term) << "]\n" );
tq = tq.empty() ? Xapian::Query(term) : tq = tq.empty() ? Xapian::Query(term) :
Xapian::Query(Xapian::Query::OP_OR, tq, Xapian::Query(term)); Xapian::Query(Xapian::Query::OP_OR, tq, Xapian::Query(term));
} }
@ -337,8 +333,7 @@ public:
if (m_lastpos < pos) if (m_lastpos < pos)
m_lastpos = pos; m_lastpos = pos;
bool noexpand = be ? m_ts->nostemexp() : true; bool noexpand = be ? m_ts->nostemexp() : true;
LOGDEB1(("TermProcQ::takeword: pushing [%s] pos %d noexp %d\n", LOGDEB1("TermProcQ::takeword: pushing [" << (term) << "] pos " << (pos) << " noexp " << (noexpand) << "\n" );
term.c_str(), pos, noexpand));
if (m_terms[pos].size() < term.size()) { if (m_terms[pos].size() < term.size()) {
m_terms[pos] = term; m_terms[pos] = term;
m_nste[pos] = noexpand; m_nste[pos] = noexpand;
@ -401,8 +396,7 @@ bool SearchDataClauseSimple::expandTerm(Rcl::Db &db,
vector<string>* multiwords vector<string>* multiwords
) )
{ {
LOGDEB0(("expandTerm: mods 0x%x fld [%s] trm [%s] lang [%s]\n", LOGDEB0("expandTerm: mods 0x" << (mods) << " fld [" << (m_field) << "] trm [" << (term) << "] lang [" << (getStemLang()) << "]\n" );
mods, m_field.c_str(), term.c_str(), getStemLang().c_str()));
sterm.clear(); sterm.clear();
oexp.clear(); oexp.clear();
if (term.empty()) if (term.empty())
@ -426,7 +420,7 @@ bool SearchDataClauseSimple::expandTerm(Rcl::Db &db,
// No stem expansion if there are wildcards or if prevented by caller // No stem expansion if there are wildcards or if prevented by caller
bool nostemexp = (mods & SDCM_NOSTEMMING) != 0; bool nostemexp = (mods & SDCM_NOSTEMMING) != 0;
if (haswild || getStemLang().empty()) { if (haswild || getStemLang().empty()) {
LOGDEB2(("expandTerm: found wildcards or stemlang empty: no exp\n")); LOGDEB2("expandTerm: found wildcards or stemlang empty: no exp\n" );
nostemexp = true; nostemexp = true;
} }
@ -448,7 +442,7 @@ bool SearchDataClauseSimple::expandTerm(Rcl::Db &db,
// performed (conversion+comparison) will automatically ignore // performed (conversion+comparison) will automatically ignore
// accented characters which are actually a separate letter // accented characters which are actually a separate letter
if (getAutoDiac() && unachasaccents(term)) { if (getAutoDiac() && unachasaccents(term)) {
LOGDEB0(("expandTerm: term has accents -> diac-sensitive\n")); LOGDEB0("expandTerm: term has accents -> diac-sensitive\n" );
diac_sensitive = true; diac_sensitive = true;
} }
@ -459,14 +453,13 @@ bool SearchDataClauseSimple::expandTerm(Rcl::Db &db,
Utf8Iter it(term); Utf8Iter it(term);
it++; it++;
if (getAutoCase() && unachasuppercase(term.substr(it.getBpos()))) { if (getAutoCase() && unachasuppercase(term.substr(it.getBpos()))) {
LOGDEB0(("expandTerm: term has uppercase -> case-sensitive\n")); LOGDEB0("expandTerm: term has uppercase -> case-sensitive\n" );
case_sensitive = true; case_sensitive = true;
} }
// If we are sensitive to case or diacritics turn stemming off // If we are sensitive to case or diacritics turn stemming off
if (diac_sensitive || case_sensitive) { if (diac_sensitive || case_sensitive) {
LOGDEB0(("expandTerm: diac or case sens set -> " LOGDEB0("expandTerm: diac or case sens set -> stemexpand and synonyms off\n" );
"stemexpand and synonyms off\n"));
nostemexp = true; nostemexp = true;
synonyms = false; synonyms = false;
} }
@ -479,8 +472,7 @@ bool SearchDataClauseSimple::expandTerm(Rcl::Db &db,
if (noexpansion) { if (noexpansion) {
oexp.push_back(prefix + term); oexp.push_back(prefix + term);
m_hldata.terms[term] = term; m_hldata.terms[term] = term;
LOGDEB(("ExpandTerm: noexpansion: final: %s\n", LOGDEB("ExpandTerm: noexpansion: final: " << (stringsToString(oexp)) << "\n" );
stringsToString(oexp).c_str()));
return true; return true;
} }
@ -521,7 +513,7 @@ bool SearchDataClauseSimple::expandTerm(Rcl::Db &db,
it != oexp.end(); it++) { it != oexp.end(); it++) {
m_hldata.terms[strip_prefix(*it)] = term; m_hldata.terms[strip_prefix(*it)] = term;
} }
LOGDEB(("ExpandTerm: final: %s\n", stringsToString(oexp).c_str())); LOGDEB("ExpandTerm: final: " << (stringsToString(oexp)) << "\n" );
return true; return true;
} }
@ -572,8 +564,7 @@ processSimpleSpan(Rcl::Db &db, string& ermsg,
int mods, void * pq) int mods, void * pq)
{ {
vector<Xapian::Query>& pqueries(*(vector<Xapian::Query>*)pq); vector<Xapian::Query>& pqueries(*(vector<Xapian::Query>*)pq);
LOGDEB0(("StringToXapianQ::processSimpleSpan: [%s] mods 0x%x\n", LOGDEB0("StringToXapianQ::processSimpleSpan: [" << (span) << "] mods 0x" << ((unsigned int)mods) << "\n" );
span.c_str(), (unsigned int)mods));
vector<string> exp; vector<string> exp;
string sterm; // dumb version of user term string sterm; // dumb version of user term
@ -669,7 +660,7 @@ void SearchDataClauseSimple::processPhraseOrNear(Rcl::Db &db, string& ermsg,
vector<bool>::const_iterator nxit = splitData->nostemexps().begin(); vector<bool>::const_iterator nxit = splitData->nostemexps().begin();
for (vector<string>::const_iterator it = splitData->terms().begin(); for (vector<string>::const_iterator it = splitData->terms().begin();
it != splitData->terms().end(); it++, nxit++) { it != splitData->terms().end(); it++, nxit++) {
LOGDEB0(("ProcessPhrase: processing [%s]\n", it->c_str())); LOGDEB0("ProcessPhrase: processing [" << *it << "]\n" );
// Adjust when we do stem expansion. Not if disabled by // Adjust when we do stem expansion. Not if disabled by
// caller, not inside phrases, and some versions of xapian // caller, not inside phrases, and some versions of xapian
// will accept only one OR clause inside NEAR. // will accept only one OR clause inside NEAR.
@ -685,8 +676,7 @@ void SearchDataClauseSimple::processPhraseOrNear(Rcl::Db &db, string& ermsg,
vector<string> exp; vector<string> exp;
if (!expandTerm(db, ermsg, lmods, *it, exp, sterm, prefix)) if (!expandTerm(db, ermsg, lmods, *it, exp, sterm, prefix))
return; return;
LOGDEB0(("ProcessPhraseOrNear: exp size %d, exp: %s\n", exp.size(), LOGDEB0("ProcessPhraseOrNear: exp size " << (exp.size()) << ", exp: " << (stringsToString(exp)) << "\n" );
stringsToString(exp).c_str()));
// groups is used for highlighting, we don't want prefixes in there. // groups is used for highlighting, we don't want prefixes in there.
vector<string> noprefs; vector<string> noprefs;
for (vector<string>::const_iterator it = exp.begin(); for (vector<string>::const_iterator it = exp.begin();
@ -712,8 +702,7 @@ void SearchDataClauseSimple::processPhraseOrNear(Rcl::Db &db, string& ermsg,
// Generate an appropriate PHRASE/NEAR query with adjusted slack // Generate an appropriate PHRASE/NEAR query with adjusted slack
// For phrases, give a relevance boost like we do for original terms // For phrases, give a relevance boost like we do for original terms
LOGDEB2(("PHRASE/NEAR: alltermcount %d lastpos %d\n", LOGDEB2("PHRASE/NEAR: alltermcount " << (splitData->alltermcount()) << " lastpos " << (splitData->lastpos()) << "\n" );
splitData->alltermcount(), splitData->lastpos()));
Xapian::Query xq(op, orqueries.begin(), orqueries.end(), Xapian::Query xq(op, orqueries.begin(), orqueries.end(),
splitData->lastpos() + 1 + slack); splitData->lastpos() + 1 + slack);
if (op == Xapian::Query::OP_PHRASE) if (op == Xapian::Query::OP_PHRASE)
@ -783,9 +772,7 @@ bool SearchDataClauseSimple::processUserString(Rcl::Db &db, const string &iq,
vector<Xapian::Query> &pqueries(*(vector<Xapian::Query>*)pq); vector<Xapian::Query> &pqueries(*(vector<Xapian::Query>*)pq);
int mods = m_modifiers; int mods = m_modifiers;
LOGDEB(("StringToXapianQ:pUS:: qstr [%s] fld [%s] mods 0x%x " LOGDEB("StringToXapianQ:pUS:: qstr [" << (iq) << "] fld [" << (m_field) << "] mods 0x" << (mods) << " slack " << (slack) << " near " << (useNear) << "\n" );
"slack %d near %d\n",
iq.c_str(), m_field.c_str(), mods, slack, useNear));
ermsg.erase(); ermsg.erase();
m_curcl = 0; m_curcl = 0;
const StopList stops = db.getStopList(); const StopList stops = db.getStopList();
@ -805,7 +792,7 @@ bool SearchDataClauseSimple::processUserString(Rcl::Db &db, const string &iq,
try { try {
for (vector<string>::iterator it = phrases.begin(); for (vector<string>::iterator it = phrases.begin();
it != phrases.end(); it++) { it != phrases.end(); it++) {
LOGDEB0(("strToXapianQ: phrase/word: [%s]\n", it->c_str())); LOGDEB0("strToXapianQ: phrase/word: [" << *it << "]\n" );
// Anchoring modifiers // Anchoring modifiers
int amods = stringToMods(*it); int amods = stringToMods(*it);
int terminc = amods != 0 ? 1 : 0; int terminc = amods != 0 ? 1 : 0;
@ -843,7 +830,7 @@ bool SearchDataClauseSimple::processUserString(Rcl::Db &db, const string &iq,
slack += tpq.lastpos() - int(tpq.terms().size()) + 1; slack += tpq.lastpos() - int(tpq.terms().size()) + 1;
LOGDEB0(("strToXapianQ: termcount: %d\n", tpq.terms().size())); LOGDEB0("strToXapianQ: termcount: " << (tpq.terms().size()) << "\n" );
switch (tpq.terms().size() + terminc) { switch (tpq.terms().size() + terminc) {
case 0: case 0:
continue;// ?? continue;// ??
@ -878,7 +865,7 @@ bool SearchDataClauseSimple::processUserString(Rcl::Db &db, const string &iq,
ermsg = "Caught unknown exception"; ermsg = "Caught unknown exception";
} }
if (!ermsg.empty()) { if (!ermsg.empty()) {
LOGERR(("stringToXapianQueries: %s\n", ermsg.c_str())); LOGERR("stringToXapianQueries: " << (ermsg) << "\n" );
return false; return false;
} }
return true; return true;
@ -887,9 +874,7 @@ bool SearchDataClauseSimple::processUserString(Rcl::Db &db, const string &iq,
// Translate a simple OR or AND search clause. // Translate a simple OR or AND search clause.
bool SearchDataClauseSimple::toNativeQuery(Rcl::Db &db, void *p) bool SearchDataClauseSimple::toNativeQuery(Rcl::Db &db, void *p)
{ {
LOGDEB(("SearchDataClauseSimple::toNativeQuery: fld [%s] val [%s] " LOGDEB("SearchDataClauseSimple::toNativeQuery: fld [" << (m_field) << "] val [" << (m_text) << "] stemlang [" << (getStemLang()) << "]\n" );
"stemlang [%s]\n", m_field.c_str(), m_text.c_str(),
getStemLang().c_str()));
Xapian::Query *qp = (Xapian::Query *)p; Xapian::Query *qp = (Xapian::Query *)p;
*qp = Xapian::Query(); *qp = Xapian::Query();
@ -899,7 +884,7 @@ bool SearchDataClauseSimple::toNativeQuery(Rcl::Db &db, void *p)
case SCLT_AND: op = Xapian::Query::OP_AND; break; case SCLT_AND: op = Xapian::Query::OP_AND; break;
case SCLT_OR: op = Xapian::Query::OP_OR; break; case SCLT_OR: op = Xapian::Query::OP_OR; break;
default: default:
LOGERR(("SearchDataClauseSimple: bad m_tp %d\n", m_tp)); LOGERR("SearchDataClauseSimple: bad m_tp " << (m_tp) << "\n" );
m_reason = "Internal error"; m_reason = "Internal error";
return false; return false;
} }
@ -908,7 +893,7 @@ bool SearchDataClauseSimple::toNativeQuery(Rcl::Db &db, void *p)
if (!processUserString(db, m_text, m_reason, &pqueries)) if (!processUserString(db, m_text, m_reason, &pqueries))
return false; return false;
if (pqueries.empty()) { if (pqueries.empty()) {
LOGERR(("SearchDataClauseSimple: resolved to null query\n")); LOGERR("SearchDataClauseSimple: resolved to null query\n" );
m_reason = string("Resolved to null query. Term too long ? : [" + m_reason = string("Resolved to null query. Term too long ? : [" +
m_text + string("]")); m_text + string("]"));
return false; return false;
@ -952,12 +937,12 @@ bool SearchDataClauseFilename::toNativeQuery(Rcl::Db &db, void *p)
// Translate a dir: path filtering clause. See comments in .h // Translate a dir: path filtering clause. See comments in .h
bool SearchDataClausePath::toNativeQuery(Rcl::Db &db, void *p) bool SearchDataClausePath::toNativeQuery(Rcl::Db &db, void *p)
{ {
LOGDEB(("SearchDataClausePath::toNativeQuery: [%s]\n", m_text.c_str())); LOGDEB("SearchDataClausePath::toNativeQuery: [" << (m_text) << "]\n" );
Xapian::Query *qp = (Xapian::Query *)p; Xapian::Query *qp = (Xapian::Query *)p;
*qp = Xapian::Query(); *qp = Xapian::Query();
if (m_text.empty()) { if (m_text.empty()) {
LOGERR(("SearchDataClausePath: empty path??\n")); LOGERR("SearchDataClausePath: empty path??\n" );
m_reason = "Empty path ?"; m_reason = "Empty path ?";
return false; return false;
} }
@ -982,8 +967,7 @@ bool SearchDataClausePath::toNativeQuery(Rcl::Db &db, void *p)
*pit, exp, sterm, wrap_prefix(pathelt_prefix))) { *pit, exp, sterm, wrap_prefix(pathelt_prefix))) {
return false; return false;
} }
LOGDEB0(("SDataPath::toNative: exp size %d. Exp: %s\n", exp.size(), LOGDEB0("SDataPath::toNative: exp size " << (exp.size()) << ". Exp: " << (stringsToString(exp)) << "\n" );
stringsToString(exp).c_str()));
if (exp.size() == 1) if (exp.size() == 1)
orqueries.push_back(Xapian::Query(exp[0])); orqueries.push_back(Xapian::Query(exp[0]));
else else
@ -1006,7 +990,7 @@ bool SearchDataClausePath::toNativeQuery(Rcl::Db &db, void *p)
// Translate NEAR or PHRASE clause. // Translate NEAR or PHRASE clause.
bool SearchDataClauseDist::toNativeQuery(Rcl::Db &db, void *p) bool SearchDataClauseDist::toNativeQuery(Rcl::Db &db, void *p)
{ {
LOGDEB(("SearchDataClauseDist::toNativeQuery\n")); LOGDEB("SearchDataClauseDist::toNativeQuery\n" );
Xapian::Query *qp = (Xapian::Query *)p; Xapian::Query *qp = (Xapian::Query *)p;
*qp = Xapian::Query(); *qp = Xapian::Query();
@ -1025,7 +1009,7 @@ bool SearchDataClauseDist::toNativeQuery(Rcl::Db &db, void *p)
if (!processUserString(db, s, m_reason, &pqueries, m_slack, useNear)) if (!processUserString(db, s, m_reason, &pqueries, m_slack, useNear))
return false; return false;
if (pqueries.empty()) { if (pqueries.empty()) {
LOGERR(("SearchDataClauseDist: resolved to null query\n")); LOGERR("SearchDataClauseDist: resolved to null query\n" );
m_reason = string("Resolved to null query. Term too long ? : [" + m_reason = string("Resolved to null query. Term too long ? : [" +
m_text + string("]")); m_text + string("]"));
return false; return false;
@ -1039,3 +1023,4 @@ bool SearchDataClauseDist::toNativeQuery(Rcl::Db &db, void *p)
} }
} // Namespace Rcl } // Namespace Rcl

View file

@ -25,12 +25,13 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <sstream> #include <sstream>
using namespace std;
#include "searchdata.h" #include "searchdata.h"
#include "debuglog.h" #include "log.h"
#include "base64.h" #include "base64.h"
using namespace std;
namespace Rcl { namespace Rcl {
static string tpToString(SClType tp) static string tpToString(SClType tp)
@ -48,7 +49,7 @@ static string tpToString(SClType tp)
string SearchData::asXML() string SearchData::asXML()
{ {
LOGDEB(("SearchData::asXML\n")); LOGDEB("SearchData::asXML\n" );
ostringstream os; ostringstream os;
// Searchdata // Searchdata
@ -64,7 +65,7 @@ string SearchData::asXML()
for (unsigned int i = 0; i < m_query.size(); i++) { for (unsigned int i = 0; i < m_query.size(); i++) {
SearchDataClause *c = m_query[i]; SearchDataClause *c = m_query[i];
if (c->getTp() == SCLT_SUB) { if (c->getTp() == SCLT_SUB) {
LOGERR(("SearchData::asXML: can't do subclauses !\n")); LOGERR("SearchData::asXML: can't do subclauses !\n" );
continue; continue;
} }
if (c->getTp() == SCLT_PATH) { if (c->getTp() == SCLT_PATH) {
@ -159,3 +160,4 @@ string SearchData::asXML()
} }

View file

@ -33,7 +33,7 @@ using namespace std;
#include <xapian.h> #include <xapian.h>
#include "stemdb.h" #include "stemdb.h"
#include "debuglog.h" #include "log.h"
#include "smallut.h" #include "smallut.h"
#include "synfamily.h" #include "synfamily.h"
#include "unacpp.h" #include "unacpp.h"
@ -85,10 +85,10 @@ bool StemDb::stemExpand(const std::string& langs, const std::string& _term,
sort(result.begin(), result.end()); sort(result.begin(), result.end());
vector<string>::iterator uit = unique(result.begin(), result.end()); vector<string>::iterator uit = unique(result.begin(), result.end());
result.resize(uit - result.begin()); result.resize(uit - result.begin());
LOGDEB1(("stemExpand:%s: %s -> %s\n", langs.c_str(), term.c_str(), LOGDEB1("stemExpand:" << (langs) << ": " << (term) << " -> " << (stringsToString(result)) << "\n" );
stringsToString(result).c_str()));
return true; return true;
} }
} }

Some files were not shown because too many files have changed in this diff Show more