diff --git a/src/Makefile.am b/src/Makefile.am index 4ba0e89f..bea2f541 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -25,7 +25,7 @@ COMMONCPPFLAGS = -I. \ -I$(top_srcdir)/xaposix \ -DBUILDING_RECOLL -AM_CPPFLAGS = -Wall -Wno-unused \ +AM_CPPFLAGS = -Wall -Wno-unused -std=c++11 \ $(COMMONCPPFLAGS) \ $(INCICONV) \ $(XAPIANCXXFLAGS) \ @@ -198,8 +198,6 @@ utils/copyfile.cpp \ utils/copyfile.h \ utils/cpuconf.cpp \ utils/cpuconf.h \ -utils/debuglog.cpp \ -utils/debuglog.h \ utils/ecrontab.cpp \ utils/ecrontab.h \ utils/execmd.cpp \ @@ -212,6 +210,8 @@ utils/hldata.h \ utils/hldata.cpp \ utils/idfile.cpp \ utils/idfile.h \ +utils/log.cpp \ +utils/log.h \ utils/md5.cpp \ utils/md5.h \ utils/md5ut.cpp \ diff --git a/src/aspell/rclaspell.cpp b/src/aspell/rclaspell.cpp index 9d7a3d2f..c69594b3 100644 --- a/src/aspell/rclaspell.cpp +++ b/src/aspell/rclaspell.cpp @@ -30,7 +30,7 @@ #include "pathut.h" #include "execmd.h" #include "rclaspell.h" -#include "debuglog.h" +#include "log.h" #include "unacpp.h" #include "ptmutex.h" @@ -84,7 +84,7 @@ public: : m_handle(0), m_speller(0) {} ~AspellData() { - LOGDEB2(("~AspellData\n")); + LOGDEB2("~AspellData\n" ); if (m_handle) { dlclose(m_handle); m_handle = 0; @@ -93,7 +93,7 @@ public: // Dumps core if I do this?? //aapi.delete_aspell_speller(m_speller); m_speller = 0; - LOGDEB2(("~AspellData: speller done\n")); + LOGDEB2("~AspellData: speller done\n" ); } } @@ -240,9 +240,9 @@ public: {} void newData() { 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)) { - LOGDEB2(("Aspell::buildDict: SKIP\n")); + LOGDEB2("Aspell::buildDict: SKIP\n" ); continue; } if (!o_index_stripchars) { @@ -253,7 +253,7 @@ public: } // Got a non-empty sort-of appropriate term, let's send it to // aspell - LOGDEB2(("Apell::buildDict: SEND\n")); + LOGDEB2("Apell::buildDict: SEND\n" ); m_input->append("\n"); return; } @@ -370,7 +370,7 @@ bool Aspell::make_speller(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); if (!ok() || !make_speller(reason)) @@ -381,7 +381,7 @@ bool Aspell::check(const string &iterm, string& reason) if (!o_index_stripchars) { string lower; if (!unacmaybefold(mterm, lower, "UTF-8", UNACOP_FOLD)) { - LOGERR(("Aspell::check : cant lowercase input\n")); + LOGERR("Aspell::check : cant lowercase input\n" ); return false; } mterm.swap(lower); @@ -413,7 +413,7 @@ bool Aspell::suggest(Rcl::Db &db, const string &_term, if (!o_index_stripchars) { string lower; if (!unacmaybefold(mterm, lower, "UTF-8", UNACOP_FOLD)) { - LOGERR(("Aspell::check : cant lowercase input\n")); + LOGERR("Aspell::check : cant lowercase input\n" ); return false; } mterm.swap(lower); @@ -584,3 +584,4 @@ int main(int argc, char **argv) #endif // RCL_USE_ASPELL #endif // TEST_RCLASPELL test driver + diff --git a/src/common/beaglequeuecache.cpp b/src/common/beaglequeuecache.cpp index 3e9f1d89..c14b12fb 100644 --- a/src/common/beaglequeuecache.cpp +++ b/src/common/beaglequeuecache.cpp @@ -20,7 +20,7 @@ #include "cstr.h" #include "beaglequeuecache.h" #include "circache.h" -#include "debuglog.h" +#include "log.h" #include "rclconfig.h" #include "pathut.h" #include "rcldoc.h" @@ -34,12 +34,11 @@ BeagleQueueCache::BeagleQueueCache(RclConfig *cnf) int maxmbs = 40; cnf->getConfParam("webcachemaxmbs", &maxmbs); if ((m_cache = new CirCache(ccdir)) == 0) { - LOGERR(("BeagleQueueCache: cant create CirCache object\n")); + LOGERR("BeagleQueueCache: cant create CirCache object\n" ); return; } if (!m_cache->create(off_t(maxmbs)*1000*1024, CirCache::CC_CRUNIQUE)) { - LOGERR(("BeagleQueueCache: cache file creation failed: %s\n", - m_cache->getReason().c_str())); + LOGERR("BeagleQueueCache: cache file creation failed: " << (m_cache->getReason()) << "\n" ); delete m_cache; m_cache = 0; return; @@ -59,11 +58,11 @@ bool BeagleQueueCache::getFromCache(const string& udi, Rcl::Doc &dotdoc, string dict; if (m_cache == 0) { - LOGERR(("BeagleQueueCache::getFromCache: cache is null\n")); + LOGERR("BeagleQueueCache::getFromCache: cache is null\n" ); return false; } if (!m_cache->get(udi, dict, &data)) { - LOGDEB(("BeagleQueueCache::getFromCache: get failed\n")); + LOGDEB("BeagleQueueCache::getFromCache: get failed\n" ); return false; } @@ -86,3 +85,4 @@ bool BeagleQueueCache::getFromCache(const string& udi, Rcl::Doc &dotdoc, dotdoc.meta[Rcl::Doc::keyudi] = udi; return true; } + diff --git a/src/common/conf_post.h b/src/common/conf_post.h index 6c552d63..4ae3caf1 100644 --- a/src/common/conf_post.h +++ b/src/common/conf_post.h @@ -29,7 +29,6 @@ #ifdef _WIN32 #include "safewindows.h" -#undef RCL_ICONV_INBUF_CONST #ifdef _MSC_VER // gmtime is supposedly thread-safe on windows @@ -47,15 +46,15 @@ typedef int mode_t; #else // End _MSC_VER -> Gminw -#define timegm portable_timegm - #undef RCL_ICONV_INBUF_CONST +#define timegm portable_timegm #endif // GMinw only typedef int pid_t; -inline int readlink(const char *cp, void *buf, int cnt) { - return -1; +inline int readlink(const char *cp, void *buf, int cnt) +{ + return -1; } #define MAXPATHLEN PATH_MAX @@ -72,9 +71,8 @@ typedef int ssize_t; #ifndef X_OK #define X_OK 4 #endif -#define RECOLL_DATADIR "C:\\recoll\\" + #define S_ISLNK(X) false #define lstat stat -#endif - +#endif // _WIN32 diff --git a/src/common/rclconfig.cpp b/src/common/rclconfig.cpp index c3a3c61b..5c7ce07d 100644 --- a/src/common/rclconfig.cpp +++ b/src/common/rclconfig.cpp @@ -42,7 +42,7 @@ #include "rclutil.h" #include "rclconfig.h" #include "conftree.h" -#include "debuglog.h" +#include "log.h" #include "smallut.h" #include "textsplit.h" #include "readfile.h" @@ -67,10 +67,9 @@ string RclConfig::o_origcwd; bool ParamStale::needrecompute() { - LOGDEB2(("ParamStale:: needrecompute. parent gen %d mine %d\n", - parent->m_keydirgen, savedkeydirgen)); + LOGDEB2("ParamStale:: needrecompute. parent gen " << (parent->m_keydirgen) << " mine " << (savedkeydirgen) << "\n" ); if (active && parent->m_keydirgen != savedkeydirgen) { - LOGDEB2(("ParamState:: needrecompute. conffile %p\n", conffile)); + LOGDEB2("ParamState:: needrecompute. conffile " << (conffile) << "\n" ); savedkeydirgen = parent->m_keydirgen; string newvalue; @@ -79,8 +78,7 @@ bool ParamStale::needrecompute() conffile->get(paramname, newvalue, parent->m_keydir); if (newvalue.compare(savedvalue)) { savedvalue = newvalue; - LOGDEB2(("ParamState:: needrecompute. return true newvalue [%s]\n", - newvalue.c_str())); + LOGDEB2("ParamState:: needrecompute. return true newvalue [" << (newvalue) << "]\n" ); return true; } } @@ -216,8 +214,7 @@ RclConfig::RclConfig(const string *argcnf) // interface, Windows will never use utf-8 o_localecharset = "UTF-8"; #endif - LOGDEB1(("RclConfig::getDefCharset: localecharset [%s]\n", - o_localecharset.c_str())); + LOGDEB1("RclConfig::getDefCharset: localecharset [" << (o_localecharset) << "]\n" ); } const char *cp; @@ -425,8 +422,7 @@ bool RclConfig::getConfParam(const string &name, vector *vip, char *ep; vip->push_back(strtol(vs[i].c_str(), &ep, 0)); if (ep == vs[i].c_str()) { - LOGDEB(("RclConfig::getConfParam: bad int value in [%s]\n", - name.c_str())); + LOGDEB("RclConfig::getConfParam: bad int value in [" << (name) << "]\n" ); return false; } } @@ -442,16 +438,16 @@ void RclConfig::initThrConf() vector vq; vector vt; if (!getConfParam("thrQSizes", &vq)) { - LOGINFO(("RclConfig::initThrConf: no thread info (queues)\n")); + LOGINFO("RclConfig::initThrConf: no thread info (queues)\n" ); goto out; } // If the first queue size is 0, autoconf is requested. if (vq.size() > 0 && vq[0] == 0) { - LOGDEB(("RclConfig::initThrConf: autoconf requested\n")); + LOGDEB("RclConfig::initThrConf: autoconf requested\n" ); CpuConf cpus; 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; } // Arbitrarily set threads config based on number of CPUS. This also @@ -477,12 +473,12 @@ void RclConfig::initThrConf() } if (!getConfParam("thrTCounts", &vt) ) { - LOGINFO(("RclConfig::initThrConf: no thread info (threads)\n")); + LOGINFO("RclConfig::initThrConf: no thread info (threads)\n" ); goto out; } 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; } @@ -499,14 +495,13 @@ out: ") "; } - LOGDEB(("RclConfig::initThrConf: chosen config (ql,nt): %s\n", - sconf.str().c_str())); + LOGDEB("RclConfig::initThrConf: chosen config (ql,nt): " << (sconf.str()) << "\n" ); } pair RclConfig::getThrConf(ThrStage who) const { if (m_thrConf.size() != 3) { - LOGERR(("RclConfig::getThrConf: bad data in rclconfig\n")); + LOGERR("RclConfig::getThrConf: bad data in rclconfig\n" ); return pair(-1,-1); } return m_thrConf[who]; @@ -516,8 +511,7 @@ vector RclConfig::getTopdirs() const { vector tdl; if (!getConfParam("topdirs", &tdl)) { - LOGERR(("RclConfig::getTopdirs: no top directories in config or " - "bad list format\n")); + LOGERR("RclConfig::getTopdirs: no top directories in config or bad list format\n" ); return tdl; } @@ -601,7 +595,7 @@ typedef multiset SuffixStore; 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 // bizarre way we do things bool needrecompute = m_stpsuffstate.needrecompute(); @@ -610,7 +604,7 @@ bool RclConfig::inStopSuffixes(const string& fni) // Need to initialize the suffixes delete STOPSUFFIXES; if ((m_stopsuffixes = new SuffixStore) == 0) { - LOGERR(("RclConfig::inStopSuffixes: out of memory\n")); + LOGERR("RclConfig::inStopSuffixes: out of memory\n" ); return false; } // Let the old customisation have priority: if recoll_noindex @@ -637,11 +631,10 @@ bool RclConfig::inStopSuffixes(const string& fni) stringtolower(fn); SuffixStore::const_iterator it = STOPSUFFIXES->find(fn); if (it != STOPSUFFIXES->end()) { - LOGDEB2(("RclConfig::inStopSuffixes: Found (%s) [%s]\n", - fni.c_str(), (*it).m_str.c_str())); + LOGDEB2("RclConfig::inStopSuffixes: Found (" << (fni) << ") [" << ((*it).m_str) << "]\n" ); return true; } else { - LOGDEB2(("RclConfig::inStopSuffixes: not found [%s]\n", fni.c_str())); + LOGDEB2("RclConfig::inStopSuffixes: not found [" << (fni) << "]\n" ); return false; } } @@ -718,18 +711,18 @@ string RclConfig::getMimeHandlerDef(const string &mtype, bool filtertypes) } if (!m_restrictMTypes.empty() && !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; } if (!m_excludeMTypes.empty() && m_excludeMTypes.count(stringtolower(mtype))) { - LOGDEB2(("RclConfig::getMimeHandlerDef: in excluded mime list\n")); + LOGDEB2("RclConfig::getMimeHandlerDef: in excluded mime list\n" ); return hs; } } 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; } @@ -820,7 +813,7 @@ void RclConfig::storeMissingHelperDesc(const string &s) FILE *fp = fopen(fmiss.c_str(), "w"); if (fp) { 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); } @@ -830,7 +823,7 @@ void RclConfig::storeMissingHelperDesc(const string &s) // things for speed (theses are used a lot during indexing) bool RclConfig::readFieldsConfig(const string& cnferrloc) { - LOGDEB2(("RclConfig::readFieldsConfig\n")); + LOGDEB2("RclConfig::readFieldsConfig\n" ); m_fields = new ConfStack("fields", m_cdirs, true); if (m_fields == 0 || !m_fields->ok()) { m_reason = string("No/bad fields file in: ") + cnferrloc; @@ -848,8 +841,7 @@ bool RclConfig::readFieldsConfig(const string& cnferrloc) ConfSimple attrs; FieldTraits ft; if (!valueSplitAttributes(val, ft.pfx, attrs)) { - LOGERR(("readFieldsConfig: bad config line for [%s]: [%s]\n", - it->c_str(), val.c_str())); + LOGERR("readFieldsConfig: bad config line for [" << *it << "]: [" << (val) << "]\n" ); return 0; } string tval; @@ -862,8 +854,7 @@ bool RclConfig::readFieldsConfig(const string& cnferrloc) if (attrs.get("noterms", tval)) ft.noterms = stringToBool(tval); m_fldtotraits[stringtolower(*it)] = ft; - LOGDEB2(("readFieldsConfig: [%s] -> [%s] %d %.1f\n", - it->c_str(), ft.pfx.c_str(), ft.wdfinc, ft.boost)); + LOGDEB2("readFieldsConfig: [" << *it << "] -> [" << (ft.pfx) << "] " << (ft.wdfinc) << " " << (ft.boost) << "\n" ); } // Add prefixes for aliases and build alias-to-canonic map while @@ -909,9 +900,7 @@ bool RclConfig::readFieldsConfig(const string& cnferrloc) #if 0 for (map::const_iterator it = m_fldtotraits.begin(); it != m_fldtotraits.end(); it++) { - LOGDEB(("readFieldsConfig: [%s] -> [%s] %d %.1f\n", - it->c_str(), it->second.pfx.c_str(), it->second.wdfinc, - it->second.boost)); + LOGDEB("readFieldsConfig: [" << *it << "] -> [" << (it->second.pfx) << "] " << (it->second.wdfinc) << " " << (it->second.boost) << "\n" ); } #endif @@ -944,12 +933,10 @@ bool RclConfig::getFieldTraits(const string& _fld, const FieldTraits **ftpp, map::const_iterator pit = m_fldtotraits.find(fld); if (pit != m_fldtotraits.end()) { *ftpp = &pit->second; - LOGDEB1(("RclConfig::getFieldTraits: [%s]->[%s]\n", - _fld.c_str(), pit->second.pfx.c_str())); + LOGDEB1("RclConfig::getFieldTraits: [" << (_fld) << "]->[" << (pit->second.pfx) << "]\n" ); return true; } else { - LOGDEB1(("RclConfig::getFieldTraits: no prefix for field [%s]\n", - fld.c_str())); + LOGDEB1("RclConfig::getFieldTraits: no prefix for field [" << (fld) << "]\n" ); *ftpp = 0; return false; } @@ -971,11 +958,10 @@ string RclConfig::fieldCanon(const string& f) const string fld = stringtolower(f); map::const_iterator it = m_aliastocanon.find(fld); if (it != m_aliastocanon.end()) { - LOGDEB1(("RclConfig::fieldCanon: [%s] -> [%s]\n", - f.c_str(), it->second.c_str())); + LOGDEB1("RclConfig::fieldCanon: [" << (f) << "] -> [" << (it->second) << "]\n" ); return it->second; } - LOGDEB1(("RclConfig::fieldCanon: [%s] -> [%s]\n", f.c_str(), fld.c_str())); + LOGDEB1("RclConfig::fieldCanon: [" << (f) << "] -> [" << (fld) << "]\n" ); return fld; } @@ -984,8 +970,7 @@ string RclConfig::fieldQCanon(const string& f) const string fld = stringtolower(f); map::const_iterator it = m_aliastoqcanon.find(fld); if (it != m_aliastoqcanon.end()) { - LOGDEB1(("RclConfig::fieldQCanon: [%s] -> [%s]\n", - f.c_str(), it->second.c_str())); + LOGDEB1("RclConfig::fieldQCanon: [" << (f) << "] -> [" << (it->second) << "]\n" ); return it->second; } return fieldCanon(f); @@ -1031,8 +1016,7 @@ bool RclConfig::setMimeViewerAllEx(const string& allex) string RclConfig::getMimeViewerDef(const string &mtype, const string& apptag, bool useall) const { - LOGDEB2(("RclConfig::getMimeViewerDef: mtype [%s] apptag [%s]\n", - mtype.c_str(), apptag.c_str())); + LOGDEB2("RclConfig::getMimeViewerDef: mtype [" << (mtype) << "] apptag [" << (apptag) << "]\n" ); string hs; if (mimeview == 0) return hs; @@ -1216,19 +1200,17 @@ string RclConfig::getPidfile() const void RclConfig::urlrewrite(const string& dbdir, string& url) const { - LOGDEB2(("RclConfig::urlrewrite: dbdir [%s] url [%s]\n", - dbdir.c_str(), url.c_str())); + LOGDEB2("RclConfig::urlrewrite: dbdir [" << (dbdir) << "] url [" << (url) << "]\n" ); // Do path translations exist for this index ? if (m_ptrans == 0 || !m_ptrans->hasSubKey(dbdir)) { - LOGDEB2(("RclConfig::urlrewrite: no paths translations (m_ptrans %p)\n", - m_ptrans)); + LOGDEB2("RclConfig::urlrewrite: no paths translations (m_ptrans " << (m_ptrans) << ")\n" ); return; } string path = fileurltolocalpath(url); if (path.empty()) { - LOGDEB2(("RclConfig::urlrewrite: not file url\n")); + LOGDEB2("RclConfig::urlrewrite: not file url\n" ); return; } @@ -1387,7 +1369,7 @@ bool RclConfig::getUncompressor(const string &mtype, vector& cmd) const vector tokens; stringToStrings(hs, tokens); if (tokens.empty()) { - LOGERR(("getUncompressor: empty spec for mtype %s\n", mtype.c_str())); + LOGERR("getUncompressor: empty spec for mtype " << (mtype) << "\n" ); return false; } vector::iterator it = tokens.begin(); @@ -1405,7 +1387,7 @@ bool RclConfig::getUncompressor(const string &mtype, vector& cmd) const if (!stringlowercmp("python", *it) || !stringlowercmp("perl", *it)) { it++; 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 { *it = findFilter(*it); } @@ -1552,7 +1534,8 @@ void RclConfig::initParamStale(ConfNull *cnf, ConfNull *mimemap) using namespace std; -#include "debuglog.h" +#include "log.h" + #include "rclinit.h" #include "rclconfig.h" #include "cstr.h" @@ -1727,3 +1710,4 @@ int main(int argc, char **argv) } #endif // TEST_RCLCONFIG + diff --git a/src/common/rclconfig.h b/src/common/rclconfig.h index 0ebc4afe..b11a916e 100644 --- a/src/common/rclconfig.h +++ b/src/common/rclconfig.h @@ -315,7 +315,7 @@ class RclConfig { string findFilter(const string& cmd) const; /** 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 */ void initThrConf(); diff --git a/src/common/rclinit.cpp b/src/common/rclinit.cpp index c3704c7e..4ca3696e 100644 --- a/src/common/rclinit.cpp +++ b/src/common/rclinit.cpp @@ -28,7 +28,7 @@ #include #endif -#include "debuglog.h" +#include "log.h" #include "rclconfig.h" #include "rclinit.h" #include "pathut.h" @@ -60,7 +60,7 @@ static pthread_t mainthread_id; static void siglogreopen(int) { if (recoll_ismainthread()) - DebugLog::reopen(); + Logger::getTheLog("")->reopen(""); } // We would like to block SIGCHLD globally, but we can't because @@ -258,10 +258,7 @@ RclConfig *recollinit(RclInitFlags flags, // to utf8 for indexing. setlocale(LC_CTYPE, ""); - DebugLog::getdbl()->setloglevel(DEBDEB1); - DebugLog::setfilename("stderr"); - if (getenv("RECOLL_LOGDATE")) - DebugLog::getdbl()->logdate(1); + Logger::getTheLog("")->setLogLevel(Logger::LLDEB1); initAsyncSigs(sigcleanup); @@ -297,15 +294,15 @@ RclConfig *recollinit(RclInitFlags flags, if (!logfilename.empty()) { logfilename = path_tildexpand(logfilename); // If not an absolute path or , compute relative to config dir - if (!path_isabsolute(logfilename) && - !DebugLog::DebugLog::isspecialname(logfilename.c_str())) { + if (!path_isabsolute(logfilename) && + logfilename.compare("stderr")) { logfilename = path_cat(config->getConfDir(), logfilename); } - DebugLog::setfilename(logfilename.c_str()); + Logger::getTheLog("")->reopen(logfilename); } if (!loglevel.empty()) { 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 diff --git a/src/common/syngroups.cpp b/src/common/syngroups.cpp index 798b9249..25faf2e8 100644 --- a/src/common/syngroups.cpp +++ b/src/common/syngroups.cpp @@ -19,7 +19,7 @@ #include "syngroups.h" -#include "debuglog.h" +#include "log.h" #include "smallut.h" #include @@ -68,11 +68,11 @@ SynGroups::SynGroups() bool SynGroups::setfile(const string& fn) { - LOGDEB(("SynGroups::setfile(%s)\n", fn.c_str())); + LOGDEB("SynGroups::setfile(" << (fn) << ")\n" ); if (!m) { m = new Internal; if (!m) { - LOGERR(("SynGroups:setfile:: new Internal failed: no mem ?\n")); + LOGERR("SynGroups:setfile:: new Internal failed: no mem ?\n" ); return false; } } @@ -86,8 +86,7 @@ bool SynGroups::setfile(const string& fn) ifstream input; input.open(fn.c_str(), ios::in); if (!input.is_open()) { - LOGERR(("SynGroups:setfile:: could not open %s errno %d\n", - fn.c_str(), errno)); + LOGERR("SynGroups:setfile:: could not open " << (fn) << " errno " << (errno) << "\n" ); return false; } @@ -102,8 +101,7 @@ bool SynGroups::setfile(const string& fn) getline(input, cline); if (!input.good()) { if (input.bad()) { - LOGERR(("Syngroup::setfile(%s):Parse: input.bad()\n", - fn.c_str())); + LOGERR("Syngroup::setfile(" << (fn) << "):Parse: input.bad()\n" ); return false; } // Must be eof ? But maybe we have a partial line which @@ -144,16 +142,14 @@ bool SynGroups::setfile(const string& fn) vector words; if (!stringToStrings(line, words)) { - LOGERR(("SynGroups:setfile: %s: bad line %d: %s\n", - fn.c_str(), lnum, line.c_str())); + LOGERR("SynGroups:setfile: " << (fn) << ": bad line " << (lnum) << ": " << (line) << "\n" ); continue; } if (words.empty()) continue; if (words.size() == 1) { - LOGERR(("Syngroup::setfile(%s):single term group at line %d ??\n", - fn.c_str(), lnum)); + LOGERR("Syngroup::setfile(" << (fn) << "):single term group at line " << (lnum) << " ??\n" ); continue; } @@ -162,8 +158,7 @@ bool SynGroups::setfile(const string& fn) it != words.end(); it++) { m->terms[*it] = m->groups.size()-1; } - LOGDEB1(("SynGroups::setfile: group: [%s]\n", - stringsToString(m->groups.back()).c_str())); + LOGDEB1("SynGroups::setfile: group: [" << (stringsToString(m->groups.back())) << "]\n" ); } m->ok = true; return true; @@ -178,14 +173,13 @@ vector SynGroups::getgroup(const string& term) STD_UNORDERED_MAP::const_iterator it1 = m->terms.find(term); if (it1 == m->terms.end()) { - LOGDEB1(("SynGroups::getgroup: [%s] not found in direct map\n", - term.c_str())); + LOGDEB1("SynGroups::getgroup: [" << (term) << "] not found in direct map\n" ); return ret; } unsigned int idx = it1->second; 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 m->groups[idx]; @@ -194,7 +188,8 @@ vector SynGroups::getgroup(const string& term) #else #include "syngroups.h" -#include "debuglog.h" +#include "log.h" + #include #include @@ -252,3 +247,4 @@ int main(int argc, char **argv) } #endif + diff --git a/src/common/textsplit.cpp b/src/common/textsplit.cpp index f17b0c25..c33b5123 100644 --- a/src/common/textsplit.cpp +++ b/src/common/textsplit.cpp @@ -27,7 +27,7 @@ #include UNORDERED_SET_INCLUDE #include "textsplit.h" -#include "debuglog.h" +#include "log.h" //#define UTF8ITER_CHECK #include "utf8iter.h" #include "uproplist.h" @@ -221,7 +221,7 @@ bool TextSplit::o_deHyphenate = false; inline bool TextSplit::emitterm(bool isspan, string &w, int pos, 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()); @@ -252,7 +252,7 @@ inline bool TextSplit::emitterm(bool isspan, string &w, int pos, m_prevlen = int(w.length()); return ret; } - LOGDEB2(("TextSplit::emitterm:dup: [%s] pos %d\n", w.c_str(), pos)); + LOGDEB2("TextSplit::emitterm:dup: [" << (w) << "] pos " << (pos) << "\n" ); } return true; } @@ -369,10 +369,7 @@ bool TextSplit::words_from_span(size_t bp) inline bool TextSplit::doemit(bool spanerase, size_t _bp) { int bp = int(_bp); - LOGDEB2(("TextSplit::doemit: sper %d bp %d spp %d spanwords %u wS %d wL %d " - "inn %d span [%s]\n", - spanerase, bp, m_spanpos, m_words_in_span.size(), - m_wordStart, m_wordLen, m_inNumber, m_span.c_str())); + 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" ); if (m_wordLen) { // 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) { - LOGDEB1(("TextSplit::text_to_words: docjk %d (%d) %s%s%s [%s]\n", - o_processCJK, o_CJKNgramLen, - m_flags & TXTS_NOSPANS ? " nospans" : "", - m_flags & TXTS_ONLYSPANS ? " onlyspans" : "", - m_flags & TXTS_KEEPWILD ? " keepwild" : "", - in.substr(0,50).c_str())); + LOGDEB1("TextSplit::text_to_words: docjk " << o_processCJK << "(" << + o_CJKNgramLen << ")" << + (m_flags & TXTS_NOSPANS ? " nospans" : "") << + (m_flags & TXTS_ONLYSPANS ? " onlyspans" : "") << + (m_flags & TXTS_KEEPWILD ? " keepwild" : "") << + "[" << in.substr(0,50) << "]\n"); if (in.empty()) return true; @@ -495,7 +492,7 @@ bool TextSplit::text_to_words(const string &in) nonalnumcnt++; 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; } @@ -509,7 +506,7 @@ bool TextSplit::text_to_words(const string &in) // Hand off situation to the cjk routine. if (!cjk_to_words(&it, &c)) { - LOGERR(("Textsplit: scan error in cjk handler\n")); + LOGERR("Textsplit: scan error in cjk handler\n" ); 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... 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; // 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); for (; !it.eof(); it++) { unsigned int c = (unsigned char)*it; - LOGDEB3(("TextSplit::hasVisibleWhite: testing 0x%04x\n", c)); 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; } if (visiblewhite.find(c) != visiblewhite.end()) @@ -931,10 +927,8 @@ template bool u8stringToStrings(const string &s, T &tokens) unsigned int c = *it; if (visiblewhite.find(c) != visiblewhite.end()) c = ' '; - LOGDEB3(("TextSplit::stringToStrings: 0x%04x\n", c)); if (c == (unsigned int)-1) { - LOGERR(("TextSplit::stringToStrings: error while " - "scanning UTF-8 string\n")); + LOGERR("TextSplit::stringToStrings: error while scanning UTF-8 string\n" ); return false; } @@ -1011,7 +1005,8 @@ bool TextSplit::stringToStrings(const string &s, vector &tokens) #include "textsplit.h" #include "readfile.h" -#include "debuglog.h" +#include "log.h" + #include "transcode.h" #include "unacpp.h" #include "termproc.h" @@ -1244,3 +1239,4 @@ int main(int argc, char **argv) } } #endif // TEST + diff --git a/src/common/unacpp.cpp b/src/common/unacpp.cpp index 837786de..a613619e 100644 --- a/src/common/unacpp.cpp +++ b/src/common/unacpp.cpp @@ -24,7 +24,7 @@ #include "unacpp.h" #include "unac.h" -#include "debuglog.h" +#include "log.h" #include "utf8iter.h" 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. bool unaciscapital(const string& in) { - LOGDEB2(("unaciscapital: [%s]\n", in.c_str())); + LOGDEB2("unaciscapital: [" << (in) << "]\n" ); if (in.empty()) return false; Utf8Iter it(in); @@ -77,7 +77,7 @@ bool unaciscapital(const string& in) string lower; 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; } Utf8Iter it1(lower); @@ -88,13 +88,13 @@ bool unaciscapital(const string& in) } bool unachasuppercase(const string& in) { - LOGDEB2(("unachasuppercase: [%s]\n", in.c_str())); + LOGDEB2("unachasuppercase: [" << (in) << "]\n" ); if (in.empty()) return false; string lower; 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; } if (lower != in) @@ -104,13 +104,13 @@ bool unachasuppercase(const string& in) } bool unachasaccents(const string& in) { - LOGDEB2(("unachasaccents: [%s]\n", in.c_str())); + LOGDEB2("unachasaccents: [" << (in) << "]\n" ); if (in.empty()) return false; string noac; 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; } if (noac != in) @@ -247,3 +247,4 @@ int main(int argc, char **argv) } #endif + diff --git a/src/index/beaglequeue.cpp b/src/index/beaglequeue.cpp index 194beccf..5012d6fa 100644 --- a/src/index/beaglequeue.cpp +++ b/src/index/beaglequeue.cpp @@ -24,7 +24,7 @@ #include "cstr.h" #include "pathut.h" #include "rclutil.h" -#include "debuglog.h" +#include "log.h" #include "fstreewalk.h" #include "beaglequeue.h" #include "beaglequeuecache.h" @@ -62,7 +62,7 @@ public: m_input.getline(cline, LL-1); if (!m_input.good()) { if (m_input.bad()) { - LOGERR(("beagleDotFileRead: input.bad()\n")); + LOGERR("beagleDotFileRead: input.bad()\n" ); } return false; } @@ -72,7 +72,7 @@ public: ll--; } line.assign(cline, ll); - LOGDEB2(("BeagleDotFile:readLine: [%s]\n", line.c_str())); + LOGDEB2("BeagleDotFile:readLine: [" << (line) << "]\n" ); return true; } @@ -83,7 +83,7 @@ public: m_input.open(m_fn.c_str(), ios::in); 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; } @@ -185,7 +185,7 @@ BeagleQueueIndexer::BeagleQueueIndexer(RclConfig *cnf, Rcl::Db *db, BeagleQueueIndexer::~BeagleQueueIndexer() { - LOGDEB(("BeagleQueueIndexer::~\n")); + LOGDEB("BeagleQueueIndexer::~\n" ); deleteZ(m_cache); } @@ -202,12 +202,12 @@ bool BeagleQueueIndexer::indexFromCache(const string& udi) string 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; } 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; } @@ -224,11 +224,11 @@ bool BeagleQueueIndexer::indexFromCache(const string& udi) try { fis = interner.internfile(doc); } catch (CancelExcept) { - LOGERR(("BeagleQueueIndexer: interrupted\n")); + LOGERR("BeagleQueueIndexer: interrupted\n" ); return false; } if (fis != FileInterner::FIDone) { - LOGERR(("BeagleQueueIndexer: bad status from internfile\n")); + LOGERR("BeagleQueueIndexer: bad status from internfile\n" ); return false; } @@ -257,15 +257,14 @@ bool BeagleQueueIndexer::index() { if (!m_db) return false; - LOGDEB(("BeagleQueueIndexer::processqueue: [%s]\n", m_queuedir.c_str())); + LOGDEB("BeagleQueueIndexer::processqueue: [" << (m_queuedir) << "]\n" ); m_config->setKeyDir(m_queuedir); if (!path_makepath(m_queuedir, 0700)) { - LOGERR(("BeagleQueueIndexer:: can't create queuedir [%s] errno %d\n", - m_queuedir.c_str(), errno)); + LOGERR("BeagleQueueIndexer:: can't create queuedir [" << (m_queuedir) << "] errno " << (errno) << "\n" ); return false; } if (!m_cache || !m_cache->cc()) { - LOGERR(("BeagleQueueIndexer: cache initialization failed\n")); + LOGERR("BeagleQueueIndexer: cache initialization failed\n" ); return false; } CirCache *cc = m_cache->cc(); @@ -283,7 +282,7 @@ bool BeagleQueueIndexer::index() do { string udi; if (!cc->getCurrentUdi(udi)) { - LOGERR(("BeagleQueueIndexer:: cache file damaged\n")); + LOGERR("BeagleQueueIndexer:: cache file damaged\n" ); break; } if (udi.empty()) @@ -296,7 +295,7 @@ bool BeagleQueueIndexer::index() indexFromCache(udi); updstatus(udi); } catch (CancelExcept) { - LOGERR(("BeagleQueueIndexer: interrupted\n")); + LOGERR("BeagleQueueIndexer: interrupted\n" ); return false; } } @@ -308,17 +307,17 @@ bool BeagleQueueIndexer::index() FsTreeWalker walker(FsTreeWalker::FtwNoRecurse); walker.addSkippedName(".*"); 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; } // Index a list of files (sent by the real time monitor) bool BeagleQueueIndexer::indexFiles(list& files) { - LOGDEB(("BeagleQueueIndexer::indexFiles\n")); + LOGDEB("BeagleQueueIndexer::indexFiles\n" ); if (!m_db) { - LOGERR(("BeagleQueueIndexer::indexfiles no db??\n")); + LOGERR("BeagleQueueIndexer::indexfiles no db??\n" ); return false; } for (list::iterator it = files.begin(); it != files.end();) { @@ -327,8 +326,7 @@ bool BeagleQueueIndexer::indexFiles(list& files) } string father = path_getfather(*it); if (father.compare(m_queuedir)) { - LOGDEB(("BeagleQueueIndexer::indexfiles: skipping [%s] (nq)\n", - it->c_str())); + LOGDEB("BeagleQueueIndexer::indexfiles: skipping [" << *it << "] (nq)\n" ); it++; continue; } // Pb: we are often called with the dot file, before the @@ -344,13 +342,11 @@ bool BeagleQueueIndexer::indexFiles(list& files) } struct stat st; if (path_fileprops(*it, &st) != 0) { - LOGERR(("BeagleQueueIndexer::indexfiles: cant stat [%s]\n", - it->c_str())); + LOGERR("BeagleQueueIndexer::indexfiles: cant stat [" << *it << "]\n" ); it++; continue; } if (!S_ISREG(st.st_mode)) { - LOGDEB(("BeagleQueueIndexer::indexfiles: skipping [%s] (nr)\n", - it->c_str())); + LOGDEB("BeagleQueueIndexer::indexfiles: skipping [" << *it << "] (nr)\n" ); it++; continue; } @@ -378,7 +374,7 @@ BeagleQueueIndexer::processone(const string &path, string dotpath = path_cat(path_getfather(path), string(".") + path_getsimple(path)); - LOGDEB(("BeagleQueueIndexer: prc1: [%s]\n", path.c_str())); + LOGDEB("BeagleQueueIndexer: prc1: [" << (path) << "]\n" ); BeagleDotFile dotfile(m_config, dotpath); Rcl::Doc dotdoc; @@ -392,7 +388,7 @@ BeagleQueueIndexer::processone(const string &path, udipath = path_cat(dotdoc.meta[Rcl::Doc::keybght], url_gpath(dotdoc.url)); make_udi(udipath, cstr_null, udi); - LOGDEB(("BeagleQueueIndexer: prc1: udi [%s]\n", udi.c_str())); + LOGDEB("BeagleQueueIndexer: prc1: udi [" << (udi) << "]\n" ); char ascdate[30]; sprintf(ascdate, "%ld", long(stp->st_mtime)); @@ -424,11 +420,11 @@ BeagleQueueIndexer::processone(const string &path, try { fis = interner.internfile(doc); } catch (CancelExcept) { - LOGERR(("BeagleQueueIndexer: interrupted\n")); + LOGERR("BeagleQueueIndexer: interrupted\n" ); goto out; } 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 // paging a big text file, we should loop. Means we're // only indexing the first page for text/plain files @@ -461,12 +457,11 @@ BeagleQueueIndexer::processone(const string &path, string fdata; file_to_string(path, fdata); if (!m_cache || !m_cache->cc()) { - LOGERR(("BeagleQueueIndexer: cache initialization failed\n")); + LOGERR("BeagleQueueIndexer: cache initialization failed\n" ); goto out; } if (!m_cache->cc()->put(udi, &dotfile.m_fields, fdata, 0)) { - LOGERR(("BeagleQueueIndexer::prc1: cache_put failed; %s\n", - m_cache->cc()->getReason().c_str())); + LOGERR("BeagleQueueIndexer::prc1: cache_put failed; " << (m_cache->cc()->getReason()) << "\n" ); goto out; } } @@ -479,3 +474,4 @@ out: } return FsTreeWalker::FtwOk; } + diff --git a/src/index/bglfetcher.cpp b/src/index/bglfetcher.cpp index 772e7875..495116a8 100644 --- a/src/index/bglfetcher.cpp +++ b/src/index/bglfetcher.cpp @@ -16,11 +16,10 @@ */ #include "autoconfig.h" -#include "debuglog.h" #include "rcldoc.h" #include "fetcher.h" #include "bglfetcher.h" -#include "debuglog.h" +#include "log.h" #include "ptmutex.h" #include "beaglequeuecache.h" @@ -32,7 +31,7 @@ bool BGLDocFetcher::fetch(RclConfig* cnf, const Rcl::Doc& idoc, RawDoc& out) { string udi; 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; } Rcl::Doc dotdoc; @@ -43,13 +42,12 @@ bool BGLDocFetcher::fetch(RclConfig* cnf, const Rcl::Doc& idoc, RawDoc& out) // deleted when the program exits. static BeagleQueueCache o_beagler(cnf); 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; } } if (dotdoc.mimetype.compare(idoc.mimetype)) { - LOGINFO(("BGLDocFetcher:: udi [%s], mimetp mismatch: in: [%s], bgl " - "[%s]\n", idoc.mimetype.c_str(), dotdoc.mimetype.c_str())); + LOGINFO("BGLDocFetcher:: udi [" << (udi) << "], mimetp mismatch: in: [" << (idoc.mimetype) << "], bgl [" << (dotdoc.mimetype) << "]\n" ); } out.kind = RawDoc::RDK_DATA; return true; @@ -62,3 +60,4 @@ bool BGLDocFetcher::makesig(RclConfig* cnf, const Rcl::Doc& idoc, string& sig) return true; } + diff --git a/src/index/checkretryfailed.cpp b/src/index/checkretryfailed.cpp index f4a97fd9..e85cc45f 100644 --- a/src/index/checkretryfailed.cpp +++ b/src/index/checkretryfailed.cpp @@ -21,7 +21,7 @@ #include "rclconfig.h" #include "execmd.h" -#include "debuglog.h" +#include "log.h" #include "checkretryfailed.h" using namespace std; @@ -34,8 +34,7 @@ bool checkRetryFailed(RclConfig *conf, bool record) string cmd; if (!conf->getConfParam("checkneedretryindexscript", cmd)) { - LOGDEB(("checkRetryFailed: 'checkneedretryindexscript' " - "not set in config\n")); + LOGDEB("checkRetryFailed: 'checkneedretryindexscript' not set in config\n" ); // We could toss a dice ? Say no retry in this case. return false; } @@ -56,3 +55,4 @@ bool checkRetryFailed(RclConfig *conf, bool record) return false; #endif } + diff --git a/src/index/exefetcher.cpp b/src/index/exefetcher.cpp index 2ee8bfde..cc5ea2e7 100644 --- a/src/index/exefetcher.cpp +++ b/src/index/exefetcher.cpp @@ -22,7 +22,7 @@ #include "exefetcher.h" -#include "debuglog.h" +#include "log.h" #include "pathut.h" #include "rclconfig.h" #include "execmd.h" @@ -47,12 +47,10 @@ public: args.push_back(idoc.ipath); int status = ecmd.doexec1(args, 0, &out); if (status == 0) { - LOGDEB(("EXEDocFetcher::Internal: got [%s]\n", out.c_str())); + LOGDEB("EXEDocFetcher::Internal: got [" << (out) << "]\n" ); return true; } else { - LOGERR(("EXEDOcFetcher::fetch: %s: %s failed for %s %s %s 0x%u\n", - bckid.c_str(), stringsToString(cmd).c_str(), udi.c_str(), - idoc.url.c_str(), idoc.ipath.c_str())); + LOGERR("EXEDOcFetcher::fetch: " << (bckid) << ": " << (stringsToString(cmd)) << " failed for " << (udi) << " " << (idoc.url) << " " << (idoc.ipath) << "\n" ); return false; } } @@ -61,8 +59,7 @@ public: EXEDocFetcher::EXEDocFetcher(const EXEDocFetcher::Internal& _m) { m = new Internal(_m); - LOGDEB(("EXEDocFetcher::EXEDocFetcher: fetch is %s\n", - stringsToString(m->sfetch).c_str())); + LOGDEB("EXEDocFetcher::EXEDocFetcher: fetch is " << (stringsToString(m->sfetch)) << "\n" ); } 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; if (!bconf) { 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); if (!bconf->ok()) { delete bconf; bconf = 0; - LOGDEB(("exeDocFetcherMake: bad/no config: %s\n", - bconfname.c_str())); + LOGDEB("exeDocFetcherMake: bad/no config: " << (bconfname) << "\n" ); return 0; } } @@ -101,29 +97,28 @@ EXEDocFetcher *exeDocFetcherMake(RclConfig *config, const string& bckid) string sfetch; 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; } stringToStrings(sfetch, m.sfetch); // We look up the command as we do for filters for now m.sfetch[0] = config->findFilter(m.sfetch[0]); if (!path_isabsolute(m.sfetch[0])) { - LOGERR(("exeDocFetcherMake: %s not found in exec path or filters dir\n", - m.sfetch[0].c_str())); + LOGERR("exeDocFetcherMake: " << (m.sfetch[0]) << " not found in exec path or filters dir\n" ); return 0; } string smkid; 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; } stringToStrings(smkid, m.smkid); m.smkid[0] = config->findFilter(m.smkid[0]); if (!path_isabsolute(m.smkid[0])) { - LOGERR(("exeDocFetcherMake: %s not found in exec path or filters dir\n", - m.smkid[0].c_str())); + LOGERR("exeDocFetcherMake: " << (m.smkid[0]) << " not found in exec path or filters dir\n" ); return 0; } return new EXEDocFetcher(m); } + diff --git a/src/index/fetcher.cpp b/src/index/fetcher.cpp index db277437..99d60735 100644 --- a/src/index/fetcher.cpp +++ b/src/index/fetcher.cpp @@ -17,7 +17,7 @@ #include "autoconfig.h" -#include "debuglog.h" +#include "log.h" #include "rclconfig.h" #include "fetcher.h" @@ -28,7 +28,7 @@ DocFetcher *docFetcherMake(RclConfig *config, const Rcl::Doc& idoc) { if (idoc.url.empty()) { - LOGERR(("docFetcherMakeg:: no url in doc!\n")); + LOGERR("docFetcherMakeg:: no url in doc!\n" ); return 0; } string backend; @@ -42,9 +42,9 @@ DocFetcher *docFetcherMake(RclConfig *config, const Rcl::Doc& idoc) } else { DocFetcher *f = exeDocFetcherMake(config, backend); if (!f) { - LOGERR(("DocFetcherFactory: unknown backend [%s]\n", - backend.c_str())); + LOGERR("DocFetcherFactory: unknown backend [" << (backend) << "]\n" ); } return f; } } + diff --git a/src/index/fsfetcher.cpp b/src/index/fsfetcher.cpp index 8210760e..a699863b 100644 --- a/src/index/fsfetcher.cpp +++ b/src/index/fsfetcher.cpp @@ -19,12 +19,11 @@ #include #include "safesysstat.h" -#include "debuglog.h" +#include "log.h" #include "cstr.h" #include "fetcher.h" #include "fsfetcher.h" #include "fsindexer.h" -#include "debuglog.h" #include "pathut.h" using std::string; @@ -35,8 +34,7 @@ static bool urltopath(RclConfig* cnf, // The url has to be like file:// fn = fileurltolocalpath(idoc.url); if (fn.empty()) { - LOGERR(("FSDocFetcher::fetch/sig: non fs url: [%s]\n", - idoc.url.c_str())); + LOGERR("FSDocFetcher::fetch/sig: non fs url: [" << (idoc.url) << "]\n" ); return false; } cnf->setKeyDir(path_getfather(fn)); @@ -44,8 +42,7 @@ static bool urltopath(RclConfig* cnf, cnf->getConfParam("followLinks", &follow); if (path_fileprops(fn, &st, follow) < 0) { - LOGERR(("FSDocFetcher::fetch: stat errno %d for [%s]\n", - errno, fn.c_str())); + LOGERR("FSDocFetcher::fetch: stat errno " << (errno) << " for [" << (fn) << "]\n" ); return false; } return true; @@ -71,3 +68,4 @@ bool FSDocFetcher::makesig(RclConfig* cnf, const Rcl::Doc& idoc, string& sig) return true; } + diff --git a/src/index/fsindexer.cpp b/src/index/fsindexer.cpp index 7b7dbb77..84500ae9 100644 --- a/src/index/fsindexer.cpp +++ b/src/index/fsindexer.cpp @@ -37,7 +37,7 @@ #include "indexer.h" #include "fsindexer.h" #include "transcode.h" -#include "debuglog.h" +#include "log.h" #include "internfile.h" #include "smallut.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) #endif // IDX_THREADS { - LOGDEB1(("FsIndexer::FsIndexer\n")); + LOGDEB1("FsIndexer::FsIndexer\n" ); m_havelocalfields = m_config->hasNameAnywhere("localfields"); m_config->getConfParam("detectxattronly", &m_detectxattronly); #ifdef IDX_THREADS m_stableconfig = new RclConfig(*m_config); - m_loglevel = DebugLog::getdbl()->getlevel(); m_haveInternQ = m_haveSplitQ = false; int internqlen = cnf->getThrConf(RclConfig::ThrIntern).first; int internthreads = cnf->getThrConf(RclConfig::ThrIntern).second; if (internqlen >= 0) { if (!m_iwqueue.start(internthreads, FsIndexerInternfileWorker, this)) { - LOGERR(("FsIndexer::FsIndexer: intern worker start failed\n")); + LOGERR("FsIndexer::FsIndexer: intern worker start failed\n" ); return; } m_haveInternQ = true; @@ -127,30 +126,28 @@ FsIndexer::FsIndexer(RclConfig *cnf, Rcl::Db *db, DbIxStatusUpdater *updfunc) int splitthreads = cnf->getThrConf(RclConfig::ThrSplit).second; if (splitqlen >= 0) { if (!m_dwqueue.start(splitthreads, FsIndexerDbUpdWorker, this)) { - LOGERR(("FsIndexer::FsIndexer: split worker start failed\n")); + LOGERR("FsIndexer::FsIndexer: split worker start failed\n" ); return; } m_haveSplitQ = true; } - LOGDEB(("FsIndexer: threads: haveIQ %d iql %d iqts %d " - "haveSQ %d sql %d sqts %d\n", m_haveInternQ, internqlen, - internthreads, m_haveSplitQ, splitqlen, splitthreads)); + LOGDEB("FsIndexer: threads: haveIQ " << (m_haveInternQ) << " iql " << (internqlen) << " iqts " << (internthreads) << " haveSQ " << (m_haveSplitQ) << " sql " << (splitqlen) << " sqts " << (splitthreads) << "\n" ); #endif // IDX_THREADS } FsIndexer::~FsIndexer() { - LOGDEB1(("FsIndexer::~FsIndexer()\n")); + LOGDEB1("FsIndexer::~FsIndexer()\n" ); #ifdef IDX_THREADS void *status; if (m_haveInternQ) { 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) { 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; #endif // IDX_THREADS @@ -163,7 +160,7 @@ bool FsIndexer::init() if (m_tdl.empty()) { m_tdl = m_config->getTopdirs(); if (m_tdl.empty()) { - LOGERR(("FsIndexers: no topdirs list defined\n")); + LOGERR("FsIndexers: no topdirs list defined\n" ); return false; } } @@ -194,8 +191,8 @@ bool FsIndexer::index(int flags) for (vector::const_iterator it = m_tdl.begin(); it != m_tdl.end(); it++) { - LOGDEB(("FsIndexer::index: Indexing %s into %s\n", it->c_str(), - getDbDir().c_str())); + LOGDEB("FsIndexer::index: Indexing " << *it << " into " << + getDbDir() << "\n"); // Set the current directory in config so that subsequent // getConfParams() will get local values @@ -217,8 +214,8 @@ bool FsIndexer::index(int flags) // Walk the directory tree if (m_walker.walk(*it, *this) != FsTreeWalker::FtwOk) { - LOGERR(("FsIndexer::index: error while indexing %s: %s\n", - it->c_str(), m_walker.getReason().c_str())); + LOGERR("FsIndexer::index: error while indexing " << *it << + ": " << m_walker.getReason() << "\n"); return false; } } @@ -235,12 +232,11 @@ bool FsIndexer::index(int flags) string missing; m_missing->getMissingDescription(missing); if (!missing.empty()) { - LOGINFO(("FsIndexer::index missing helper program(s):\n%s\n", - missing.c_str())); + LOGINFO("FsIndexer::index missing helper program(s):\n" << (missing) << "\n" ); } m_config->storeMissingHelperDesc(missing); } - LOGINFO(("fsindexer index time: %d mS\n", chron.millis())); + LOGINFO("fsindexer index time: " << (chron.millis()) << " mS\n" ); return true; } @@ -261,8 +257,7 @@ static bool matchesSkipped(const vector& tdl, for (vector::const_iterator it = tdl.begin(); it != tdl.end(); it++) { // the topdirs members are already canonized. - LOGDEB2(("matchesSkipped: comparing ancestor [%s] to " - "topdir [%s]\n", mpath.c_str(), it->c_str())); + LOGDEB2("matchesSkipped: comparing ancestor [" << (mpath) << "] to topdir [" << (it) << "]\n" ); if (!mpath.compare(*it)) { topdir = *it; goto goodpath; @@ -270,8 +265,7 @@ static bool matchesSkipped(const vector& tdl, } if (walker.inSkippedPaths(mpath, false)) { - LOGDEB(("FsIndexer::indexFiles: skipping [%s] (skpp)\n", - path.c_str())); + LOGDEB("FsIndexer::indexFiles: skipping [" << (path) << "] (skpp)\n" ); return true; } @@ -285,13 +279,12 @@ static bool matchesSkipped(const vector& tdl, // path did not shorten, something is seriously amiss // (could be an assert actually) if (mpath.length() >= len) { - LOGERR(("FsIndexer::indexFile: internal Error: path [%s] did not " - "shorten\n", mpath.c_str())); + LOGERR("FsIndexer::indexFile: internal Error: path [" << (mpath) << "] did not shorten\n" ); return true; } } // 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; goodpath: @@ -301,8 +294,7 @@ goodpath: while (mpath.length() >= topdir.length() && mpath.length() > 1) { string fn = path_getsimple(mpath); if (walker.inSkippedNames(fn)) { - LOGDEB(("FsIndexer::indexFiles: skipping [%s] (skpn)\n", - path.c_str())); + LOGDEB("FsIndexer::indexFiles: skipping [" << (path) << "] (skpn)\n" ); return true; } @@ -326,7 +318,7 @@ goodpath: */ bool FsIndexer::indexFiles(list& files, int flags) { - LOGDEB(("FsIndexer::indexFiles\n")); + LOGDEB("FsIndexer::indexFiles\n" ); m_noretryfailed = (flags & ConfIndexer::IxFNoRetryFailed) != 0; bool ret = false; @@ -344,7 +336,7 @@ bool FsIndexer::indexFiles(list& files, int flags) walker.setSkippedPaths(m_config->getSkippedPaths()); for (list::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)); if (m_havelocalfields) @@ -364,15 +356,15 @@ bool FsIndexer::indexFiles(list& files, int flags) struct stat stb; int ststat = path_fileprops(*it, &stb, follow); if (ststat != 0) { - LOGERR(("FsIndexer::indexFiles: (l)stat %s: %s", it->c_str(), - strerror(errno))); + LOGERR("FsIndexer::indexFiles: (l)stat " << *it << ": " << + strerror(errno) << "\n"); it++; continue; } if (processone(*it, &stb, FsTreeWalker::FtwRegular) != FsTreeWalker::FtwOk) { - LOGERR(("FsIndexer::indexFiles: processone failed\n")); + LOGERR("FsIndexer::indexFiles: processone failed\n" ); goto out; } it = files.erase(it); @@ -390,11 +382,11 @@ out: // Purge possible orphan documents if (ret == true) { - LOGDEB(("Indexfiles: purging orphans\n")); + LOGDEB("Indexfiles: purging orphans\n" ); const vector& purgecandidates = m_purgeCandidates.getCandidates(); for (vector::const_iterator it = purgecandidates.begin(); 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); } #ifdef IDX_THREADS @@ -402,7 +394,7 @@ out: #endif // IDX_THREADS } - LOGDEB(("FsIndexer::indexFiles: done\n")); + LOGDEB("FsIndexer::indexFiles: done\n" ); return ret; } @@ -410,7 +402,7 @@ out: /** Purge docs for given files out of the database */ bool FsIndexer::purgeFiles(list& files) { - LOGDEB(("FsIndexer::purgeFiles\n")); + LOGDEB("FsIndexer::purgeFiles\n" ); bool ret = false; if (!init()) return false; @@ -422,7 +414,7 @@ bool FsIndexer::purgeFiles(list& files) // found or deleted, false only in case of actual error bool existed; if (!m_db->purgeFile(udi, &existed)) { - LOGERR(("FsIndexer::purgeFiles: Database error\n")); + LOGERR("FsIndexer::purgeFiles: Database error\n" ); goto out; } // If we actually deleted something, take it off the list @@ -442,14 +434,14 @@ out: m_dwqueue.waitIdle(); m_db->waitUpdIdle(); #endif // IDX_THREADS - LOGDEB(("FsIndexer::purgeFiles: done\n")); + LOGDEB("FsIndexer::purgeFiles: done\n" ); return ret; } // Local fields can be set for fs subtrees in the configuration file void FsIndexer::localfieldsfromconf() { - LOGDEB1(("FsIndexer::localfieldsfromconf\n")); + LOGDEB1("FsIndexer::localfieldsfromconf\n" ); string sfields; m_config->getConfParam("localfields", sfields); @@ -469,8 +461,7 @@ void FsIndexer::localfieldsfromconf() it != nmlst.end(); it++) { string nm = m_config->fieldCanon(*it); attrs.get(*it, m_localfields[nm]); - LOGDEB2(("FsIndexer::localfieldsfromconf: [%s]->[%s]\n", - nm.c_str(), m_localfields[nm].c_str())); + LOGDEB2("FsIndexer::localfieldsfromconf: [" << (nm) << "]->[" << (m_localfields[nm]) << "]\n" ); } } @@ -501,7 +492,6 @@ void *FsIndexerDbUpdWorker(void * fsp) recoll_threadinit(); FsIndexer *fip = (FsIndexer*)fsp; WorkQueue *tqp = &fip->m_dwqueue; - DebugLog::getdbl()->setloglevel(fip->m_loglevel); DbUpdTask *tsk; for (;;) { @@ -510,9 +500,9 @@ void *FsIndexerDbUpdWorker(void * fsp) tqp->workerExit(); 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)) { - LOGERR(("FsIndexerDbUpdWorker: addOrUpdate failed\n")); + LOGERR("FsIndexerDbUpdWorker: addOrUpdate failed\n" ); tqp->workerExit(); return (void*)0; } @@ -525,7 +515,6 @@ void *FsIndexerInternfileWorker(void * fsp) recoll_threadinit(); FsIndexer *fip = (FsIndexer*)fsp; WorkQueue *tqp = &fip->m_iwqueue; - DebugLog::getdbl()->setloglevel(fip->m_loglevel); RclConfig myconf(*(fip->m_stableconfig)); InternfileTask *tsk = 0; @@ -534,15 +523,15 @@ void *FsIndexerInternfileWorker(void * fsp) tqp->workerExit(); 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, tsk->localfields) != FsTreeWalker::FtwOk) { - LOGERR(("FsIndexerInternfileWorker: processone failed\n")); + LOGERR("FsIndexerInternfileWorker: processone failed\n" ); tqp->workerExit(); return (void*)0; } - LOGDEB1(("FsIndexerInternfileWorker: done fn %s\n", tsk->fn.c_str())); + LOGDEB1("FsIndexerInternfileWorker: done fn " << (tsk->fn) << "\n" ); delete tsk; } } @@ -613,15 +602,11 @@ static string compute_utf8fn(RclConfig *config, const string& fn) string utf8fn; int ercnt; if (!transcode(path_getsimple(fn), utf8fn, charset, "UTF-8", &ercnt)) { - LOGERR(("processone: fn transcode failure from [%s] to UTF-8: %s\n", - charset.c_str(), path_getsimple(fn).c_str())); + LOGERR("processone: fn transcode failure from [" << (charset) << "] to UTF-8: " << (path_getsimple(fn)) << "\n" ); } else if (ercnt) { - LOGDEB(("processone: fn transcode %d errors from [%s] to UTF-8: %s\n", - ercnt, charset.c_str(), path_getsimple(fn).c_str())); + LOGDEB("processone: fn transcode " << (ercnt) << " errors from [" << (charset) << "] to UTF-8: " << (path_getsimple(fn)) << "\n" ); } - LOGDEB2(("processone: fn transcoded from [%s] to [%s] (%s->%s)\n", - path_getsimple(fn).c_str(), utf8fn.c_str(), charset.c_str(), - "UTF-8")); + LOGDEB2("processone: fn transcoded from [" << (path_getsimple(fn)) << "] to [" << (utf8fn) << "] (" << (charset) << "->" << ("UTF-8") << ")\n" ); return utf8fn; } @@ -663,8 +648,7 @@ FsIndexer::processonefile(RclConfig *config, bool xattronly = m_detectxattronly && !m_db->inFullReset() && existingDoc && needupdate && (stp->st_mtime < stp->st_ctime); - LOGDEB(("processone: needupdate %d noretry %d existing %d oldsig [%s]\n", - needupdate, m_noretryfailed, existingDoc, oldsig.c_str())); + LOGDEB("processone: needupdate " << (needupdate) << " noretry " << (m_noretryfailed) << " existing " << (existingDoc) << " oldsig [" << (oldsig) << "]\n" ); // If noretryfailed is set, check for a file which previously // 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) string nold = oldsig.substr(0, oldsig.size()-1); 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); needupdate = false; } } if (!needupdate) { - LOGDEB0(("processone: up to date: %s\n", fn.c_str())); + LOGDEB0("processone: up to date: " << (fn) << "\n" ); if (m_updater) { #ifdef IDX_THREADS PTMutexLocker locker(m_updater->m_mutex); @@ -696,8 +680,7 @@ FsIndexer::processonefile(RclConfig *config, return FsTreeWalker::FtwOk; } - LOGDEB0(("processone: processing: [%s] %s\n", - displayableBytes(off_t(stp->st_size)).c_str(), fn.c_str())); + LOGDEB0("processone: processing: [" << (displayableBytes(off_t(stp->st_size))) << "] " << (fn) << "\n" ); string utf8fn = compute_utf8fn(config, fn); @@ -729,7 +712,7 @@ FsIndexer::processonefile(RclConfig *config, try { fis = interner.internfile(doc); } catch (CancelExcept) { - LOGERR(("fsIndexer::processone: interrupted\n")); + LOGERR("fsIndexer::processone: interrupted\n" ); return FsTreeWalker::FtwStop; } @@ -800,7 +783,7 @@ FsIndexer::processonefile(RclConfig *config, DbUpdTask *tp = new DbUpdTask(udi, doc.ipath.empty() ? cstr_null : parent_udi, doc); if (!m_dwqueue.put(tp)) { - LOGERR(("processonefile: wqueue.put failed\n")); + LOGERR("processonefile: wqueue.put failed\n" ); return FsTreeWalker::FtwError; } } else { @@ -839,8 +822,7 @@ FsIndexer::processonefile(RclConfig *config, // 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 // db-wide purge, e.g. if we're called from indexfiles()). - LOGDEB2(("processOnefile: existingDoc %d hadNonNullIpath %d\n", - existingDoc, hadNonNullIpath)); + LOGDEB2("processOnefile: existingDoc " << (existingDoc) << " hadNonNullIpath " << (hadNonNullIpath) << "\n" ); if (existingDoc && hadNonNullIpath) { 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 // by the following step. 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; if (xattronly) { map xfields; @@ -889,3 +871,4 @@ FsIndexer::processonefile(RclConfig *config, return FsTreeWalker::FtwOk; } + diff --git a/src/index/fsindexer.h b/src/index/fsindexer.h index 42d65e03..ade62522 100644 --- a/src/index/fsindexer.h +++ b/src/index/fsindexer.h @@ -142,7 +142,6 @@ class FsIndexer : public FsTreeWalkerCB { #ifdef IDX_THREADS friend void *FsIndexerDbUpdWorker(void*); friend void *FsIndexerInternfileWorker(void*); - int m_loglevel; WorkQueue m_iwqueue; WorkQueue m_dwqueue; bool m_haveInternQ; diff --git a/src/index/indexer.cpp b/src/index/indexer.cpp index e58b0d8e..dc893f8e 100644 --- a/src/index/indexer.cpp +++ b/src/index/indexer.cpp @@ -22,7 +22,7 @@ #include #include "cstr.h" -#include "debuglog.h" +#include "log.h" #include "indexer.h" #include "fsindexer.h" #ifndef DISABLE_WEB_INDEXER @@ -60,13 +60,13 @@ bool ConfIndexer::runFirstIndexing() { // Indexing status file existing and not empty ? 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; } // And only do this if the user has kept the default topdirs (~). vector tdl = m_config->getTopdirs(); 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 true; @@ -74,7 +74,7 @@ bool ConfIndexer::runFirstIndexing() bool ConfIndexer::firstFsIndexingSequence() { - LOGDEB(("ConfIndexer::firstFsIndexingSequence\n")); + LOGDEB("ConfIndexer::firstFsIndexingSequence\n" ); deleteZ(m_fsindexer); m_fsindexer = new FsIndexer(m_config, &m_db, m_updater); 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; if (!m_db.open(mode)) { - LOGERR(("ConfIndexer: error opening database %s : %s\n", - m_config->getDbDir().c_str(), m_db.getReason().c_str())); + LOGERR("ConfIndexer: error opening database " << (m_config->getDbDir()) << " : " << (m_db.getReason()) << "\n" ); return false; } @@ -135,8 +134,7 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags) if (m_updater) m_updater->update(DbIxStatus::DBIXS_CLOSING, string()); if (!m_db.close()) { - LOGERR(("ConfIndexer::index: error closing database in %s\n", - m_config->getDbDir().c_str())); + LOGERR("ConfIndexer::index: error closing database in " << (m_config->getDbDir()) << "\n" ); return false; } @@ -163,8 +161,7 @@ bool ConfIndexer::indexFiles(list& ifiles, int flag) myfiles.sort(); if (!m_db.open(Rcl::Db::DbUpd)) { - LOGERR(("ConfIndexer: indexFiles error opening database %s\n", - m_config->getDbDir().c_str())); + LOGERR("ConfIndexer: indexFiles error opening database " << (m_config->getDbDir()) << "\n" ); return false; } m_config->setKeyDir(cstr_null); @@ -173,8 +170,7 @@ bool ConfIndexer::indexFiles(list& ifiles, int flag) m_fsindexer = new FsIndexer(m_config, &m_db, m_updater); if (m_fsindexer) ret = m_fsindexer->indexFiles(myfiles, flag); - LOGDEB2(("ConfIndexer::indexFiles: fsindexer returned %d, " - "%d files remainining\n", ret, myfiles.size())); + LOGDEB2("ConfIndexer::indexFiles: fsindexer returned " << (ret) << ", " << (myfiles.size()) << " files remainining\n" ); #ifndef DISABLE_WEB_INDEXER if (m_dobeagle && !myfiles.empty() && !(flag & IxFNoWeb)) { @@ -189,8 +185,7 @@ bool ConfIndexer::indexFiles(list& ifiles, int flag) #endif // The close would be done in our destructor, but we want status here if (!m_db.close()) { - LOGERR(("ConfIndexer::index: error closing database in %s\n", - m_config->getDbDir().c_str())); + LOGERR("ConfIndexer::index: error closing database in " << (m_config->getDbDir()) << "\n" ); return false; } ifiles = myfiles; @@ -214,8 +209,7 @@ bool ConfIndexer::docsToPaths(vector &docs, vector &paths) // Filesystem document. The url has to be like file:// if (idoc.url.find(cstr_fileu) != 0) { - LOGERR(("idx::docsToPaths: FS backend and non fs url: [%s]\n", - idoc.url.c_str())); + LOGERR("idx::docsToPaths: FS backend and non fs url: [" << (idoc.url) << "]\n" ); continue; } paths.push_back(idoc.url.substr(7, string::npos)); @@ -247,8 +241,7 @@ bool ConfIndexer::purgeFiles(std::list &files, int flag) myfiles.sort(); if (!m_db.open(Rcl::Db::DbUpd)) { - LOGERR(("ConfIndexer: purgeFiles error opening database %s\n", - m_config->getDbDir().c_str())); + LOGERR("ConfIndexer: purgeFiles error opening database " << (m_config->getDbDir()) << "\n" ); return false; } bool ret = false; @@ -272,8 +265,7 @@ bool ConfIndexer::purgeFiles(std::list &files, int flag) // The close would be done in our destructor, but we want status here if (!m_db.close()) { - LOGERR(("ConfIndexer::purgefiles: error closing database in %s\n", - m_config->getDbDir().c_str())); + LOGERR("ConfIndexer::purgefiles: error closing database in " << (m_config->getDbDir()) << "\n" ); return false; } return ret; @@ -286,7 +278,7 @@ bool ConfIndexer::createStemmingDatabases() string slangs; if (m_config->getConfParam("indexstemminglanguages", slangs)) { 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; } vector langs; @@ -319,7 +311,7 @@ bool ConfIndexer::createStemDb(const string &lang) // module, either from a configuration variable or the NLS environment. bool ConfIndexer::createAspellDict() { - LOGDEB2(("ConfIndexer::createAspellDict()\n")); + LOGDEB2("ConfIndexer::createAspellDict()\n" ); #ifdef RCL_USE_ASPELL // For the benefit of the real-time indexer, we only initialize // noaspell from the configuration once. It can then be set to @@ -334,22 +326,20 @@ bool ConfIndexer::createAspellDict() return true; 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; } Aspell aspell(m_config); string reason; if (!aspell.init(reason)) { - LOGERR(("ConfIndexer::createAspellDict: aspell init failed: %s\n", - reason.c_str())); + LOGERR("ConfIndexer::createAspellDict: aspell init failed: " << (reason) << "\n" ); noaspell = true; return false; } - LOGDEB(("ConfIndexer::createAspellDict: creating dictionary\n")); + LOGDEB("ConfIndexer::createAspellDict: creating dictionary\n" ); if (!aspell.buildDict(m_db, reason)) { - LOGERR(("ConfIndexer::createAspellDict: aspell buildDict failed: %s\n", - reason.c_str())); + LOGERR("ConfIndexer::createAspellDict: aspell buildDict failed: " << (reason) << "\n" ); noaspell = true; return false; } @@ -361,3 +351,4 @@ vector ConfIndexer::getStemmerNames() { return Rcl::Db::getStemmerNames(); } + diff --git a/src/index/mimetype.cpp b/src/index/mimetype.cpp index 11073957..11b7154f 100644 --- a/src/index/mimetype.cpp +++ b/src/index/mimetype.cpp @@ -26,7 +26,7 @@ using namespace std; #include "mimetype.h" -#include "debuglog.h" +#include "log.h" #include "execmd.h" #include "rclconfig.h" #include "smallut.h" @@ -64,7 +64,7 @@ static string mimetypefromdata(RclConfig *cfg, const string &fn, bool usfc) vector cmd; string 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); string exe; if (cmd.empty()) { @@ -76,19 +76,17 @@ static string mimetypefromdata(RclConfig *cfg, const string &fn, bool usfc) } cmd.push_back(fn); } else { - LOGDEB(("mimetype:systemfilecommand not found, using %s\n", - stringsToString(tradfilecmd).c_str())); + LOGDEB("mimetype:systemfilecommand not found, using " << (stringsToString(tradfilecmd)) << "\n" ); cmd = tradfilecmd; } string result; if (!ExecCmd::backtick(cmd, result)) { - LOGERR(("mimetypefromdata: exec %s failed\n", - stringsToString(cmd).c_str())); + LOGERR("mimetypefromdata: exec " << (stringsToString(cmd)) << " failed\n" ); return string(); } 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: // 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) { // Garbage "file" output. Maybe the result of a charset // conversion attempt? - LOGERR(("mimetype: can't interpret 'file' output: [%s]\n", - result.c_str())); + LOGERR("mimetype: can't interpret 'file' output: [" << (result) << "]\n" ); return string(); } 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: // http://freedesktop.org/wiki/CommonExtendedAttributes 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()) { - LOGDEB0(("Mimetype: getxattr() returned empty mime type !\n")); + LOGDEB0("Mimetype: getxattr() returned empty mime type !\n" ); } else { return mtype; } @@ -174,12 +171,12 @@ string mimetype(const string &fn, const struct stat *stp, #endif if (cfg == 0) { - LOGERR(("Mimetype: null config ??\n")); + LOGERR("Mimetype: null config ??\n" ); return mtype; } if (cfg->inStopSuffixes(fn)) { - LOGDEB(("mimetype: fn [%s] in stopsuffixes\n", fn.c_str())); + LOGDEB("mimetype: fn [" << (fn) << "] in stopsuffixes\n" ); return mtype; } @@ -211,7 +208,8 @@ string mimetype(const string &fn, const struct stat *stp, #include #include -#include "debuglog.h" +#include "log.h" + #include "rclconfig.h" #include "rclinit.h" #include "mimetype.h" @@ -245,3 +243,4 @@ int main(int argc, const char **argv) #endif // TEST + diff --git a/src/index/rclmonprc.cpp b/src/index/rclmonprc.cpp index 566f6727..ba2c65d7 100644 --- a/src/index/rclmonprc.cpp +++ b/src/index/rclmonprc.cpp @@ -37,9 +37,10 @@ using std::list; using std::vector; -#include "debuglog.h" +#include "log.h" #include "rclmon.h" -#include "debuglog.h" +#include "log.h" + #include "execmd.h" #include "recollindex.h" #include "pathut.h" @@ -167,7 +168,7 @@ void RclEQData::readDelayPats(int dfltsecs) vector dplist; if (!stringToStrings(patstring, dplist)) { - LOGERR(("rclEQData: bad pattern list: [%s]\n", patstring.c_str())); + LOGERR("rclEQData: bad pattern list: [" << (patstring) << "]\n" ); return; } @@ -182,8 +183,7 @@ void RclEQData::readDelayPats(int dfltsecs) dp.seconds = dfltsecs; } m_delaypats.push_back(dp); - LOGDEB2(("rclmon::readDelayPats: add [%s] %d\n", - dp.pattern.c_str(), dp.seconds)); + LOGDEB2("rclmon::readDelayPats: add [" << (dp.pattern) << "] " << (dp.seconds) << "\n" ); } } @@ -246,14 +246,12 @@ bool RclMonEventQueue::wait(int seconds, bool *top) MONDEB(("RclMonEventQueue:: timeout\n")); return true; } - LOGERR(("RclMonEventQueue::wait:pthread_cond_timedwait failed" - "with err %d\n", err)); + LOGERR("RclMonEventQueue::wait:pthread_cond_timedwait failedwith err " << (err) << "\n" ); return false; } } else { if ((err = pthread_cond_wait(&m_data->m_cond, &m_data->m_mutex))) { - LOGERR(("RclMonEventQueue::wait: pthread_cond_wait failed" - "with err %d\n", err)); + LOGERR("RclMonEventQueue::wait: pthread_cond_wait failedwith err " << (err) << "\n" ); return false; } } @@ -265,7 +263,7 @@ bool RclMonEventQueue::lock() { MONDEB(("RclMonEventQueue:: lock\n")); 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; } MONDEB(("RclMonEventQueue:: lock return\n")); @@ -276,7 +274,7 @@ bool RclMonEventQueue::unlock() { MONDEB(("RclMonEventQueue:: unlock\n")); 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 true; @@ -298,15 +296,15 @@ RclConfig *RclMonEventQueue::getConfig() bool RclMonEventQueue::ok() { if (m_data == 0) { - LOGINFO(("RclMonEventQueue: not ok: bad state\n")); + LOGINFO("RclMonEventQueue: not ok: bad state\n" ); return false; } if (stopindexing) { - LOGINFO(("RclMonEventQueue: not ok: stop request\n")); + LOGINFO("RclMonEventQueue: not ok: stop request\n" ); return false; } if (!m_data->m_ok) { - LOGINFO(("RclMonEventQueue: not ok: queue terminated\n")); + LOGINFO("RclMonEventQueue: not ok: queue terminated\n" ); return false; } return true; @@ -489,15 +487,15 @@ bool startMonitor(RclConfig *conf, int opts) rclEQ.setopts(opts); 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; } if (!rclEQ.lock()) { - LOGERR(("startMonitor: cant lock queue ???\n")); + LOGERR("startMonitor: cant lock queue ???\n" ); return false; } - LOGDEB(("start_monitoring: entering main loop\n")); + LOGDEB("start_monitoring: entering main loop\n" ); bool timedout; time_t lastauxtime = time(0); @@ -515,7 +513,7 @@ bool startMonitor(RclConfig *conf, int opts) #ifndef _WIN32 bool x11dead = !(opts & RCLMON_NOX11) && !x11IsAlive(); if (x11dead) - LOGDEB(("RclMonprc: x11 is dead\n")); + LOGDEB("RclMonprc: x11 is dead\n" ); #else bool x11dead = false; #endif @@ -533,11 +531,11 @@ bool startMonitor(RclConfig *conf, int opts) switch (ev.evtype()) { case RclMonEvent::RCLEVT_MODIFY: 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); break; 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 // tell us because he knows), we should purge the db // of all the subtree, because on a directory rename, @@ -556,7 +554,7 @@ bool startMonitor(RclConfig *conf, int opts) } break; 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 @@ -603,7 +601,7 @@ bool startMonitor(RclConfig *conf, int opts) // Check for a config change 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 // change. -n was added by the reexec after the initial // 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 rclEQ.lock(); } - LOGDEB(("Rclmonprc: calling queue setTerminate\n")); + LOGDEB("Rclmonprc: calling queue setTerminate\n" ); rclEQ.setTerminate(); // 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 // (can't foresee any reason why we'd want to do this). // pthread_join(rcv_thrid, 0); - LOGDEB(("Monitor: returning\n")); + LOGDEB("Monitor: returning\n" ); return true; } #endif // RCL_MONITOR + diff --git a/src/index/rclmonrcv.cpp b/src/index/rclmonrcv.cpp index 1d616d75..a95ba589 100644 --- a/src/index/rclmonrcv.cpp +++ b/src/index/rclmonrcv.cpp @@ -24,7 +24,7 @@ #include "safesysstat.h" #include "safeunistd.h" -#include "debuglog.h" +#include "log.h" #include "rclmon.h" #include "rclinit.h" #include "fstreewalk.h" @@ -148,26 +148,17 @@ void *rclMonRcvRun(void *q) { RclMonEventQueue *queue = (RclMonEventQueue *)q; - LOGDEB(("rclMonRcvRun: running\n")); + LOGDEB("rclMonRcvRun: running\n" ); recoll_threadinit(); // Make a local copy of the configuration as it doesn't like // concurrent accesses. It's ok to copy it here as the other // thread will not work before we have sent events. 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 RclMonitor *mon; if ((mon = makeMonitor()) == 0) { - LOGERR(("rclMonRcvRun: makeMonitor failed\n")); + LOGERR("rclMonRcvRun: makeMonitor failed\n" ); queue->setTerminate(); return 0; } @@ -176,8 +167,7 @@ void *rclMonRcvRun(void *q) // Get top directories from config vector tdl = lconfig.getTopdirs(); if (tdl.empty()) { - LOGERR(("rclMonRcvRun:: top directory list (topdirs param.) not" - "found in config or Directory list parse error")); + LOGERR("rclMonRcvRun:: top directory list (topdirs param.) notfound in config or Directory list parse error" ); queue->setTerminate(); return 0; } @@ -196,14 +186,13 @@ void *rclMonRcvRun(void *q) } else { walker.setOpts(FsTreeWalker::FtwOptNone); } - LOGDEB(("rclMonRcvRun: walking %s\n", it->c_str())); + LOGDEB("rclMonRcvRun: walking " << *it << "\n" ); if (walker.walk(*it, walkcb) != FsTreeWalker::FtwOk) { - LOGERR(("rclMonRcvRun: tree walk failed\n")); + LOGERR("rclMonRcvRun: tree walk failed\n" ); goto terminate; } if (walker.getErrCnt() > 0) { - LOGINFO(("rclMonRcvRun: fs walker errors: %s\n", - walker.getReason().c_str())); + LOGINFO("rclMonRcvRun: fs walker errors: " << (walker.getReason()) << "\n" ); } } @@ -213,7 +202,7 @@ void *rclMonRcvRun(void *q) if (doweb) { string webqueuedir = lconfig.getWebQueueDir(); 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) goto terminate; } @@ -249,16 +238,13 @@ void *rclMonRcvRun(void *q) // it seems that fam/gamin is doing the job for us so // that we are generating double events here (no big // deal as prc will sort/merge). - LOGDEB(("rclMonRcvRun: walking new dir %s\n", - ev.m_path.c_str())); + LOGDEB("rclMonRcvRun: walking new dir " << (ev.m_path) << "\n" ); if (walker.walk(ev.m_path, walkcb) != FsTreeWalker::FtwOk) { - LOGERR(("rclMonRcvRun: walking new dir %s: %s\n", - ev.m_path.c_str(), walker.getReason().c_str())); + LOGERR("rclMonRcvRun: walking new dir " << (ev.m_path) << ": " << (walker.getReason()) << "\n" ); goto terminate; } if (walker.getErrCnt() > 0) { - LOGINFO(("rclMonRcvRun: fs walker errors: %s\n", - walker.getReason().c_str())); + LOGINFO("rclMonRcvRun: fs walker errors: " << (walker.getReason()) << "\n" ); } } @@ -269,7 +255,7 @@ void *rclMonRcvRun(void *q) terminate: queue->setTerminate(); - LOGINFO(("rclMonRcvRun: monrcv thread routine returning\n")); + LOGINFO("rclMonRcvRun: monrcv thread routine returning\n" ); return 0; } @@ -353,7 +339,7 @@ RclFAM::RclFAM() : m_ok(false) { if (FAMOpen2(&m_conn, "Recoll")) { - LOGERR(("RclFAM::RclFAM: FAMOpen2 failed, errno %d\n", errno)); + LOGERR("RclFAM::RclFAM: FAMOpen2 failed, errno " << (errno) << "\n" ); return; } 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 // ensure that we exit after gamin gets stuck. if (setjmp(jbuf)) { - LOGERR(("RclFAM::addWatch: timeout talking to FAM\n")); + LOGERR("RclFAM::addWatch: timeout talking to FAM\n" ); return false; } signal(SIGALRM, onalrm); @@ -392,12 +378,12 @@ bool RclFAM::addWatch(const string& path, bool isdir) FAMRequest req; if (isdir) { if (FAMMonitorDirectory(&m_conn, path.c_str(), &req, 0) != 0) { - LOGERR(("RclFAM::addWatch: FAMMonitorDirectory failed\n")); + LOGERR("RclFAM::addWatch: FAMMonitorDirectory failed\n" ); goto out; } } else { if (FAMMonitorFile(&m_conn, path.c_str(), &req, 0) != 0) { - LOGERR(("RclFAM::addWatch: FAMMonitorFile failed\n")); + LOGERR("RclFAM::addWatch: FAMMonitorFile failed\n" ); goto out; } } @@ -435,7 +421,7 @@ bool RclFAM::getEvent(RclMonEvent& ev, int msecs) } int ret; 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(); return false; } else if (ret == 0) { @@ -462,7 +448,7 @@ bool RclFAM::getEvent(RclMonEvent& ev, int msecs) MONDEB(("RclFAM::getEvent: call FAMNextEvent\n")); FAMEvent fe; if (FAMNextEvent(&m_conn, &fe) < 0) { - LOGERR(("RclFAM::getEvent: FAMNextEvent failed, errno %d\n", errno)); + LOGERR("RclFAM::getEvent: FAMNextEvent failed, errno " << (errno) << "\n" ); close(); return false; } @@ -511,7 +497,7 @@ bool RclFAM::getEvent(RclMonEvent& ev, int msecs) // Have to return something, this is different from an empty queue, // esp if we are trying to empty it... 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; break; } @@ -532,7 +518,7 @@ public: : m_ok(false), m_fd(-1), m_evp(0), m_ep(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; } m_ok = true; @@ -616,11 +602,9 @@ bool RclIntf::addWatch(const string& path, bool) int wd; if ((wd = inotify_add_watch(m_fd, path.c_str(), mask)) < 0) { saved_errno = errno; - LOGERR(("RclIntf::addWatch: inotify_add_watch failed. errno %d\n", - saved_errno)); + LOGERR("RclIntf::addWatch: inotify_add_watch failed. errno " << (saved_errno) << "\n" ); if (errno == ENOSPC) { - LOGERR(("RclIntf::addWatch: ENOSPC error may mean that you need" - "increase the inotify kernel constants. See inotify(7)\n")); + LOGERR("RclIntf::addWatch: ENOSPC error may mean that you needincrease the inotify kernel constants. See inotify(7)\n" ); } return false; } @@ -649,7 +633,7 @@ bool RclIntf::getEvent(RclMonEvent& ev, int msecs) int ret; MONDEB(("RclIntf::getEvent: select\n")); 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(); return false; } else if (ret == 0) { @@ -663,8 +647,7 @@ bool RclIntf::getEvent(RclMonEvent& ev, int msecs) return false; int rret; if ((rret=read(m_fd, m_evbuf, sizeof(m_evbuf))) <= 0) { - LOGERR(("RclIntf::getEvent: read failed, %d->%d errno %d\n", - sizeof(m_evbuf), rret, errno)); + LOGERR("RclIntf::getEvent: read failed, " << (sizeof(m_evbuf)) << "->" << (rret) << " errno " << (errno) << "\n" ); close(); return false; } @@ -681,7 +664,7 @@ bool RclIntf::getEvent(RclMonEvent& ev, int msecs) map::const_iterator it; 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; } ev.m_path = it->second; @@ -721,13 +704,12 @@ bool RclIntf::getEvent(RclMonEvent& ev, int msecs) } } else if (evp->mask & (IN_IGNORED)) { if (!m_idtopath.erase(evp->wd)) { - LOGDEB0(("Got IGNORE event for unknown watch\n")); + LOGDEB0("Got IGNORE event for unknown watch\n" ); } else { eraseWatchSubTree(m_idtopath, ev.m_path); } } else { - LOGDEB(("RclIntf::getEvent: unhandled event %s 0x%x %s\n", - event_name(evp->mask), evp->mask, ev.m_path.c_str())); + LOGDEB("RclIntf::getEvent: unhandled event " << (event_name(evp->mask)) << " 0x" << (evp->mask) << " " << (ev.m_path) << "\n" ); return true; } return true; @@ -748,8 +730,8 @@ static RclMonitor *makeMonitor() return new RclFAM; #endif #endif - LOGINFO(("RclMonitor: neither Inotify nor Fam was compiled as " - "file system change notification interface\n")); + LOGINFO("RclMonitor: neither Inotify nor Fam was compiled as file system change notification interface\n" ); return 0; } #endif // RCL_MONITOR + diff --git a/src/index/recollindex.cpp b/src/index/recollindex.cpp index 7e2193e4..a29e02bc 100644 --- a/src/index/recollindex.cpp +++ b/src/index/recollindex.cpp @@ -36,7 +36,7 @@ using namespace std; -#include "debuglog.h" +#include "log.h" #include "rclinit.h" #include "indexer.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 // logs in again, the new recollindex will fail). 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; return false; } @@ -166,7 +166,7 @@ static MyUpdater *updater; static void sigcleanup(int sig) { 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(); stopindexing = 1; } @@ -301,7 +301,7 @@ static bool checktopdirs(RclConfig *config, vector& nonexist) vector tdl; if (!config->getConfParam("topdirs", &tdl)) { 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; } @@ -310,12 +310,10 @@ static bool checktopdirs(RclConfig *config, vector& nonexist) if (!it->size() || !path_isabsolute(*it)) { if ((*it)[0] == '~') { cerr << "Tilde expansion failed: " << *it << endl; - LOGERR(("recollindex: tilde expansion failed: %s\n", - it->c_str())); + LOGERR("recollindex: tilde expansion failed: " << *it << "\n" ); } else { cerr << "Not an absolute path: " << *it << endl; - LOGERR(("recollindex: not an absolute path: %s\n", - it->c_str())); + LOGERR("recollindex: not an absolute path: " << *it << "\n" ); } return false; } @@ -516,18 +514,14 @@ int main(int argc, char **argv) string rundir; config->getConfParam("idxrundir", rundir); if (!rundir.compare("tmp")) { - LOGINFO(("recollindex: changing current directory to [%s]\n", - tmplocation().c_str())); + LOGINFO("recollindex: changing current directory to [" << (tmplocation()) << "]\n" ); if (chdir(tmplocation().c_str()) < 0) { - LOGERR(("chdir(%s) failed, errno %d\n", - tmplocation().c_str(), errno)); + LOGERR("chdir(" << (tmplocation()) << ") failed, errno " << (errno) << "\n" ); } } else if (!rundir.empty()) { - LOGINFO(("recollindex: changing current directory to [%s]\n", - rundir.c_str())); + LOGINFO("recollindex: changing current directory to [" << (rundir) << "]\n" ); if (chdir(rundir.c_str()) < 0) { - LOGERR(("chdir(%s) failed, errno %d\n", - rundir.c_str(), errno)); + LOGERR("chdir(" << (rundir) << ") failed, errno " << (errno) << "\n" ); } } @@ -550,10 +544,10 @@ int main(int argc, char **argv) // 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. - LOGINFO(("recollindex: starting up\n")); + LOGINFO("recollindex: starting up\n" ); #ifndef _WIN32 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 rclIxIonice(config); @@ -625,11 +619,11 @@ int main(int argc, char **argv) Usage(); lockorexit(&pidfile); if (!(op_flags&OPT_D)) { - LOGDEB(("recollindex: daemonizing\n")); + LOGDEB("recollindex: daemonizing\n" ); #ifndef _WIN32 if (daemon(0,0) != 0) { fprintf(stderr, "daemon() failed, errno %d\n", errno); - LOGERR(("daemon() failed, errno %d\n", errno)); + LOGERR("daemon() failed, errno " << (errno) << "\n" ); exit(1); } #endif @@ -640,30 +634,29 @@ int main(int argc, char **argv) // Not too sure if I have to redo the nice thing after daemon(), // can't hurt anyway (easier than testing on all platforms...) 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 rclIxIonice(config); #endif if (sleepsecs > 0) { - LOGDEB(("recollindex: sleeping %d\n", sleepsecs)); + LOGDEB("recollindex: sleeping " << (sleepsecs) << "\n" ); for (int i = 0; i < sleepsecs; i++) { sleep(1); // Check that x11 did not go away while we were sleeping. 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); } } } if (!(op_flags & OPT_n)) { 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) || stopindexing) { - LOGERR(("recollindex, initial indexing pass failed, " - "not going into monitor mode\n")); + LOGERR("recollindex, initial indexing pass failed, not going into monitor mode\n" ); exit(1); } else { // Record success of indexing pass with failed files retries. @@ -674,7 +667,7 @@ int main(int argc, char **argv) deleteZ(confindexer); #ifndef _WIN32 o_reexec->insertArgs(vector(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 // back, but the monitor will explicitely strip it before // starting a config change exec to ensure that we do a @@ -724,3 +717,4 @@ int main(int argc, char **argv) return !status; } } + diff --git a/src/index/subtreelist.cpp b/src/index/subtreelist.cpp index 60be975e..e668ce02 100644 --- a/src/index/subtreelist.cpp +++ b/src/index/subtreelist.cpp @@ -25,16 +25,15 @@ #include "searchdata.h" #include "rclquery.h" #include "subtreelist.h" -#include "debuglog.h" +#include "log.h" bool subtreelist(RclConfig *config, const string& top, vector& paths) { - LOGDEB(("subtreelist: top: [%s]\n", top.c_str())); + LOGDEB("subtreelist: top: [" << (top) << "]\n" ); Rcl::Db rcldb(config); if (!rcldb.open(Rcl::Db::DbRO)) { - LOGERR(("subtreelist: can't open database in [%s]: %s\n", - config->getDbDir().c_str(), rcldb.getReason().c_str())); + LOGERR("subtreelist: can't open database in [" << (config->getDbDir()) << "]: " << (rcldb.getReason()) << "\n" ); return false; } @@ -129,3 +128,4 @@ int main(int argc, char **argv) exit(0); } #endif + diff --git a/src/internfile/extrameta.cpp b/src/internfile/extrameta.cpp index fede2e54..836b3755 100644 --- a/src/internfile/extrameta.cpp +++ b/src/internfile/extrameta.cpp @@ -21,7 +21,7 @@ #include "rclconfig.h" #include "pxattr.h" -#include "debuglog.h" +#include "log.h" #include "cstr.h" #include "rcldoc.h" #include "execmd.h" @@ -33,8 +33,7 @@ static void docfieldfrommeta(RclConfig* cfg, const string& name, const string &value, Rcl::Doc& doc) { string fieldname = cfg->fieldCanon(name); - LOGDEB0(("Internfile:: setting [%s] from cmd/xattr value [%s]\n", - fieldname.c_str(), value.c_str())); + LOGDEB0("Internfile:: setting [" << (fieldname) << "] from cmd/xattr value [" << (value) << "]\n" ); if (fieldname == cstr_dj_keymd) { doc.dmtime = value; } else { @@ -45,17 +44,15 @@ static void docfieldfrommeta(RclConfig* cfg, const string& name, void reapXAttrs(const RclConfig* cfg, const string& path, map& xfields) { - LOGDEB2(("reapXAttrs: [%s]\n", path.c_str())); + LOGDEB2("reapXAttrs: [" << (path) << "]\n" ); #ifndef _WIN32 // Retrieve xattrs names from files and mapping table from config vector xnames; if (!pxattr::list(path, &xnames)) { if (errno == ENOTSUP) { - LOGDEB(("FileInterner::reapXattrs: pxattr::list: errno %d\n", - errno)); + LOGDEB("FileInterner::reapXattrs: pxattr::list: errno " << (errno) << "\n" ); } else { - LOGERR(("FileInterner::reapXattrs: pxattr::list: errno %d\n", - errno)); + LOGERR("FileInterner::reapXattrs: pxattr::list: errno " << (errno) << "\n" ); } return; } @@ -77,13 +74,12 @@ void reapXAttrs(const RclConfig* cfg, const string& path, } string value; if (!pxattr::get(path, *it, &value, pxattr::PXATTR_NOFOLLOW)) { - LOGERR(("FileInterner::reapXattrs: pxattr::get failed" - "for %s, errno %d\n", (*it).c_str(), errno)); + LOGERR("FileInterner::reapXattrs: pxattr::get failedfor " << ((*it)) << ", errno " << (errno) << "\n" ); continue; } // Encode should we ? xfields[key] = value; - LOGDEB2(("reapXAttrs: [%s] -> [%s]\n", key.c_str(), value.c_str())); + LOGDEB2("reapXAttrs: [" << (key) << "] -> [" << (value) << "]\n" ); } #endif } @@ -150,3 +146,4 @@ void docFieldsFromMetaCmds(RclConfig *cfg, const map& cfields, } } } + diff --git a/src/internfile/indextext.h b/src/internfile/indextext.h index 7e700dcb..3fc9fe88 100644 --- a/src/internfile/indextext.h +++ b/src/internfile/indextext.h @@ -18,9 +18,6 @@ #define _INDEXTEXT_H_INCLUDED_ /* Note: this only exists to help with using myhtmlparse.cc */ -// Minimize changes to myhtmlparse.cpp -#include "debuglog.h" - #include // lets hope that the charset includes ascii values... diff --git a/src/internfile/internfile.cpp b/src/internfile/internfile.cpp index 89e2273f..8037adf5 100644 --- a/src/internfile/internfile.cpp +++ b/src/internfile/internfile.cpp @@ -35,7 +35,7 @@ using namespace std; #include "internfile.h" #include "rcldoc.h" #include "mimetype.h" -#include "debuglog.h" +#include "log.h" #include "mimehandler.h" #include "execmd.h" #include "pathut.h" @@ -76,8 +76,7 @@ static string colon_restore(const string& in) // (ie message having a given attachment) bool FileInterner::getEnclosingUDI(const Rcl::Doc &doc, string& udi) { - LOGDEB(("FileInterner::getEnclosingUDI(): url [%s] ipath [%s]\n", - doc.url.c_str(), doc.ipath.c_str())); + LOGDEB("FileInterner::getEnclosingUDI(): url [" << (doc.url) << "] ipath [" << (doc.ipath) << "]\n" ); string eipath = doc.ipath; string::size_type colon; if (eipath.empty()) @@ -119,9 +118,9 @@ FileInterner::FileInterner(const string &fn, const struct stat *stp, RclConfig *cnf, int flags, const string *imime) : 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()) { - LOGERR(("FileInterner::FileInterner: empty file name!\n")); + LOGERR("FileInterner::FileInterner: empty file name!\n" ); return; } initcommon(cnf, flags); @@ -132,7 +131,7 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf, int flags, const string *imime) { if (f.empty()) { - LOGERR(("FileInterner::init: empty file name!\n")); + LOGERR("FileInterner::init: empty file name!\n" ); return; } 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). if (flags & FIF_doUseInputMimetype) { if (!imime) { - LOGERR(("FileInterner:: told to use null imime\n")); + LOGERR("FileInterner:: told to use null imime\n" ); return; } l_mime = *imime; } else { - LOGDEB(("FileInterner::init fn [%s] mime [%s] preview %d\n", - f.c_str(), imime?imime->c_str() : "(null)", m_forPreview)); + LOGDEB("FileInterner::init fn [" << f << "] mime [" << + (imime?imime->c_str() : "(null)") << "] preview " << m_forPreview + << "\n" ); // Run mime type identification in any case (see comment above). 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)) { return; } - LOGDEB1(("FileInterner:: after ucomp: tfile %s\n", - m_tfile.c_str())); + LOGDEB1("FileInterner:: after ucomp: tfile " << (m_tfile) << "\n" ); m_fn = m_tfile; // Stat the uncompressed file, mainly to get the size struct stat ucstat; if (path_fileprops(m_fn, &ucstat) != 0) { - LOGERR(("FileInterner: can't stat the uncompressed file" - "[%s] errno %d\n", m_fn.c_str(), errno)); + LOGERR("FileInterner: can't stat the uncompressed file[" << (m_fn) << "] errno " << (errno) << "\n" ); return; } else { 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) l_mime = *imime; } else { - LOGINFO(("FileInterner:: %s over size limit %d kbs\n", - m_fn.c_str(), maxkbs)); + LOGINFO("FileInterner:: " << (m_fn) << " over size limit " << (maxkbs) << " kbs\n" ); } } } @@ -215,7 +212,7 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf, if (l_mime.empty()) { // No mime type. We let it through as config may warrant that // 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) @@ -224,8 +221,7 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf, if (!df || df->is_unknown()) { // No real handler for this type, for now :( - LOGDEB(("FileInterner:: unprocessed mime: [%s] [%s]\n", - l_mime.c_str(), f.c_str())); + LOGDEB("FileInterner:: unprocessed mime: [" << (l_mime) << "] [" << (f) << "]\n" ); if (!df) return; } @@ -245,12 +241,12 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf, df->set_docsize(docsize); if (!df->set_document_file(l_mime, m_fn)) { delete df; - LOGERR(("FileInterner:: error converting %s\n", m_fn.c_str())); + LOGERR("FileInterner:: error converting " << (m_fn) << "\n" ); return; } 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; } @@ -259,7 +255,7 @@ FileInterner::FileInterner(const string &data, RclConfig *cnf, int flags, const string& imime) : 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); init(data, cnf, flags, imime); } @@ -268,7 +264,7 @@ void FileInterner::init(const string &data, RclConfig *cnf, int flags, const string& imime) { if (imime.empty()) { - LOGERR(("FileInterner: inmemory constructor needs input mime type\n")); + LOGERR("FileInterner: inmemory constructor needs input mime type\n" ); return; } m_mimetype = imime; @@ -279,7 +275,7 @@ void FileInterner::init(const string &data, RclConfig *cnf, if (!df) { // No handler for this type, for now :( if indexallfilenames // 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; } df->set_property(Dijon::Filter::OPERATING_MODE, @@ -300,8 +296,7 @@ void FileInterner::init(const string &data, RclConfig *cnf, } } if (!result) { - LOGINFO(("FileInterner:: set_doc failed inside for mtype %s\n", - m_mimetype.c_str())); + LOGINFO("FileInterner:: set_doc failed inside for mtype " << (m_mimetype) << "\n" ); delete df; return; } @@ -325,17 +320,17 @@ void FileInterner::initcommon(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)) { - LOGDEB0(("FileInterner::FileInterner(idoc)\n")); + LOGDEB0("FileInterner::FileInterner(idoc)\n" ); initcommon(cnf, flags); DocFetcher *fetcher = docFetcherMake(cnf, idoc); if (fetcher == 0) { - LOGERR(("FileInterner:: no backend\n")); + LOGERR("FileInterner:: no backend\n" ); return; } DocFetcher::RawDoc rawdoc; if (!fetcher->fetch(cnf, idoc, rawdoc)) { - LOGERR(("FileInterner:: fetcher failed\n")); + LOGERR("FileInterner:: fetcher failed\n" ); return; } switch (rawdoc.kind) { @@ -350,7 +345,7 @@ FileInterner::FileInterner(const Rcl::Doc& idoc, RclConfig *cnf, int flags) m_direct = true; break; default: - LOGERR(("FileInterner::FileInterner(idoc): bad rawdoc kind ??\n")); + LOGERR("FileInterner::FileInterner(idoc): bad rawdoc kind ??\n" ); } return; } @@ -359,7 +354,7 @@ bool FileInterner::makesig(RclConfig *cnf, const Rcl::Doc& idoc, string& sig) { DocFetcher *fetcher = docFetcherMake(cnf, idoc); if (fetcher == 0) { - LOGERR(("FileInterner::makesig no backend for doc\n")); + LOGERR("FileInterner::makesig no backend for doc\n" ); return false; } @@ -386,14 +381,12 @@ TempFile FileInterner::dataToTempFile(const string& dt, const string& mt) // Create temp file with appropriate suffix for mime type TempFile temp(new TempFileInternal(m_cfg->getSuffixFromMimeType(mt))); if (!temp->ok()) { - LOGERR(("FileInterner::dataToTempFile: cant create tempfile: %s\n", - temp->getreason().c_str())); + LOGERR("FileInterner::dataToTempFile: cant create tempfile: " << (temp->getreason()) << "\n" ); return TempFile(); } string reason; if (!stringtofile(dt, temp->filename(), reason)) { - LOGERR(("FileInterner::dataToTempFile: stringtofile: %s\n", - reason.c_str())); + LOGERR("FileInterner::dataToTempFile: stringtofile: " << (reason) << "\n" ); return TempFile(); } return temp; @@ -404,7 +397,7 @@ TempFile FileInterner::dataToTempFile(const string& dt, const string& mt) // RECFILTERROR HELPERNOTFOUND program1 [program2 ...] 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) { vector verr; stringToStrings(msg, verr); @@ -496,10 +489,10 @@ static inline bool getKeyValue(const map& docdata, it = docdata.find(key); if (it != docdata.end()) { value = it->second; - LOGDEB2(("getKeyValue: [%s]->[%s]\n", key.c_str(), value.c_str())); + LOGDEB2("getKeyValue: [" << (key) << "]->[" << (value) << "]\n" ); return true; } - LOGDEB2(("getKeyValue: no value for [%s]\n", key.c_str())); + LOGDEB2("getKeyValue: no value for [" << (key) << "]\n" ); return false; } @@ -508,7 +501,7 @@ bool FileInterner::dijontorcl(Rcl::Doc& doc) RecollFilter *df = m_handlers.back(); if (df == 0) { //?? - LOGERR(("FileInterner::dijontorcl: null top handler ??\n")); + LOGERR("FileInterner::dijontorcl: null top handler ??\n" ); return false; } const map& docdata = df->get_meta_data(); @@ -575,7 +568,7 @@ bool FileInterner::dijontorcl(Rcl::Doc& doc) // actually complicated. void FileInterner::collectIpathAndMT(Rcl::Doc& doc) const { - LOGDEB2(("FileInterner::collectIpathAndMT\n")); + LOGDEB2("FileInterner::collectIpathAndMT\n" ); bool hasipath = false; if (!m_noxattrs) { @@ -624,7 +617,7 @@ void FileInterner::collectIpathAndMT(Rcl::Doc& doc) const // Trim empty tail elements in ipath. 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); if (sit == string::npos) doc.ipath.erase(); @@ -660,8 +653,7 @@ int FileInterner::addHandler() getKeyValue(docdata, cstr_dj_keycharset, charset); getKeyValue(docdata, cstr_dj_keymt, mimetype); - LOGDEB(("FileInterner::addHandler: next_doc is %s target [%s]\n", - mimetype.c_str(), m_targetMType.c_str())); + LOGDEB("FileInterner::addHandler: next_doc is " << (mimetype) << " target [" << (m_targetMType) << "]\n" ); // 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 @@ -669,7 +661,7 @@ int FileInterner::addHandler() if (!stringicmp(mimetype, m_targetMType) || !stringicmp(mimetype, cstr_textplain)) { m_reachedMType = mimetype; - LOGDEB1(("FileInterner::addHandler: target reached\n")); + LOGDEB1("FileInterner::addHandler: target reached\n" ); return ADD_BREAK; } @@ -677,7 +669,7 @@ int FileInterner::addHandler() if (m_handlers.size() >= MAXHANDLERS) { // Stack too big. Skip this and go on to check if there is // something else in the current back() - LOGERR(("FileInterner::addHandler: stack too high\n")); + LOGERR("FileInterner::addHandler: stack too high\n" ); return ADD_CONTINUE; } @@ -685,8 +677,7 @@ int FileInterner::addHandler() if (!newflt) { // If we can't find a handler, this doc can't be handled // but there can be other ones so we go on - LOGINFO(("FileInterner::addHandler: no filter for [%s]\n", - mimetype.c_str())); + LOGINFO("FileInterner::addHandler: no filter for [" << (mimetype) << "]\n" ); return ADD_CONTINUE; } newflt->set_property(Dijon::Filter::OPERATING_MODE, @@ -725,8 +716,7 @@ int FileInterner::addHandler() } } if (!setres) { - LOGINFO(("FileInterner::addHandler: set_doc failed inside %s " - " for mtype %s\n", m_fn.c_str(), mimetype.c_str())); + LOGINFO("FileInterner::addHandler: set_doc failed inside " << (m_fn) << " for mtype " << (mimetype) << "\n" ); delete newflt; if (m_forPreview) return ADD_ERROR; @@ -734,7 +724,7 @@ int FileInterner::addHandler() } // add handler and go on, maybe this one will give us text... m_handlers.push_back(newflt); - LOGDEB1(("FileInterner::addHandler: added\n")); + LOGDEB1("FileInterner::addHandler: added\n" ); return ADD_OK; } @@ -744,21 +734,19 @@ void FileInterner::processNextDocError(Rcl::Doc &doc) collectIpathAndMT(doc); m_reason = m_handlers.back()->get_error(); checkExternalMissing(m_reason, doc.mimetype); - LOGERR(("FileInterner::internfile: next_document error " - "[%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())); + LOGERR("FileInterner::internfile: next_document error [" << (m_fn) << "" << (doc.ipath.empty() ? "" : "|") << "" << (doc.ipath) << "] " << (doc.mimetype) << " " << (m_reason) << "\n" ); } 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 m_imgtmp.reset(); if (m_handlers.size() < 1) { // Just means the constructor failed - LOGDEB(("FileInterner::internfile: no handler: constructor failed\n")); + LOGDEB("FileInterner::internfile: no handler: constructor failed\n" ); return FIError; } @@ -777,7 +765,7 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath } vipath.insert(vipath.begin(), lipath.begin(), lipath.end()); 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; } } @@ -793,7 +781,7 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath while (!m_handlers.empty()) { CancelCheck::instance().checkCancel(); if (loop++ > 1000) { - LOGERR(("FileInterner:: looping!\n")); + LOGERR("FileInterner:: looping!\n" ); return FIError; } // 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) { m_reason += "Requested document does not exist. "; 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; } popHandler(); @@ -820,7 +808,7 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath if (m_forPreview) { m_reason += "Requested document does not exist. "; 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; } popHandler(); @@ -831,20 +819,20 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath // handler to stack. switch (addHandler()) { case ADD_OK: // Just go through: handler has been stacked, use it - LOGDEB2(("addHandler returned OK\n")); + LOGDEB2("addHandler returned OK\n" ); break; case ADD_CONTINUE: // forget this doc and retrieve next from current handler // (ipath stays same) - LOGDEB2(("addHandler returned CONTINUE\n")); + LOGDEB2("addHandler returned CONTINUE\n" ); continue; case ADD_BREAK: // Stop looping: doc type ok, need complete its processing // and return it - LOGDEB2(("addHandler returned BREAK\n")); + LOGDEB2("addHandler returned BREAK\n" ); goto breakloop; // when you have to you have to case ADD_ERROR: - LOGDEB2(("addHandler returned ERROR\n")); + LOGDEB2("addHandler returned ERROR\n" ); return FIError; } @@ -858,14 +846,14 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath if (!ipath.empty()) { if (m_handlers.size() <= vipath.size() && !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; } } } breakloop: if (m_handlers.empty()) { - LOGDEB(("FileInterner::internfile: conversion ended with no doc\n")); + LOGDEB("FileInterner::internfile: conversion ended with no doc\n" ); return FIError; } @@ -908,7 +896,7 @@ bool FileInterner::tempFileForMT(TempFile& otemp, RclConfig* cnf, TempFile temp(new TempFileInternal( cnf->getSuffixFromMimeType(mimetype))); if (!temp->ok()) { - LOGERR(("FileInterner::interntofile: can't create temp file\n")); + LOGERR("FileInterner::interntofile: can't create temp file\n" ); return false; } otemp = temp; @@ -934,7 +922,7 @@ bool FileInterner::tempFileForMT(TempFile& otemp, RclConfig* cnf, bool FileInterner::idocToFile(TempFile& otemp, const string& tofile, RclConfig *cnf, const Rcl::Doc& idoc) { - LOGDEB(("FileInterner::idocToFile\n")); + LOGDEB("FileInterner::idocToFile\n" ); if (idoc.ipath.empty()) { return topdocToFile(otemp, tofile, cnf, idoc); @@ -953,12 +941,12 @@ bool FileInterner::topdocToFile(TempFile& otemp, const string& tofile, { DocFetcher *fetcher = docFetcherMake(cnf, idoc); if (fetcher == 0) { - LOGERR(("FileInterner::idocToFile no backend\n")); + LOGERR("FileInterner::idocToFile no backend\n" ); return false; } DocFetcher::RawDoc rawdoc; if (!fetcher->fetch(cnf, idoc, rawdoc)) { - LOGERR(("FileInterner::idocToFile fetcher failed\n")); + LOGERR("FileInterner::idocToFile fetcher failed\n" ); return false; } const char *filename = ""; @@ -975,20 +963,18 @@ bool FileInterner::topdocToFile(TempFile& otemp, const string& tofile, switch (rawdoc.kind) { case DocFetcher::RawDoc::RDK_FILENAME: if (!copyfile(rawdoc.data.c_str(), filename, reason)) { - LOGERR(("FileInterner::idocToFile: copyfile: %s\n", - reason.c_str())); + LOGERR("FileInterner::idocToFile: copyfile: " << (reason) << "\n" ); return false; } break; case DocFetcher::RawDoc::RDK_DATA: if (!stringtofile(rawdoc.data, filename, reason)) { - LOGERR(("FileInterner::idocToFile: stringtofile: %s\n", - reason.c_str())); + LOGERR("FileInterner::idocToFile: stringtofile: " << (reason) << "\n" ); return false; } break; default: - LOGERR(("FileInterner::FileInterner(idoc): bad rawdoc kind ??\n")); + LOGERR("FileInterner::FileInterner(idoc): bad rawdoc kind ??\n" ); } if (tofile.empty()) @@ -1000,13 +986,13 @@ bool FileInterner::interntofile(TempFile& otemp, const string& tofile, const string& ipath, const string& mimetype) { if (!ok()) { - LOGERR(("FileInterner::interntofile: constructor failed\n")); + LOGERR("FileInterner::interntofile: constructor failed\n" ); return false; } Rcl::Doc doc; Status ret = internfile(doc, ipath); if (ret == FileInterner::FIError) { - LOGERR(("FileInterner::interntofile: internfile() failed\n")); + LOGERR("FileInterner::interntofile: internfile() failed\n" ); return false; } @@ -1033,8 +1019,7 @@ bool FileInterner::interntofile(TempFile& otemp, const string& tofile, } string reason; if (!stringtofile(doc.text, filename, reason)) { - LOGERR(("FileInterner::interntofile: stringtofile : %s\n", - reason.c_str())); + LOGERR("FileInterner::interntofile: stringtofile : " << (reason) << "\n" ); return false; } @@ -1045,16 +1030,15 @@ bool FileInterner::interntofile(TempFile& otemp, const string& tofile, bool FileInterner::isCompressed(const string& fn, RclConfig *cnf) { - LOGDEB(("FileInterner::isCompressed: [%s]\n", fn.c_str())); + LOGDEB("FileInterner::isCompressed: [" << (fn) << "]\n" ); struct stat st; 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; } string l_mime = mimetype(fn, &st, cnf, true); if (l_mime.empty()) { - LOGERR(("FileInterner::isUncompressed: can't get mime for [%s]\n", - fn.c_str())); + LOGERR("FileInterner::isUncompressed: can't get mime for [" << (fn) << "]\n" ); return false; } @@ -1069,17 +1053,15 @@ bool FileInterner::isCompressed(const string& fn, RclConfig *cnf) bool FileInterner::maybeUncompressToTemp(TempFile& temp, const string& fn, RclConfig *cnf, const Rcl::Doc& doc) { - LOGDEB(("FileInterner::maybeUncompressToTemp: [%s]\n", fn.c_str())); + LOGDEB("FileInterner::maybeUncompressToTemp: [" << (fn) << "]\n" ); struct stat st; if (path_fileprops(fn.c_str(), &st) < 0) { - LOGERR(("FileInterner::maybeUncompressToTemp: can't stat [%s]\n", - fn.c_str())); + LOGERR("FileInterner::maybeUncompressToTemp: can't stat [" << (fn) << "]\n" ); return false; } string l_mime = mimetype(fn, &st, cnf, true); if (l_mime.empty()) { - LOGERR(("FileInterner::maybeUncompress.: can't id. mime for [%s]\n", - fn.c_str())); + LOGERR("FileInterner::maybeUncompress.: can't id. mime for [" << (fn) << "]\n" ); return false; } @@ -1091,14 +1073,13 @@ bool FileInterner::maybeUncompressToTemp(TempFile& temp, const string& fn, int maxkbs = -1; if (cnf->getConfParam("compressedfilemaxkbs", &maxkbs) && maxkbs >= 0 && int(st.st_size / 1024) > maxkbs) { - LOGINFO(("FileInterner:: %s over size limit %d kbs\n", - fn.c_str(), maxkbs)); + LOGINFO("FileInterner:: " << (fn) << " over size limit " << (maxkbs) << " kbs\n" ); return false; } temp = TempFile(new TempFileInternal(cnf->getSuffixFromMimeType(doc.mimetype))); if (!temp->ok()) { - LOGERR(("FileInterner: cant create temporary file")); + LOGERR("FileInterner: cant create temporary file" ); return false; } @@ -1113,9 +1094,7 @@ bool FileInterner::maybeUncompressToTemp(TempFile& temp, const string& fn, // uncompressed file, hopefully staying on the same dev. string reason; if (!renameormove(uncomped.c_str(), temp->filename(), reason)) { - LOGERR(("FileInterner::maybeUncompress: move [%s] -> [%s] " - "failed: %s\n", - uncomped.c_str(), temp->filename(), reason.c_str())); + LOGERR("FileInterner::maybeUncompress: move [" << (uncomped) << "] -> [" << (temp->filename()) << "] failed: " << (reason) << "\n" ); return false; } return true; @@ -1131,7 +1110,8 @@ bool FileInterner::maybeUncompressToTemp(TempFile& temp, const string& fn, using namespace std; -#include "debuglog.h" +#include "log.h" + #include "rclinit.h" #include "internfile.h" #include "rclconfig.h" @@ -1232,3 +1212,4 @@ int main(int argc, char **argv) } #endif // TEST_INTERNFILE + diff --git a/src/internfile/mh_exec.cpp b/src/internfile/mh_exec.cpp index 17cc973b..30708e11 100644 --- a/src/internfile/mh_exec.cpp +++ b/src/internfile/mh_exec.cpp @@ -26,7 +26,7 @@ #include "execmd.h" #include "mh_exec.h" #include "mh_html.h" -#include "debuglog.h" +#include "log.h" #include "cancelcheck.h" #include "smallut.h" #include "md5ut.h" @@ -55,11 +55,10 @@ void MEAdv::reset() void MEAdv::newData(int n) { - LOGDEB2(("MHExec:newData(%d)\n", n)); + LOGDEB2("MHExec:newData(" << (n) << ")\n" ); if (m_filtermaxseconds > 0 && time(0L) - m_start > m_filtermaxseconds) { - LOGERR(("MimeHandlerExec: filter timeout (%d S)\n", - m_filtermaxseconds)); + LOGERR("MimeHandlerExec: filter timeout (" << (m_filtermaxseconds) << " S)\n" ); throw HandlerTimeout(); } // 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) { - LOGDEB(("MimeHandlerExec:skip_to_document: [%s]\n", ipath.c_str())); + LOGDEB("MimeHandlerExec:skip_to_document: [" << (ipath) << "]\n" ); m_ipath = ipath; return true; } @@ -83,13 +82,13 @@ bool MimeHandlerExec::next_document() return false; m_havedoc = false; if (missingHelper) { - LOGDEB(("MimeHandlerExec::next_document(): helper known missing\n")); + LOGDEB("MimeHandlerExec::next_document(): helper known missing\n" ); return false; } if (params.empty()) { // Hu ho - LOGERR(("MimeHandlerExec::mkDoc: empty params\n")); + LOGERR("MimeHandlerExec::mkDoc: empty params\n" ); m_reason = "RECFILTERROR BADCONFIG"; return false; } @@ -118,16 +117,15 @@ bool MimeHandlerExec::next_document() try { status = mexec.doexec(cmd, myparams, 0, &output); } catch (HandlerTimeout) { - LOGERR(("MimeHandlerExec: handler timeout\n")); + LOGERR("MimeHandlerExec: handler timeout\n" ); status = 0x110f; } catch (CancelExcept) { - LOGERR(("MimeHandlerExec: cancelled\n")); + LOGERR("MimeHandlerExec: cancelled\n" ); status = 0x110f; } if (status) { - LOGERR(("MimeHandlerExec: command status 0x%x for %s\n", - status, cmd.c_str())); + LOGERR("MimeHandlerExec: command status 0x" << (status) << " for " << (cmd) << "\n" ); if (WIFEXITED(status) && WEXITSTATUS(status) == 127) { // That's how execmd signals a failed exec (most probably // 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)) { m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5); } else { - LOGERR(("MimeHandlerExec: cant compute md5 for [%s]: %s\n", - m_fn.c_str(), reason.c_str())); + LOGERR("MimeHandlerExec: cant compute md5 for [" << (m_fn) << "]: " << (reason) << "\n" ); } } handle_cs(m_metaData[cstr_dj_keymt]); } + diff --git a/src/internfile/mh_execm.cpp b/src/internfile/mh_execm.cpp index 2e294d7e..c3db6a18 100644 --- a/src/internfile/mh_execm.cpp +++ b/src/internfile/mh_execm.cpp @@ -23,7 +23,7 @@ using namespace std; #include "cstr.h" #include "mh_execm.h" #include "mh_html.h" -#include "debuglog.h" +#include "log.h" #include "cancelcheck.h" #include "smallut.h" #include "md5ut.h" @@ -36,10 +36,10 @@ using namespace std; bool MimeHandlerExecMultiple::startCmd() { - LOGDEB(("MimeHandlerExecMultiple::startCmd\n")); + LOGDEB("MimeHandlerExecMultiple::startCmd\n" ); if (params.empty()) { // Hu ho - LOGERR(("MHExecMultiple::startCmd: empty params\n")); + LOGERR("MHExecMultiple::startCmd: empty params\n" ); m_reason = "RECFILTERROR BADCONFIG"; return false; } @@ -86,15 +86,15 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data) // Read name and length if (m_cmd.getline(ibuf) <= 0) { - LOGERR(("MHExecMultiple: getline error\n")); + LOGERR("MHExecMultiple: getline error\n" ); return false; } - LOGDEB1(("MHEM:rde: line [%s]\n", ibuf.c_str())); + LOGDEB1("MHEM:rde: line [" << (ibuf) << "]\n" ); // Empty line (end of message) ? if (!ibuf.compare("\n")) { - LOGDEB(("MHExecMultiple: Got empty line\n")); + LOGDEB("MHExecMultiple: Got empty line\n" ); name.clear(); return true; } @@ -112,8 +112,7 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data) vector tokens; stringToTokens(ibuf, tokens); if (tokens.size() != 2) { - LOGERR(("MHExecMultiple: bad line in filter output: [%s]\n", - ibuf.c_str())); + LOGERR("MHExecMultiple: bad line in filter output: [" << (ibuf) << "]\n" ); return false; } vector::iterator it = tokens.begin(); @@ -121,13 +120,12 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data) string& slen = *it; int len; if (sscanf(slen.c_str(), "%d", &len) != 1) { - LOGERR(("MHExecMultiple: bad line in filter output: [%s]\n", - ibuf.c_str())); + LOGERR("MHExecMultiple: bad line in filter output: [" << (ibuf) << "]\n" ); return false; } if (len / 1024 > m_maxmemberkb) { - LOGERR(("MHExecMultiple: data len > maxmemberkb\n")); + LOGERR("MHExecMultiple: data len > maxmemberkb\n" ); return false; } @@ -144,24 +142,23 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data) // Read element data datap->erase(); if (len > 0 && m_cmd.receive(*datap, len) != len) { - LOGERR(("MHExecMultiple: expected %d bytes of data, got %d\n", - len, datap->length())); + LOGERR("MHExecMultiple: expected " << (len) << " bytes of data, got " << (datap->length()) << "\n" ); return false; } - LOGDEB1(("MHExecMe:rdDtElt got: name [%s] len %d value [%s]\n", - name.c_str(), len, datap->size() > 100 ? - (datap->substr(0, 100) + " ...").c_str() : datap->c_str())); + LOGDEB1("MHExecMe:rdDtElt got: name [" << name << "] len " << len << + "value [" << (datap->size() > 100 ? + (datap->substr(0, 100) + " ...") : datap) << endl); return true; } 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) return false; if (missingHelper) { - LOGDEB(("MHExecMultiple::next_document(): helper known missing\n")); + LOGDEB("MHExecMultiple::next_document(): helper known missing\n" ); return false; } @@ -185,8 +182,7 @@ bool MimeHandlerExecMultiple::next_document() if (MD5File(m_fn, md5, &reason)) { file_md5 = MD5HexPrint(md5, xmd5); } else { - LOGERR(("MimeHandlerExecM: cant compute md5 for [%s]: %s\n", - m_fn.c_str(), reason.c_str())); + LOGERR("MimeHandlerExecM: cant compute md5 for [" << (m_fn) << "]: " << (reason) << "\n" ); } } obuf << "FileName: " << m_fn.length() << "\n" << m_fn; @@ -196,8 +192,7 @@ bool MimeHandlerExecMultiple::next_document() obuf << "Filename: " << 0 << "\n"; } if (!m_ipath.empty()) { - LOGDEB(("next_doc: sending len %d val [%s]\n", m_ipath.length(), - m_ipath.c_str())); + LOGDEB("next_doc: sending len " << (m_ipath.length()) << " val [" << (m_ipath) << "]\n" ); obuf << "Ipath: " << m_ipath.length() << "\n" << m_ipath; } if (!m_dfltInputCharset.empty()) { @@ -208,14 +203,14 @@ bool MimeHandlerExecMultiple::next_document() obuf << "\n"; if (m_cmd.send(obuf.str()) < 0) { m_cmd.zapChild(); - LOGERR(("MHExecMultiple: send error\n")); + LOGERR("MHExecMultiple: send error\n" ); return false; } m_adv.reset(); // Read answer (multiple elements) - LOGDEB1(("MHExecMultiple: reading answer\n")); + LOGDEB1("MHExecMultiple: reading answer\n" ); bool eofnext_received = false; bool eofnow_received = false; bool fileerror_received = false; @@ -231,47 +226,46 @@ bool MimeHandlerExecMultiple::next_document() return false; } } catch (HandlerTimeout) { - LOGINFO(("MHExecMultiple: timeout\n")); + LOGINFO("MHExecMultiple: timeout\n" ); m_cmd.zapChild(); return false; } catch (CancelExcept) { - LOGINFO(("MHExecMultiple: interrupt\n")); + LOGINFO("MHExecMultiple: interrupt\n" ); m_cmd.zapChild(); return false; } if (name.empty()) break; if (!stringlowercmp("eofnext:", name)) { - LOGDEB(("MHExecMultiple: got EOFNEXT\n")); + LOGDEB("MHExecMultiple: got EOFNEXT\n" ); eofnext_received = true; } else if (!stringlowercmp("eofnow:", name)) { - LOGDEB(("MHExecMultiple: got EOFNOW\n")); + LOGDEB("MHExecMultiple: got EOFNOW\n" ); eofnow_received = true; } else if (!stringlowercmp("fileerror:", name)) { - LOGDEB(("MHExecMultiple: got FILEERROR\n")); + LOGDEB("MHExecMultiple: got FILEERROR\n" ); fileerror_received = true; } else if (!stringlowercmp("subdocerror:", name)) { - LOGDEB(("MHExecMultiple: got SUBDOCERROR\n")); + LOGDEB("MHExecMultiple: got SUBDOCERROR\n" ); subdocerror_received = true; } else if (!stringlowercmp("ipath:", name)) { ipath = data; - LOGDEB(("MHExecMultiple: got ipath [%s]\n", data.c_str())); + LOGDEB("MHExecMultiple: got ipath [" << (data) << "]\n" ); } else if (!stringlowercmp("charset:", name)) { charset = data; - LOGDEB(("MHExecMultiple: got charset [%s]\n", data.c_str())); + LOGDEB("MHExecMultiple: got charset [" << (data) << "]\n" ); } else if (!stringlowercmp("mimetype:", name)) { mtype = data; - LOGDEB(("MHExecMultiple: got mimetype [%s]\n", data.c_str())); + LOGDEB("MHExecMultiple: got mimetype [" << (data) << "]\n" ); } else { string nm = stringtolower((const string&)name); trimstring(nm, ":"); - LOGDEB(("MHExecMultiple: got [%s] -> [%s]\n", nm.c_str(), - data.c_str())); + LOGDEB("MHExecMultiple: got [" << (nm) << "] -> [" << (data) << "]\n" ); m_metaData[nm] += data; } if (loop == 20) { // ?? - LOGERR(("MHExecMultiple: filter sent too many parameters\n")); + LOGERR("MHExecMultiple: filter sent too many parameters\n" ); return false; } } @@ -289,8 +283,7 @@ bool MimeHandlerExecMultiple::next_document() // this was wrong. Empty documents can be found ie in zip files and should // not be interpreted as eof. if (m_metaData[cstr_dj_keycontent].empty()) { - LOGDEB0(("MHExecMultiple: got empty document inside [%s]: [%s]\n", - m_fn.c_str(), ipath.c_str())); + LOGDEB0("MHExecMultiple: got empty document inside [" << (m_fn) << "]: [" << (ipath) << "]\n" ); } if (!ipath.empty()) { @@ -300,8 +293,7 @@ bool MimeHandlerExecMultiple::next_document() // string which we can use to compute a mime type m_metaData[cstr_dj_keyipath] = ipath; if (mtype.empty()) { - LOGDEB0(("MHExecMultiple: no mime type from filter, " - "using ipath for a guess\n")); + LOGDEB0("MHExecMultiple: no mime type from filter, using ipath for a guess\n" ); mtype = mimetype(ipath, 0, m_config, false); if (mtype.empty()) { // 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 // We could recognize them by the end /, but wouldn't know // what to do with them anyway. - LOGINFO(("MHExecMultiple: cant guess mime type\n")); + LOGINFO("MHExecMultiple: cant guess mime type\n" ); mtype = "application/octet-stream"; } } @@ -335,10 +327,7 @@ bool MimeHandlerExecMultiple::next_document() if (eofnext_received) m_havedoc = false; - LOGDEB0(("MHExecMultiple: returning %d bytes of content," - " 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())); + 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" ); return true; } + diff --git a/src/internfile/mh_html.cpp b/src/internfile/mh_html.cpp index 2750146d..bc0ec594 100644 --- a/src/internfile/mh_html.cpp +++ b/src/internfile/mh_html.cpp @@ -17,7 +17,7 @@ #include "cstr.h" #include "mimehandler.h" -#include "debuglog.h" +#include "log.h" #include "readfile.h" #include "transcode.h" #include "mimeparse.h" @@ -36,11 +36,11 @@ using namespace std; 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); string otext; if (!file_to_string(fn, otext)) { - LOGINFO(("textHtmlToDoc: cant read: %s\n", fn.c_str())); + LOGINFO("textHtmlToDoc: cant read: " << (fn) << "\n" ); return false; } m_filename = fn; @@ -73,14 +73,12 @@ bool MimeHandlerHtml::next_document() m_filename.erase(); string charset = m_dfltInputCharset; - LOGDEB(("MHHtml::next_doc.: default supposed input charset: [%s]\n", - charset.c_str())); + LOGDEB("MHHtml::next_doc.: default supposed input charset: [" << (charset) << "]\n" ); // Override default input charset if someone took care to set one: map::const_iterator it = m_metaData.find(cstr_dj_keycharset); if (it != m_metaData.end() && !it->second.empty()) { charset = it->second; - LOGDEB(("MHHtml: next_doc.: input charset from ext. metadata: [%s]\n", - charset.c_str())); + LOGDEB("MHHtml: next_doc.: input charset from ext. metadata: [" << (charset) << "]\n" ); } // - We first try to convert from the supposed charset @@ -93,14 +91,13 @@ bool MimeHandlerHtml::next_document() MyHtmlParser result; for (int pass = 0; pass < 2; pass++) { string transcoded; - LOGDEB(("Html::mkDoc: pass %d\n", pass)); + LOGDEB("Html::mkDoc: pass " << (pass) << "\n" ); MyHtmlParser p; // Try transcoding. If it fails, use original text. int ecnt; if (!transcode(m_html, transcoded, charset, "UTF-8", &ecnt)) { - LOGDEB(("textHtmlToDoc: transcode failed from cs '%s' to UTF-8 for" - "[%s]", charset.c_str(), fn.empty()?"unknown":fn.c_str())); + LOGDEB("textHtmlToDoc: transcode failed from cs '" << (charset) << "' to UTF-8 for[" << (fn.empty()?"unknown":fn) << "]" ); transcoded = m_html; // We don't know the charset, at all p.reset_charsets(); @@ -108,11 +105,9 @@ bool MimeHandlerHtml::next_document() } else { if (ecnt) { if (pass == 0) { - LOGDEB(("textHtmlToDoc: init transcode had %d errors for " - "[%s]\n", ecnt, fn.empty()?"unknown":fn.c_str())); + LOGDEB("textHtmlToDoc: init transcode had " << (ecnt) << " errors for [" << (fn.empty()?"unknown":fn) << "]\n" ); } else { - LOGERR(("textHtmlToDoc: final transcode had %d errors for " - "[%s]\n", ecnt, fn.empty()?"unknown":fn.c_str())); + LOGERR("textHtmlToDoc: final transcode had " << (ecnt) << " errors for [" << (fn.empty()?"unknown":fn) << "]\n" ); } } // charset has the putative source charset, transcoded is now @@ -150,16 +145,15 @@ bool MimeHandlerHtml::next_document() break; } - LOGDEB(("textHtmlToDoc: charset [%s] doc charset [%s]\n", - charset.c_str(), result.get_charset().c_str())); + LOGDEB("textHtmlToDoc: charset [" << (charset) << "] doc charset [" << (result.get_charset()) << "]\n" ); if (!result.get_charset().empty() && !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 // transcoding again charset = result.get_charset(); } else { - LOGERR(("textHtmlToDoc:: error: non charset exception\n")); + LOGERR("textHtmlToDoc:: error: non charset exception\n" ); return false; } } @@ -181,3 +175,4 @@ bool MimeHandlerHtml::next_document() } return true; } + diff --git a/src/internfile/mh_mail.cpp b/src/internfile/mh_mail.cpp index 9d4a3f36..e54812fa 100644 --- a/src/internfile/mh_mail.cpp +++ b/src/internfile/mh_mail.cpp @@ -33,7 +33,7 @@ #include "transcode.h" #include "mimeparse.h" #include "mh_mail.h" -#include "debuglog.h" +#include "log.h" #include "smallut.h" #include "mh_html.h" #include "rclconfig.h" @@ -89,7 +89,7 @@ void MimeHandlerMail::clear() 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); if (m_fd >= 0) { close(m_fd); @@ -103,14 +103,12 @@ bool MimeHandlerMail::set_document_file(const string& mt, const string &fn) if (MD5File(fn, md5, &reason)) { m_metaData[cstr_dj_keymd5] = MD5HexPrint(md5, xmd5); } else { - LOGERR(("MimeHandlerMail: cant md5 [%s]: %s\n", fn.c_str(), - reason.c_str())); + LOGERR("MimeHandlerMail: cant md5 [" << (fn) << "]: " << (reason) << "\n" ); } } m_fd = open(fn.c_str(), 0); if (m_fd < 0) { - LOGERR(("MimeHandlerMail::set_document_file: open(%s) errno %d\n", - fn.c_str(), errno)); + LOGERR("MimeHandlerMail::set_document_file: open(" << (fn) << ") errno " << (errno) << "\n" ); return false; } #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->parseFull(m_fd); if (!m_bincdoc->isHeaderParsed() && !m_bincdoc->isAllParsed()) { - LOGERR(("MimeHandlerMail::mkDoc: mime parse error for %s\n", - fn.c_str())); + LOGERR("MimeHandlerMail::mkDoc: mime parse error for " << (fn) << "\n" ); return false; } 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, const string &msgtxt) { - LOGDEB1(("MimeHandlerMail::set_document_string\n")); - LOGDEB2(("Message text: [%s]\n", msgtxt.c_str())); + LOGDEB1("MimeHandlerMail::set_document_string\n" ); + LOGDEB2("Message text: [" << (msgtxt) << "]\n" ); RecollFilter::set_document_string(mt, msgtxt); 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()) { - LOGERR(("MimeHandlerMail::set_document_string: stream create error." - "msgtxt.size() %d\n", int(msgtxt.size()))); + LOGERR("MimeHandlerMail::set_document_string: stream create error.msgtxt.size() " << (int(msgtxt.size())) << "\n" ); return false; } delete m_bincdoc; if ((m_bincdoc = new Binc::MimeDocument) == 0) { - LOGERR(("MimeHandlerMail::set_doc._string: new Binc:Document failed." - " Out of memory?")); + LOGERR("MimeHandlerMail::set_doc._string: new Binc:Document failed. Out of memory?" ); return false; } m_bincdoc->parseFull(*m_stream); 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; } m_havedoc = true; @@ -166,14 +161,14 @@ bool MimeHandlerMail::set_document_string(const string& mt, 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) { // No decoding done yet. If ipath is null need do nothing if (ipath.empty() || ipath == "-1") return true; // ipath points to attachment: need to decode message if (!next_document()) { - LOGERR(("MimeHandlerMail::skip_to_doc: next_document failed\n")); + LOGERR("MimeHandlerMail::skip_to_doc: next_document failed\n" ); return false; } } @@ -183,8 +178,7 @@ bool MimeHandlerMail::skip_to_document(const string& ipath) bool MimeHandlerMail::next_document() { - LOGDEB(("MimeHandlerMail::next_document m_idx %d m_havedoc %d\n", - m_idx, m_havedoc)); + LOGDEB("MimeHandlerMail::next_document m_idx " << (m_idx) << " m_havedoc " << (m_havedoc) << "\n" ); if (!m_havedoc) return false; bool res = false; @@ -192,8 +186,7 @@ bool MimeHandlerMail::next_document() if (m_idx == -1) { m_metaData[cstr_dj_keymt] = cstr_textplain; res = processMsg(m_bincdoc, 0); - LOGDEB1(("MimeHandlerMail::next_document: mt %s, att cnt %d\n", - m_metaData[cstr_dj_keymt].c_str(), m_attachments.size())); + LOGDEB1("MimeHandlerMail::next_document: mt " << (m_metaData[cstr_dj_keymt]) << ", att cnt " << (m_attachments.size()) << "\n" ); const string& txt = m_metaData[cstr_dj_keycontent]; if (m_startoftext < txt.size()) m_metaData[cstr_dj_keyabstract] = @@ -228,16 +221,16 @@ static bool decodeBody(const string& cte, // Content transfer encoding if (!stringlowercmp("quoted-printable", cte)) { if (!qp_decode(body, decoded)) { - LOGERR(("decodeBody: quoted-printable decoding failed !\n")); - LOGDEB((" Body: \n%s\n", body.c_str())); + LOGERR("decodeBody: quoted-printable decoding failed !\n" ); + LOGDEB(" Body: \n" << (body) << "\n" ); return false; } *respp = &decoded; } else if (!stringlowercmp("base64", cte)) { if (!base64_decode(body, decoded)) { // base64 encoding errors are actually relatively common - LOGERR(("decodeBody: base64 decoding failed !\n")); - LOGDEB((" Body: \n%s\n", body.c_str())); + LOGERR("decodeBody: base64 decoding failed !\n" ); + LOGDEB(" Body: \n" << (body) << "\n" ); return false; } *respp = &decoded; @@ -247,7 +240,7 @@ static bool decodeBody(const string& cte, // Content transfer encoding bool MimeHandlerMail::processAttach() { - LOGDEB(("MimeHandlerMail::processAttach() m_idx %d\n", m_idx)); + LOGDEB("MimeHandlerMail::processAttach() m_idx " << (m_idx) << "\n" ); if (!m_havedoc) return false; 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_keyfn] = att->m_filename; m_metaData[cstr_dj_keytitle] = att->m_filename + " (" + m_subject + ")"; - LOGDEB1((" processAttach:ct [%s] cs [%s] fn [%s]\n", - att->m_contentType.c_str(), - att->m_charset.c_str(), - att->m_filename.c_str())); + LOGDEB1(" processAttach:ct [" << (att->m_contentType) << "] cs [" << (att->m_charset) << "] fn [" << (att->m_filename) << "]\n" ); // Erase current content and replace m_metaData[cstr_dj_keycontent] = string(); @@ -315,11 +305,10 @@ bool MimeHandlerMail::processAttach() // text bool MimeHandlerMail::processMsg(Binc::MimePart *doc, int depth) { - LOGDEB2(("MimeHandlerMail::processMsg: depth %d\n", depth)); + LOGDEB2("MimeHandlerMail::processMsg: depth " << (depth) << "\n" ); if (depth++ >= maxdepth) { // Have to stop somewhere - LOGINFO(("MimeHandlerMail::processMsg: maxdepth %d exceeded\n", - maxdepth)); + LOGINFO("MimeHandlerMail::processMsg: maxdepth " << (maxdepth) << " exceeded\n" ); // Return true anyway, better to index partially than not at all return true; } @@ -371,7 +360,7 @@ bool MimeHandlerMail::processMsg(Binc::MimePart *doc, int depth) m_metaData[cstr_dj_keymd] = ascuxtime; } else { // Leave mtime field alone, ftime will be used instead. - LOGDEB(("rfc2822Date...: failed: [%s]\n", decoded.c_str())); + LOGDEB("rfc2822Date...: failed: [" << (decoded) << "]\n" ); } } if (preview()) @@ -405,12 +394,10 @@ bool MimeHandlerMail::processMsg(Binc::MimePart *doc, int depth) text += '\n'; m_startoftext = text.size(); - LOGDEB2(("MimeHandlerMail::processMsg:ismultipart %d mime subtype '%s'\n", - doc->isMultipart(), doc->getSubType().c_str())); + LOGDEB2("MimeHandlerMail::processMsg:ismultipart " << (doc->isMultipart()) << " mime subtype '" << (doc->getSubType()) << "'\n" ); walkmime(doc, depth); - LOGDEB2(("MimeHandlerMail::processMsg:text:[%s]\n", - m_metaData[cstr_dj_keycontent].c_str())); + LOGDEB2("MimeHandlerMail::processMsg:text:[" << (m_metaData[cstr_dj_keycontent]) << "]\n" ); return true; } @@ -426,17 +413,16 @@ bool MimeHandlerMail::processMsg(Binc::MimePart *doc, int depth) // message/rfc822 may also be of interest. void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth) { - LOGDEB2(("MimeHandlerMail::walkmime: depth %d\n", depth)); + LOGDEB2("MimeHandlerMail::walkmime: depth " << (depth) << "\n" ); if (depth++ >= maxdepth) { - LOGINFO(("walkmime: max depth (%d) exceeded\n", maxdepth)); + LOGINFO("walkmime: max depth (" << (maxdepth) << ") exceeded\n" ); return; } string& out = m_metaData[cstr_dj_keycontent]; if (doc->isMultipart()) { - LOGDEB2(("walkmime: ismultipart %d subtype '%s'\n", - doc->isMultipart(), doc->getSubType().c_str())); + LOGDEB2("walkmime: ismultipart " << (doc->isMultipart()) << " subtype '" << (doc->getSubType()) << "'\n" ); // We only handle alternative, related and mixed (no digests). std::vector::iterator it; @@ -459,22 +445,22 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth) // Get and parse content-type header Binc::HeaderItem 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; } MimeHeaderValue 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)) ittxt = it; else if (!stringlowercmp("text/html", content_type.value)) ithtml = it; } if (ittxt != doc->members.end()) { - LOGDEB2(("walkmime: alternative: chose text/plain part\n")) + LOGDEB2("walkmime: alternative: chose text/plain part\n" ); walkmime(&(*ittxt), depth); } 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); } } @@ -490,7 +476,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth) if (doc->h.getFirstHeader("Content-Type", hi)) { ctt = hi.getValue(); } - LOGDEB2(("walkmime:content-type: %s\n", ctt.c_str())); + LOGDEB2("walkmime:content-type: " << (ctt) << "\n" ); MimeHeaderValue content_type; parseMimeHeaderValue(ctt, content_type); @@ -501,7 +487,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth) } MimeHeaderValue 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; if (stringlowercmp("inline", content_disposition.value)) dispindic = "Attachment"; @@ -521,7 +507,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth) } if (doc->isMessageRFC822()) { - LOGDEB2(("walkmime: message/RFC822 part\n")); + LOGDEB2("walkmime: message/RFC822 part\n" ); // The first part is the already parsed message. Call // processMsg instead of walkmime so that mail headers get @@ -542,7 +528,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth) } // "Simple" part. - LOGDEB2(("walkmime: simple part\n")); + LOGDEB2("walkmime: simple part\n" ); // 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 // 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; if (att == 0) { - LOGERR(("Out of memory\n")); + LOGERR("Out of memory\n" ); return; } att->m_contentType = content_type.value; @@ -598,11 +584,7 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth) att->m_charset = charset; att->m_contentTransferEncoding = cte; att->m_part = doc; - LOGDEB(("walkmime: attachmnt: ct [%s] cte [%s] cs [%s] fn [%s]\n", - att->m_contentType.c_str(), - att->m_contentTransferEncoding.c_str(), - att->m_charset.c_str(), - filename.c_str())); + LOGDEB("walkmime: attachmnt: ct [" << (att->m_contentType) << "] cte [" << (att->m_contentTransferEncoding) << "] cs [" << (att->m_charset) << "] fn [" << (filename) << "]\n" ); m_attachments.push_back(att); return; } @@ -612,15 +594,14 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth) // filter stack work: this would create another subdocument, but // we want instead to decode a body part of this message document. - LOGDEB2(("walkmime: final: body start offset %d, length %d\n", - doc->getBodyStartOffset(), doc->getBodyLength())); + LOGDEB2("walkmime: final: body start offset " << (doc->getBodyStartOffset()) << ", length " << (doc->getBodyLength()) << "\n" ); string body; doc->getBody(body, 0, doc->bodylength); { string decoded; const string *bdp; if (!decodeBody(cte, body, decoded, &bdp)) { - LOGERR(("MimeHandlerMail::walkmime: failed decoding body\n")); + LOGERR("MimeHandlerMail::walkmime: failed decoding body\n" ); } if (bdp != &body) body.swap(decoded); @@ -641,10 +622,9 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth) } else { string utf8; // 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)) { - LOGERR(("walkmime: transcode failed from cs '%s' to UTF-8\n", - charset.c_str())); + LOGERR("walkmime: transcode failed from cs '" << (charset) << "' to UTF-8\n" ); out += body; } else { out += utf8; @@ -654,5 +634,6 @@ void MimeHandlerMail::walkmime(Binc::MimePart* doc, int depth) if (out.length() && out[out.length()-1] != '\n') out += '\n'; - LOGDEB2(("walkmime: out now: [%s]\n", out.c_str())); + LOGDEB2("walkmime: out now: [" << (out) << "]\n" ); } + diff --git a/src/internfile/mh_mbox.cpp b/src/internfile/mh_mbox.cpp index 0032f9a3..93af14d3 100644 --- a/src/internfile/mh_mbox.cpp +++ b/src/internfile/mh_mbox.cpp @@ -38,7 +38,7 @@ #include "cstr.h" #include "mimehandler.h" -#include "debuglog.h" +#include "log.h" #include "readfile.h" #include "mh_mbox.h" #include "smallut.h" @@ -100,47 +100,43 @@ public: ~MboxCache() {} mbhoff_type get_offset(RclConfig *config, const string& udi, int msgnum) { - LOGDEB0(("MboxCache::get_offsets: udi [%s] msgnum %d\n", udi.c_str(), - msgnum)); + LOGDEB0("MboxCache::get_offsets: udi [" << (udi) << "] msgnum " << (msgnum) << "\n" ); if (!ok(config)) { - LOGDEB0(("MboxCache::get_offsets: init failed\n")); + LOGDEB0("MboxCache::get_offsets: init failed\n" ); return -1; } PTMutexLocker locker(o_mcache_mutex); string fn = makefilename(udi); FILE *fp = 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; } FpKeeper keeper(&fp); char blk1[M_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; } ConfSimple cf(string(blk1, o_b1size)); string fudi; if (!cf.get("udi", fudi) || fudi.compare(udi)) { - LOGINFO(("MboxCache::get_offset:badudi fn %s udi [%s], fudi [%s]\n", - fn.c_str(), udi.c_str(), fudi.c_str())); + LOGINFO("MboxCache::get_offset:badudi fn " << (fn) << " udi [" << (udi) << "], fudi [" << (fudi) << "]\n" ); return -1; } if (fseeko(fp, cacheoffset(msgnum), SEEK_SET) != 0) { - LOGDEB0(("MboxCache::get_offsets: seek %s errno %d\n", - lltodecstr(cacheoffset(msgnum)).c_str(), errno)); + LOGDEB0("MboxCache::get_offsets: seek " << (lltodecstr(cacheoffset(msgnum))) << " errno " << (errno) << "\n" ); return -1; } mbhoff_type offset = -1; size_t ret; if ((ret = fread(&offset, 1, sizeof(mbhoff_type), fp)) != sizeof(mbhoff_type)) { - LOGDEB0(("MboxCache::get_offsets: read ret %d errno %d\n", - ret, errno)); + LOGDEB0("MboxCache::get_offsets: read ret " << (ret) << " errno " << (errno) << "\n" ); return -1; } - LOGDEB0(("MboxCache::get_offsets: ret %s\n", lltodecstr(offset).c_str())); + LOGDEB0("MboxCache::get_offsets: ret " << (lltodecstr(offset)) << "\n" ); return offset; } @@ -148,7 +144,7 @@ public: void put_offsets(RclConfig *config, const string& udi, mbhoff_type fsize, vector& offs) { - LOGDEB0(("MboxCache::put_offsets: %u offsets\n", offs.size())); + LOGDEB0("MboxCache::put_offsets: " << (offs.size()) << " offsets\n" ); if (!ok(config) || !maybemakedir()) return; if (fsize < m_minfsize) @@ -157,7 +153,7 @@ public: string fn = makefilename(udi); FILE *fp; 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; } FpKeeper keeper(&fp); @@ -167,7 +163,7 @@ public: blk1.append(cstr_newline); blk1.resize(o_b1size, 0); 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; } @@ -261,7 +257,7 @@ void MimeHandlerMbox::clear() 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); m_fn = fn; 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"); if (m_vfp == 0) { - LOGERR(("MimeHandlerMail::set_document_file: error opening %s\n", - fn.c_str())); + LOGERR("MimeHandlerMail::set_document_file: error opening " << (fn) << "\n" ); return false; } #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 {struct stat st; if (fstat(fileno((FILE*)m_vfp), &st) < 0) { - LOGERR(("MimeHandlerMbox:setdocfile: fstat(%s) failed errno %d\n", - fn.c_str(), errno)); + LOGERR("MimeHandlerMbox:setdocfile: fstat(" << (fn) << ") failed errno " << (errno) << "\n" ); return false; } m_fsize = st.st_size; @@ -297,7 +291,7 @@ bool MimeHandlerMbox::set_document_file(const string& mt, const string &fn) string quirks; if (m_config && m_config->getConfParam(cstr_keyquirks, quirks)) { if (quirks == "tbird") { - LOGDEB(("MimeHandlerMbox: setting quirks TBIRD\n")); + LOGDEB("MimeHandlerMbox: setting quirks TBIRD\n" ); m_quirks |= MBOXQUIRK_TBIRD; } } @@ -305,8 +299,7 @@ bool MimeHandlerMbox::set_document_file(const string& mt, const string &fn) // And double check for thunderbird string tbirdmsf = fn + ".msf"; if ((m_quirks&MBOXQUIRK_TBIRD) == 0 && path_exists(tbirdmsf)) { - LOGDEB(("MimeHandlerMbox: detected unconfigured tbird mbox in %s\n", - fn.c_str())); + LOGDEB("MimeHandlerMbox: detected unconfigured tbird mbox in " << (fn) << "\n" ); m_quirks |= MBOXQUIRK_TBIRD; } @@ -423,7 +416,7 @@ static void compileregexes() bool MimeHandlerMbox::next_document() { if (m_vfp == 0) { - LOGERR(("MimeHandlerMbox::next_document: not open\n")); + LOGERR("MimeHandlerMbox::next_document: not open\n" ); return false; } if (!m_havedoc) { @@ -435,11 +428,10 @@ bool MimeHandlerMbox::next_document() sscanf(m_ipath.c_str(), "%d", &mtarg); } else if (m_forPreview) { // 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; } - LOGDEB0(("MimeHandlerMbox::next_document: fn %s, msgnum %d mtarg %d \n", - m_fn.c_str(), m_msgnum, mtarg)); + LOGDEB0("MimeHandlerMbox::next_document: fn " << (m_fn) << ", msgnum " << (m_msgnum) << " mtarg " << (mtarg) << " \n" ); if (mtarg == 0) mtarg = -1; @@ -459,8 +451,7 @@ bool MimeHandlerMbox::next_document() if (mtarg > 0) { mbhoff_type off; line_type line; - LOGDEB0(("MimeHandlerMbox::next_doc: mtarg %d m_udi[%s]\n", - mtarg, m_udi.c_str())); + LOGDEB0("MimeHandlerMbox::next_doc: mtarg " << (mtarg) << " m_udi[" << (m_udi) << "]\n" ); if (!m_udi.empty() && (off = o_mcache.get_offset(m_config, m_udi, mtarg)) >= 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_quirks & MBOXQUIRK_TBIRD) && !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); m_msgnum = mtarg -1; storeoffsets = false; @@ -487,7 +478,7 @@ bool MimeHandlerMbox::next_document() for (;;) { message_end = ftello(fp); if (!fgets(line, LL, fp)) { - LOGDEB2(("MimeHandlerMbox:next: eof\n")); + LOGDEB2("MimeHandlerMbox:next: eof\n" ); iseof = true; m_msgnum++; break; @@ -495,8 +486,7 @@ bool MimeHandlerMbox::next_document() m_lineno++; int ll; stripendnl(line, ll); - LOGDEB2(("mhmbox:next: hadempty %d lineno %d ll %d Line: [%s]\n", - hademptyline, m_lineno, ll, line)); + LOGDEB2("mhmbox:next: hadempty " << (hademptyline) << " lineno " << (m_lineno) << " ll " << (ll) << " Line: [" << (line) << "]\n" ); if (hademptyline) { if (ll > 0) { // Non-empty line with empty line flag set, reset flag @@ -514,8 +504,7 @@ bool MimeHandlerMbox::next_document() ((m_quirks & MBOXQUIRK_TBIRD) && !M_regexec(minifromregex, line, 0, 0, 0))) ) { - LOGDEB0(("MimeHandlerMbox: msgnum %d, " - "From_ at line %d: [%s]\n", m_msgnum, m_lineno, line)); + LOGDEB0("MimeHandlerMbox: msgnum " << (m_msgnum) << ", From_ at line " << (m_lineno) << ": [" << (line) << "]\n" ); if (storeoffsets) m_offsets.push_back(message_end); m_msgnum++; @@ -538,15 +527,13 @@ bool MimeHandlerMbox::next_document() line[ll+1] = 0; msgtxt += line; if (msgtxt.size() > max_mbox_member_size) { - LOGERR(("mh_mbox: huge message (more than %u MB) inside %s," - " giving up\n", max_mbox_member_size/(1024*1024), - m_fn.c_str())); + LOGERR("mh_mbox: huge message (more than " << (max_mbox_member_size/(1024*1024)) << " MB) inside " << (m_fn) << ", giving up\n" ); return false; } } } - LOGDEB2(("Message text length %d\n", msgtxt.size())); - LOGDEB2(("Message text: [%s]\n", msgtxt.c_str())); + LOGDEB2("Message text length " << (msgtxt.size()) << "\n" ); + LOGDEB2("Message text: [" << (msgtxt) << "]\n" ); char buf[20]; // m_msgnum was incremented when hitting the next From_ or eof, so the data // is for m_msgnum - 1 @@ -554,7 +541,7 @@ bool MimeHandlerMbox::next_document() m_metaData[cstr_dj_keyipath] = buf; m_metaData[cstr_dj_keymt] = "message/rfc822"; if (iseof) { - LOGDEB2(("MimeHandlerMbox::next: eof hit\n")); + LOGDEB2("MimeHandlerMbox::next: eof hit\n" ); m_havedoc = false; if (!m_udi.empty() && storeoffsets) { 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 + diff --git a/src/internfile/mh_symlink.h b/src/internfile/mh_symlink.h index dd0c769c..8f200af8 100644 --- a/src/internfile/mh_symlink.h +++ b/src/internfile/mh_symlink.h @@ -25,7 +25,7 @@ #include "mimehandler.h" #include "transcode.h" #include "pathut.h" -#include "debuglog.h" +#include "log.h" /** Index symlink target * @@ -61,8 +61,7 @@ class MimeHandlerSymlink : public RecollFilter { transcode(path_getsimple(slc), m_metaData[cstr_dj_keycontent], m_config->getDefCharset(true), "UTF-8"); } else { - LOGDEB(("Symlink: readlink [%s] failed, errno %d\n", m_fn.c_str(), - errno)); + LOGDEB("Symlink: readlink [" << (m_fn) << "] failed, errno " << (errno) << "\n" ); } m_metaData[cstr_dj_keymt] = cstr_textplain; return true; @@ -72,3 +71,4 @@ private: }; #endif /* _MH_SYMLINK_H_INCLUDED_ */ + diff --git a/src/internfile/mh_text.cpp b/src/internfile/mh_text.cpp index 80da2733..91186ee5 100644 --- a/src/internfile/mh_text.cpp +++ b/src/internfile/mh_text.cpp @@ -27,7 +27,7 @@ #include "cstr.h" #include "mh_text.h" -#include "debuglog.h" +#include "log.h" #include "readfile.h" #include "md5ut.h" #include "rclconfig.h" @@ -42,8 +42,7 @@ const int KB = 1024; // Process a plain text file bool MimeHandlerText::set_document_file(const string& mt, const string &fn) { - LOGDEB(("MimeHandlerText::set_document_file: [%s] offs %s\n", - fn.c_str(), lltodecstr(m_offs).c_str())); + LOGDEB("MimeHandlerText::set_document_file: [" << (fn) << "] offs " << (lltodecstr(m_offs)) << "\n" ); 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 long long fsize = path_filesize(m_fn); if (fsize < 0) { - LOGERR(("MimeHandlerText::set_document_file: stat %s errno %d\n", - m_fn.c_str(), errno)); + LOGERR("MimeHandlerText::set_document_file: stat " << (m_fn) << " errno " << (errno) << "\n" ); return false; } @@ -111,8 +109,7 @@ bool MimeHandlerText::skip_to_document(const string& ipath) char *endptr; long long t = strtoll(ipath.c_str(), &endptr, 10); if (endptr == ipath.c_str()) { - LOGERR(("MimeHandlerText::skip_to_document: bad ipath offs [%s]\n", - ipath.c_str())); + LOGERR("MimeHandlerText::skip_to_document: bad ipath offs [" << (ipath) << "]\n" ); return false; } m_offs = (off_t)t; @@ -122,7 +119,7 @@ bool MimeHandlerText::skip_to_document(const string& ipath) 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) return false; @@ -175,7 +172,7 @@ bool MimeHandlerText::readnext() string reason; m_text.clear(); 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; return false; } @@ -197,3 +194,4 @@ bool MimeHandlerText::readnext() m_offs += m_text.length(); return true; } + diff --git a/src/internfile/mimehandler.cpp b/src/internfile/mimehandler.cpp index 5cd1bbf3..6a273102 100644 --- a/src/internfile/mimehandler.cpp +++ b/src/internfile/mimehandler.cpp @@ -27,7 +27,7 @@ using namespace std; #include "cstr.h" #include "mimehandler.h" -#include "debuglog.h" +#include "log.h" #include "rclconfig.h" #include "smallut.h" #include "md5ut.h" @@ -60,8 +60,7 @@ static RecollFilter *getMimeHandlerFromCache(const string& key) PTMutexLocker locker(o_handlers_mutex); string xdigest; MD5HexPrint(key, xdigest); - LOGDEB(("getMimeHandlerFromCache: %s cache size %u\n", - xdigest.c_str(), o_handlers.size())); + LOGDEB("getMimeHandlerFromCache: " << (xdigest) << " cache size " << (o_handlers.size()) << "\n" ); multimap::iterator it = o_handlers.find(key); if (it != o_handlers.end()) { @@ -70,14 +69,13 @@ static RecollFilter *getMimeHandlerFromCache(const string& key) if (it1 != o_hlru.end()) { o_hlru.erase(it1); } else { - LOGERR(("getMimeHandlerFromCache: lru position not found\n")); + LOGERR("getMimeHandlerFromCache: lru position not found\n" ); } o_handlers.erase(it); - LOGDEB(("getMimeHandlerFromCache: %s found size %u\n", - xdigest.c_str(), o_handlers.size())); + LOGDEB("getMimeHandlerFromCache: " << (xdigest) << " found size " << (o_handlers.size()) << "\n" ); return h; } - LOGDEB(("getMimeHandlerFromCache: %s not found\n", xdigest.c_str())); + LOGDEB("getMimeHandlerFromCache: " << (xdigest) << " not found\n" ); return 0; } @@ -87,15 +85,14 @@ void returnMimeHandler(RecollFilter *handler) typedef multimap::value_type value_type; if (handler == 0) { - LOGERR(("returnMimeHandler: bad parameter\n")); + LOGERR("returnMimeHandler: bad parameter\n" ); return; } handler->clear(); PTMutexLocker locker(o_handlers_mutex); - LOGDEB(("returnMimeHandler: returning filter for %s cache size %d\n", - handler->get_mime_type().c_str(), o_handlers.size())); + LOGDEB("returnMimeHandler: returning filter for " << (handler->get_mime_type()) << " cache size " << (o_handlers.size()) << "\n" ); // Limit pool size. The pool can grow quite big because there are // many filter types, each of which can be used in several copies @@ -108,9 +105,9 @@ void returnMimeHandler(RecollFilter *handler) if (once) { once = 0; 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) { it = o_hlru.back(); @@ -125,7 +122,7 @@ void returnMimeHandler(RecollFilter *handler) void clearMimeHandlerCache() { - LOGDEB(("clearMimeHandlerCache()\n")); + LOGDEB("clearMimeHandlerCache()\n" ); multimap::iterator it; PTMutexLocker locker(o_handlers_mutex); for (it = o_handlers.begin(); it != o_handlers.end(); it++) { @@ -139,31 +136,31 @@ void clearMimeHandlerCache() static RecollFilter *mhFactory(RclConfig *config, const string &mime, bool nobuild, string& id) { - LOGDEB2(("mhFactory(%s)\n", mime.c_str())); + LOGDEB2("mhFactory(" << (mime) << ")\n" ); string lmime(mime); stringtolower(lmime); if (cstr_textplain == lmime) { - LOGDEB2(("mhFactory(%s): returning MimeHandlerText\n", mime.c_str())); + LOGDEB2("mhFactory(" << (mime) << "): returning MimeHandlerText\n" ); MD5String("MimeHandlerText", id); return nobuild ? 0 : new MimeHandlerText(config, id); } else if ("text/html" == lmime) { - LOGDEB2(("mhFactory(%s): returning MimeHandlerHtml\n", mime.c_str())); + LOGDEB2("mhFactory(" << (mime) << "): returning MimeHandlerHtml\n" ); MD5String("MimeHandlerHtml", id); return nobuild ? 0 : new MimeHandlerHtml(config, id); } else if ("text/x-mail" == lmime) { - LOGDEB2(("mhFactory(%s): returning MimeHandlerMbox\n", mime.c_str())); + LOGDEB2("mhFactory(" << (mime) << "): returning MimeHandlerMbox\n" ); MD5String("MimeHandlerMbox", id); return nobuild ? 0 : new MimeHandlerMbox(config, id); } else if ("message/rfc822" == lmime) { - LOGDEB2(("mhFactory(%s): returning MimeHandlerMail\n", mime.c_str())); + LOGDEB2("mhFactory(" << (mime) << "): returning MimeHandlerMail\n" ); MD5String("MimeHandlerMail", id); return nobuild ? 0 : new MimeHandlerMail(config, id); } else if ("inode/symlink" == lmime) { - LOGDEB2(("mhFactory(%s): ret MimeHandlerSymlink\n", mime.c_str())); + LOGDEB2("mhFactory(" << (mime) << "): ret MimeHandlerSymlink\n" ); MD5String("MimeHandlerSymlink", id); return nobuild ? 0 : new MimeHandlerSymlink(config, id); } else if ("application/x-zerosize" == lmime) { - LOGDEB(("mhFactory(%s): ret MimeHandlerNull\n", mime.c_str())); + LOGDEB("mhFactory(" << (mime) << "): ret MimeHandlerNull\n" ); MD5String("MimeHandlerNull", id); return nobuild ? 0 : new MimeHandlerNull(config, id); } 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 // allows indexing and previewing as text/plain (no filter // 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); return nobuild ? 0 : new MimeHandlerText(config, id); } else { // We should not get there. It means that "internal" was set // as a handler in mimeconf for a mime type we actually can't // handle. - LOGERR(("mhFactory: mime type [%s] set as internal but unknown\n", - lmime.c_str())); + LOGERR("mhFactory: mime type [" << (lmime) << "] set as internal but unknown\n" ); MD5String("MimeHandlerUnknown", id); return nobuild ? 0 : new MimeHandlerUnknown(config, id); } @@ -203,8 +199,7 @@ MimeHandlerExec *mhExecFactory(RclConfig *cfg, const string& mtype, string& hs, string cmdstr; if (!cfg->valueSplitAttributes(hs, cmdstr, attrs)) { - LOGERR(("mhExecFactory: bad config line for [%s]: [%s]\n", - mtype.c_str(), hs.c_str())); + LOGERR("mhExecFactory: bad config line for [" << (mtype) << "]: [" << (hs) << "]\n" ); return 0; } @@ -212,8 +207,7 @@ MimeHandlerExec *mhExecFactory(RclConfig *cfg, const string& mtype, string& hs, vector cmdtoks; stringToStrings(cmdstr, cmdtoks); if (cmdtoks.empty()) { - LOGERR(("mhExecFactory: bad config line for [%s]: [%s]\n", - mtype.c_str(), hs.c_str())); + LOGERR("mhExecFactory: bad config line for [" << (mtype) << "]: [" << (hs) << "]\n" ); return 0; } 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 if (!stringlowercmp("python", *it) || !stringlowercmp("perl", *it)) { if (cmdtoks.size() < 2) { - LOGERR(("mhExecFactory: python/perl cmd: no script?. [%s]: [%s]\n", - mtype.c_str(), hs.c_str())); + LOGERR("mhExecFactory: python/perl cmd: no script?. [" << (mtype) << "]: [" << (hs) << "]\n" ); } vector::iterator it1(it); it1++; @@ -251,9 +244,7 @@ MimeHandlerExec *mhExecFactory(RclConfig *cfg, const string& mtype, string& hs, for (it = h->params.begin(); it != h->params.end(); it++) { scmd += string("[") + *it + "] "; } - LOGDEB(("mhExecFactory:mt [%s] cfgmt [%s] cfgcs [%s] cmd: [%s]\n", - mtype.c_str(), h->cfgFilterOutputMtype.c_str(), h->cfgFilterOutputCharset.c_str(), - scmd.c_str())); + LOGDEB("mhExecFactory:mt [" << (mtype) << "] cfgmt [" << (h->cfgFilterOutputMtype) << "] cfgcs [" << (h->cfgFilterOutputCharset) << "] cmd: [" << (scmd) << "]\n" ); #endif return h; @@ -263,8 +254,7 @@ MimeHandlerExec *mhExecFactory(RclConfig *cfg, const string& mtype, string& hs, RecollFilter *getMimeHandler(const string &mtype, RclConfig *cfg, bool filtertypes) { - LOGDEB(("getMimeHandler: mtype [%s] filtertypes %d\n", - mtype.c_str(), filtertypes)); + LOGDEB("getMimeHandler: mtype [" << (mtype) << "] filtertypes " << (filtertypes) << "\n" ); RecollFilter *h = 0; // 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); } -#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 ? h = getMimeHandlerFromCache(id); if (h != 0) goto out; - LOGDEB2(("getMimeHandler: %s not in cache\n", mtype.c_str())); + LOGDEB2("getMimeHandler: " << (mtype) << " not in cache\n" ); // Not in cache. if (internal) { @@ -319,14 +303,13 @@ RecollFilter *getMimeHandler(const string &mtype, RclConfig *cfg, // partly redundant with the localfields/rclaptg, but // better and the latter will probably go away at some // 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); goto out; } else if (!stringlowercmp("dll", handlertype)) { } else { if (cmdstr.empty()) { - LOGERR(("getMimeHandler: bad line for %s: %s\n", - mtype.c_str(), hs.c_str())); + LOGERR("getMimeHandler: bad line for " << (mtype) << ": " << (hs) << "\n" ); goto out; } if (!stringlowercmp("exec", handlertype)) { @@ -336,8 +319,7 @@ RecollFilter *getMimeHandler(const string &mtype, RclConfig *cfg, h = mhExecFactory(cfg, mtype, cmdstr, true, id); goto out; } else { - LOGERR(("getMimeHandler: bad line for %s: %s\n", - mtype.c_str(), hs.c_str())); + LOGERR("getMimeHandler: bad line for " << (mtype) << ": " << (hs) << "\n" ); goto out; } } @@ -380,3 +362,4 @@ bool canIntern(const std::string mtype, RclConfig *cfg) return false; return true; } + diff --git a/src/internfile/myhtmlparse.cpp b/src/internfile/myhtmlparse.cpp index f4272a4b..fcb3439f 100644 --- a/src/internfile/myhtmlparse.cpp +++ b/src/internfile/myhtmlparse.cpp @@ -37,7 +37,7 @@ #include "mimeparse.h" #include "smallut.h" #include "cancelcheck.h" -#include "debuglog.h" +#include "log.h" #include "transcode.h" static const string cstr_html_charset("charset"); @@ -193,7 +193,7 @@ MyHtmlParser::MyHtmlParser() 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, // so don't do it. If charset known, caller has converted text to utf-8, // and this is also how we translate entities @@ -261,14 +261,7 @@ void MyHtmlParser::decode_entities(string &s) void MyHtmlParser::process_text(const string &text) { - LOGDEB2(("process_text: title %d script %d style %d pre %d " - "pending_space %d txt [%s]\n", - in_title_tag, - in_script_tag, - in_style_tag, - in_pre_tag, - pending_space, - text.c_str())); + 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" ); CancelCheck::instance().checkCancel(); if (!in_script_tag && !in_style_tag) { @@ -307,7 +300,7 @@ MyHtmlParser::process_text(const string &text) bool MyHtmlParser::opening_tag(const string &tag) { - LOGDEB2(("opening_tag: [%s]\n", tag.c_str())); + LOGDEB2("opening_tag: [" << (tag) << "]\n" ); #if 0 cout << "TAG: " << tag << ": " << endl; map::const_iterator x; @@ -419,10 +412,7 @@ MyHtmlParser::opening_tag(const string &tag) charset = k->second; if (!charset.empty() && !samecharset(charset, fromcharset)) { - LOGDEB1(("Doc http-equiv charset '%s' " - "differs from dir deflt '%s'\n", - charset.c_str(), - fromcharset.c_str())); + LOGDEB1("Doc http-equiv charset '" << (charset) << "' differs from dir deflt '" << (fromcharset) << "'\n" ); throw false; } } @@ -436,10 +426,7 @@ MyHtmlParser::opening_tag(const string &tag) charset = newcharset; if (!charset.empty() && !samecharset(charset, fromcharset)) { - LOGDEB1(("Doc html5 charset '%s' " - "differs from dir deflt '%s'\n", - charset.c_str(), - fromcharset.c_str())); + LOGDEB1("Doc html5 charset '" << (charset) << "' differs from dir deflt '" << (fromcharset) << "'\n" ); throw false; } } @@ -494,7 +481,7 @@ MyHtmlParser::opening_tag(const string &tag) bool MyHtmlParser::closing_tag(const string &tag) { - LOGDEB2(("closing_tag: [%s]\n", tag.c_str())); + LOGDEB2("closing_tag: [" << (tag) << "]\n" ); if (tag.empty()) return true; switch (tag[0]) { case 'a': @@ -592,3 +579,4 @@ void MyHtmlParser::do_eof() { } + diff --git a/src/internfile/txtdcode.cpp b/src/internfile/txtdcode.cpp index 3bd95ff7..ecb4029c 100644 --- a/src/internfile/txtdcode.cpp +++ b/src/internfile/txtdcode.cpp @@ -18,7 +18,7 @@ #include "cstr.h" #include "transcode.h" #include "mimehandler.h" -#include "debuglog.h" +#include "log.h" #include "smallut.h" @@ -33,8 +33,7 @@ static bool alternate_decode(const string& in, string& out) { string lang = localelang(); string code = langtocode(lang); - LOGDEB(("RecollFilter::txtdcode: trying alternate decode from %s\n", - code.c_str())); + LOGDEB("RecollFilter::txtdcode: trying alternate decode from " << (code) << "\n" ); int ecnt; bool ret = transcode(in, out, code, cstr_utf8, &ecnt); return ecnt > 5 ? false : ret; @@ -43,22 +42,18 @@ static bool alternate_decode(const string& in, string& out) bool RecollFilter::txtdcode(const string& who) { if (m_metaData[cstr_dj_keymt].compare(cstr_textplain)) { - LOGERR(("%s::txtdcode: called on non txt/plain: %s\n", who.c_str(), - m_metaData[cstr_dj_keymt].c_str())); + LOGERR("" << (who) << "::txtdcode: called on non txt/plain: " << (m_metaData[cstr_dj_keymt]) << "\n" ); return false; } string& ocs = m_metaData[cstr_dj_keyorigcharset]; string& itext = m_metaData[cstr_dj_keycontent]; - LOGDEB1(("%s::txtdcode: %d bytes from [%s] to UTF-8\n", - who.c_str(), itext.size(), ocs.c_str())); + LOGDEB1("" << (who) << "::txtdcode: " << (itext.size()) << " bytes from [" << (ocs) << "] to UTF-8\n" ); int ecnt; string otext; bool ret = transcode(itext, otext, ocs, cstr_utf8, &ecnt); if (!ret || ecnt > int(itext.size() / 100)) { - LOGERR(("%s::txtdcode: transcode %d bytes to UTF-8 failed " - "for input charset [%s] ret %d ecnt %d\n", - who.c_str(), itext.size(), ocs.c_str(), ret, ecnt)); + LOGERR("" << (who) << "::txtdcode: transcode " << (itext.size()) << " bytes to UTF-8 failed for input charset [" << (ocs) << "] ret " << (ret) << " ecnt " << (ecnt) << "\n" ); if (samecharset(ocs, cstr_utf8)) { ret = alternate_decode(itext, otext); @@ -66,7 +61,7 @@ bool RecollFilter::txtdcode(const string& who) ret = false; } if (!ret) { - LOGDEB(("txtdcode: failed. Doc is not text?\n")); + LOGDEB("txtdcode: failed. Doc is not text?\n" ); itext.erase(); return false; } @@ -77,3 +72,4 @@ bool RecollFilter::txtdcode(const string& who) return true; } + diff --git a/src/internfile/uncomp.cpp b/src/internfile/uncomp.cpp index 1962be97..ffcd9ae0 100644 --- a/src/internfile/uncomp.cpp +++ b/src/internfile/uncomp.cpp @@ -24,7 +24,7 @@ #include #include "uncomp.h" -#include "debuglog.h" +#include "log.h" #include "smallut.h" #include "execmd.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 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; } @@ -66,14 +66,12 @@ bool Uncomp::uncompressfile(const string& ifn, int pc; long long availmbs; if (!fsocc(m_dir->dirname(), &pc, &availmbs)) { - LOGERR(("uncompressfile: can't retrieve avail space for %s\n", - m_dir->dirname())); + LOGERR("uncompressfile: can't retrieve avail space for " << (m_dir->dirname()) << "\n" ); // Hope for the best } else { long long fsize = path_filesize(ifn); if (fsize < 0) { - LOGERR(("uncompressfile: stat input file %s errno %d\n", - ifn.c_str(), errno)); + LOGERR("uncompressfile: stat input file " << (ifn) << " errno " << (errno) << "\n" ); return false; } // 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); if (availmbs < 2 * filembs + 1) { - LOGERR(("uncompressfile. %s MBs available in %s not enough " - "to uncompress %s of size %s mbs\n", - lltodecstr(availmbs).c_str(), m_dir->dirname(), - ifn.c_str(), lltodecstr(filembs).c_str())); + LOGERR("uncompressfile. " << (lltodecstr(availmbs)) << " MBs available in " << (m_dir->dirname()) << " not enough to uncompress " << (ifn) << " of size " << (lltodecstr(filembs)) << " mbs\n" ); return false; } } @@ -112,10 +107,9 @@ bool Uncomp::uncompressfile(const string& ifn, ExecCmd ex; int status = ex.doexec(cmd, args, 0, &tfile); if (status || tfile.empty()) { - LOGERR(("uncompressfile: doexec: failed for [%s] status 0x%x\n", - ifn.c_str(), status)); + LOGERR("uncompressfile: doexec: failed for [" << (ifn) << "] status 0x" << (status) << "\n" ); if (!m_dir->wipe()) { - LOGERR(("uncompressfile: wipedir failed\n")); + LOGERR("uncompressfile: wipedir failed\n" ); } return false; } @@ -139,3 +133,4 @@ Uncomp::~Uncomp() } } + diff --git a/src/php/recoll/recoll.cpp b/src/php/recoll/recoll.cpp index 6d948d35..6c454282 100644 --- a/src/php/recoll/recoll.cpp +++ b/src/php/recoll/recoll.cpp @@ -36,7 +36,7 @@ #include "rclconfig.h" #include "pathut.h" #include "rclinit.h" -#include "debuglog.h" +#include "log.h" #include "wasatorcl.h" #include "internfile.h" #include "wipedir.h" @@ -238,3 +238,4 @@ extern "C" { ZEND_GET_MODULE(recoll) } #endif + diff --git a/src/python/recoll/pyrclextract.cpp b/src/python/recoll/pyrclextract.cpp index 7cd913c7..8f632e81 100644 --- a/src/python/recoll/pyrclextract.cpp +++ b/src/python/recoll/pyrclextract.cpp @@ -25,7 +25,7 @@ #include using namespace std; -#include "debuglog.h" +#include "log.h" #include "rcldoc.h" #include "internfile.h" #include "rclconfig.h" @@ -49,7 +49,7 @@ typedef struct { static void Extractor_dealloc(rclx_ExtractorObject *self) { - LOGDEB(("Extractor_dealloc\n")); + LOGDEB("Extractor_dealloc\n" ); delete self->xtr; Py_TYPE(self)->tp_free((PyObject*)self); } @@ -57,7 +57,7 @@ Extractor_dealloc(rclx_ExtractorObject *self) static PyObject * Extractor_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - LOGDEB(("Extractor_new\n")); + LOGDEB("Extractor_new\n" ); rclx_ExtractorObject *self = (rclx_ExtractorObject *)type->tp_alloc(type, 0); if (self == 0) @@ -70,7 +70,7 @@ Extractor_new(PyTypeObject *type, PyObject *args, PyObject *kwds) static int Extractor_init(rclx_ExtractorObject *self, PyObject *args, PyObject *kwargs) { - LOGDEB(("Extractor_init\n")); + LOGDEB("Extractor_init\n" ); static const char* kwlist[] = {"doc", NULL}; PyObject *pdobj; @@ -99,7 +99,7 @@ static PyObject * Extractor_textextract(rclx_ExtractorObject* self, PyObject *args, PyObject *kwargs) { - LOGDEB(("Extractor_textextract\n")); + LOGDEB("Extractor_textextract\n" ); static const char* kwlist[] = {"ipath", NULL}; char *sipath = 0; @@ -153,7 +153,7 @@ static PyObject * Extractor_idoctofile(rclx_ExtractorObject* self, PyObject *args, PyObject *kwargs) { - LOGDEB(("Extractor_idoctofile\n")); + LOGDEB("Extractor_idoctofile\n" ); static const char* kwlist[] = {"ipath", "mimetype", "ofilename", NULL}; char *sipath = 0; char *smt = 0; @@ -359,3 +359,4 @@ initrclextract(void) return module; #endif } + diff --git a/src/python/recoll/pyrecoll.cpp b/src/python/recoll/pyrecoll.cpp index 5c47c6b9..ffa1cd44 100644 --- a/src/python/recoll/pyrecoll.cpp +++ b/src/python/recoll/pyrecoll.cpp @@ -34,7 +34,7 @@ using namespace std; #include "pathut.h" #include "rclutil.h" #include "wasatorcl.h" -#include "debuglog.h" +#include "log.h" #include "pathut.h" #include "plaintorich.h" #include "hldata.h" @@ -62,8 +62,7 @@ typedef struct { static void SearchData_dealloc(recoll_SearchDataObject *self) { - LOGDEB(("SearchData_dealloc. Releasing. Count before: %d\n", - self->sd.use_count())); + LOGDEB("SearchData_dealloc. Releasing. Count before: " << (self->sd.use_count()) << "\n" ); self->sd.reset(); Py_TYPE(self)->tp_free((PyObject*)self); } @@ -71,7 +70,7 @@ SearchData_dealloc(recoll_SearchDataObject *self) static PyObject * SearchData_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - LOGDEB(("SearchData_new\n")); + LOGDEB("SearchData_new\n" ); recoll_SearchDataObject *self; self = (recoll_SearchDataObject *)type->tp_alloc(type, 0); @@ -90,7 +89,7 @@ PyDoc_STRVAR(doc_SearchDataObject, static int SearchData_init(recoll_SearchDataObject *self, PyObject *args, PyObject *kwargs) { - LOGDEB(("SearchData_init\n")); + LOGDEB("SearchData_init\n" ); static const char* kwlist[] = {"type", "stemlang", NULL}; char *stp = 0; char *steml = 0; @@ -180,9 +179,9 @@ static PyObject * SearchData_addclause(recoll_SearchDataObject* self, PyObject *args, PyObject *kwargs) { - LOGDEB0(("SearchData_addclause\n")); + LOGDEB0("SearchData_addclause\n" ); if (!self->sd) { - LOGERR(("SearchData_addclause: not init??\n")); + LOGERR("SearchData_addclause: not init??\n" ); PyErr_SetString(PyExc_AttributeError, "sd"); return 0; } @@ -294,7 +293,7 @@ SearchData_addclause(recoll_SearchDataObject* self, PyObject *args, static void Doc_dealloc(recoll_DocObject *self) { - LOGDEB(("Doc_dealloc\n")); + LOGDEB("Doc_dealloc\n" ); if (self->doc) the_docs.erase(self->doc); deleteZ(self->doc); @@ -304,7 +303,7 @@ Doc_dealloc(recoll_DocObject *self) static PyObject * Doc_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - LOGDEB(("Doc_new\n")); + LOGDEB("Doc_new\n" ); recoll_DocObject *self; self = (recoll_DocObject *)type->tp_alloc(type, 0); @@ -318,7 +317,7 @@ Doc_new(PyTypeObject *type, PyObject *args, PyObject *kwds) static int Doc_init(recoll_DocObject *self, PyObject *, PyObject *) { - LOGDEB(("Doc_init\n")); + LOGDEB("Doc_init\n" ); if (self->doc) the_docs.erase(self->doc); delete self->doc; @@ -340,7 +339,7 @@ PyDoc_STRVAR(doc_Doc_getbinurl, static PyObject * Doc_getbinurl(recoll_DocObject *self) { - LOGDEB0(("Doc_getbinurl\n")); + LOGDEB0("Doc_getbinurl\n" ); if (self->doc == 0 || the_docs.find(self->doc) == the_docs.end()) { PyErr_SetString(PyExc_AttributeError, "doc"); @@ -359,7 +358,7 @@ PyDoc_STRVAR(doc_Doc_setbinurl, static PyObject * Doc_setbinurl(recoll_DocObject *self, PyObject *value) { - LOGDEB0(("Doc_setbinurl\n")); + LOGDEB0("Doc_setbinurl\n" ); if (self->doc == 0 || the_docs.find(self->doc) == the_docs.end()) { PyErr_SetString(PyExc_AttributeError, "doc??"); @@ -381,7 +380,7 @@ PyDoc_STRVAR(doc_Doc_keys, static PyObject * Doc_keys(recoll_DocObject *self) { - LOGDEB0(("Doc_keys\n")); + LOGDEB0("Doc_keys\n" ); if (self->doc == 0 || the_docs.find(self->doc) == the_docs.end()) { PyErr_SetString(PyExc_AttributeError, "doc"); @@ -406,7 +405,7 @@ PyDoc_STRVAR(doc_Doc_items, static PyObject * Doc_items(recoll_DocObject *self) { - LOGDEB0(("Doc_items\n")); + LOGDEB0("Doc_items\n" ); if (self->doc == 0 || the_docs.find(self->doc) == the_docs.end()) { PyErr_SetString(PyExc_AttributeError, "doc"); @@ -436,7 +435,7 @@ PyDoc_STRVAR(doc_Doc_get, static PyObject * Doc_get(recoll_DocObject *self, PyObject *args) { - LOGDEB0(("Doc_get\n")); + LOGDEB0("Doc_get\n" ); char *sutf8 = 0; // needs freeing if (!PyArg_ParseTuple(args, "es:Doc_get", "utf-8", &sutf8)) { @@ -490,7 +489,7 @@ static PyMethodDef Doc_methods[] = { static PyObject * 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()) { PyErr_SetString(PyExc_AttributeError, "doc"); return 0; @@ -505,7 +504,7 @@ Doc_getattro(recoll_DocObject *self, PyObject *nameobj) if (PyUnicode_Check(nameobj)) { utf8o = PyUnicode_AsUTF8String(nameobj); 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??"); Py_RETURN_NONE; } @@ -597,7 +596,7 @@ Doc_getattro(recoll_DocObject *self, PyObject *nameobj) } 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 PyUnicode_Decode(value.c_str(), value.size(), "utf-8", "replace"); @@ -636,15 +635,14 @@ Doc_setattr(recoll_DocObject *self, char *name, PyObject *value) PyObject* putf8 = PyUnicode_AsUTF8String(value); if (putf8 == 0) { - LOGERR(("Doc_setmeta: encoding to utf8 failed\n")); + LOGERR("Doc_setmeta: encoding to utf8 failed\n" ); PyErr_SetString(PyExc_AttributeError, "value??"); return -1; } char* uvalue = PyBytes_AsString(putf8); string key = rclconfig->fieldQCanon(string(name)); - LOGDEB0(("Doc_setattr: doc %p [%s] (%s) -> [%s]\n", - self->doc, key.c_str(), name, uvalue)); + LOGDEB0("Doc_setattr: doc " << (self->doc) << " [" << (key) << "] (" << (name) << ") -> [" << (uvalue) << "]\n" ); // We set the value in the meta array in all cases. Good idea ? or do it // only for fields without a dedicated Doc:: entry? @@ -804,7 +802,7 @@ PyDoc_STRVAR(doc_Query_close, static PyObject * Query_close(recoll_QueryObject *self) { - LOGDEB(("Query_close\n")); + LOGDEB("Query_close\n" ); if (self->query) { the_queries.erase(self->query); deleteZ(self->query); @@ -820,7 +818,7 @@ Query_close(recoll_QueryObject *self) static void Query_dealloc(recoll_QueryObject *self) { - LOGDEB(("Query_dealloc\n")); + LOGDEB("Query_dealloc\n" ); PyObject *ret = Query_close(self); Py_DECREF(ret); Py_TYPE(self)->tp_free((PyObject*)self); @@ -829,7 +827,7 @@ Query_dealloc(recoll_QueryObject *self) static PyObject * Query_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { - LOGDEB(("Query_new\n")); + LOGDEB("Query_new\n" ); recoll_QueryObject *self; self = (recoll_QueryObject *)type->tp_alloc(type, 0); @@ -851,7 +849,7 @@ Query_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) static int Query_init(recoll_QueryObject *self, PyObject *, PyObject *) { - LOGDEB(("Query_init\n")); + LOGDEB("Query_init\n" ); if (self->query) the_queries.erase(self->query); @@ -879,7 +877,7 @@ PyDoc_STRVAR(doc_Query_sortby, static PyObject * Query_sortby(recoll_QueryObject* self, PyObject *args, PyObject *kwargs) { - LOGDEB0(("Query_sortby\n")); + LOGDEB0("Query_sortby\n" ); static const char *kwlist[] = {"field", "ascending", NULL}; char *sfield = 0; PyObject *ascobj = 0; @@ -913,7 +911,7 @@ PyDoc_STRVAR(doc_Query_execute, static PyObject * 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}; char *sutf8 = 0; // needs freeing char *sstemlang = 0; @@ -936,8 +934,7 @@ Query_execute(recoll_QueryObject* self, PyObject *args, PyObject *kwargs) PyMem_Free(sstemlang); } - LOGDEB0(("Query_execute: [%s] dostem %d stemlang [%s]\n", utf8.c_str(), - dostem, stemlang.c_str())); + LOGDEB0("Query_execute: [" << (utf8) << "] dostem " << (dostem) << " stemlang [" << (stemlang) << "]\n" ); if (self->query == 0 || the_queries.find(self->query) == the_queries.end()) { @@ -974,7 +971,7 @@ PyDoc_STRVAR(doc_Query_executesd, static PyObject * Query_executesd(recoll_QueryObject* self, PyObject *args, PyObject *kwargs) { - LOGDEB0(("Query_executeSD\n")); + LOGDEB0("Query_executeSD\n" ); static const char *kwlist[] = {"searchdata", NULL}; recoll_SearchDataObject *pysd = 0; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:Query_execute", @@ -1016,7 +1013,7 @@ PyDoc_STRVAR(doc_Query_fetchone, static PyObject * Query_fetchone(PyObject *_self) { - LOGDEB0(("Query_fetchone/next\n")); + LOGDEB0("Query_fetchone/next\n" ); recoll_QueryObject* self = (recoll_QueryObject*)_self; if (self->query == 0 || @@ -1057,7 +1054,7 @@ PyDoc_STRVAR(doc_Query_fetchmany, static PyObject * Query_fetchmany(recoll_QueryObject* self, PyObject *args, PyObject *kwargs) { - LOGDEB0(("Query_fetchmany\n")); + LOGDEB0("Query_fetchmany\n" ); static const char *kwlist[] = {"size", NULL}; int size = 0; @@ -1107,7 +1104,7 @@ PyDoc_STRVAR(doc_Query_scroll, static PyObject * Query_scroll(recoll_QueryObject* self, PyObject *args, PyObject *kwargs) { - LOGDEB0(("Query_scroll\n")); + LOGDEB0("Query_scroll\n" ); static const char *kwlist[] = {"position", "mode", NULL}; int pos = 0; char *smode = 0; @@ -1194,7 +1191,7 @@ public: static PyObject * 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}; char *sutf8 = 0; // needs freeing int ishtml = 0; @@ -1216,7 +1213,7 @@ Query_highlight(recoll_QueryObject* self, PyObject *args, PyObject *kwargs) ishtml = 1; if (eolbrobj && !PyObject_IsTrue(eolbrobj)) eolbr = 0; - LOGDEB0(("Query_highlight: ishtml %d\n", ishtml)); + LOGDEB0("Query_highlight: ishtml " << (ishtml) << "\n" ); if (self->query == 0 || the_queries.find(self->query) == the_queries.end()) { @@ -1254,7 +1251,7 @@ PyDoc_STRVAR(doc_Query_makedocabstract, static PyObject * Query_makedocabstract(recoll_QueryObject* self, PyObject *args,PyObject *kwargs) { - LOGDEB0(("Query_makeDocAbstract\n")); + LOGDEB0("Query_makeDocAbstract\n" ); static const char *kwlist[] = {"doc", "methods", NULL}; recoll_DocObject *pydoc = 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()) { - LOGERR(("Query_makeDocAbstract: doc not found %p\n", pydoc->doc)); + LOGERR("Query_makeDocAbstract: doc not found " << (pydoc->doc) << "\n" ); PyErr_SetString(PyExc_AttributeError, "doc"); return 0; } 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"); return 0; } @@ -1324,7 +1321,7 @@ PyDoc_STRVAR(doc_Query_getxquery, static 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 || the_queries.find(self->query) == the_queries.end()) { @@ -1352,7 +1349,7 @@ PyDoc_STRVAR(doc_Query_getgroups, static PyObject * Query_getgroups(recoll_QueryObject* self, PyObject *, PyObject *) { - LOGDEB0(("Query_getgroups\n")); + LOGDEB0("Query_getgroups\n" ); if (self->query == 0 || the_queries.find(self->query) == the_queries.end()) { @@ -1497,7 +1494,7 @@ typedef struct recoll_DbObject { static PyObject * Db_close(recoll_DbObject *self) { - LOGDEB(("Db_close. self %p\n", self)); + LOGDEB("Db_close. self " << (self) << "\n" ); if (self->db) { the_dbs.erase(self->db); delete self->db; @@ -1509,7 +1506,7 @@ Db_close(recoll_DbObject *self) static void Db_dealloc(recoll_DbObject *self) { - LOGDEB(("Db_dealloc\n")); + LOGDEB("Db_dealloc\n" ); PyObject *ret = Db_close(self); Py_DECREF(ret); Py_TYPE(self)->tp_free((PyObject*)self); @@ -1518,7 +1515,7 @@ Db_dealloc(recoll_DbObject *self) static PyObject * Db_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - LOGDEB2(("Db_new\n")); + LOGDEB2("Db_new\n" ); recoll_DbObject *self; self = (recoll_DbObject *)type->tp_alloc(type, 0); @@ -1550,7 +1547,7 @@ Db_init(recoll_DbObject *self, PyObject *args, PyObject *kwargs) } else { rclconfig = recollinit(0, 0, reason, 0); } - LOGDEB(("Db_init\n")); + LOGDEB("Db_init\n" ); if (rclconfig == 0) { PyErr_SetString(PyExc_EnvironmentError, reason.c_str()); @@ -1566,7 +1563,7 @@ Db_init(recoll_DbObject *self, PyObject *args, PyObject *kwargs) delete self->db; self->db = new Rcl::Db(rclconfig); 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"); return -1; } @@ -1609,9 +1606,9 @@ Db_init(recoll_DbObject *self, PyObject *args, PyObject *kwargs) static PyObject * 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()) { - LOGERR(("Db_query: db not found %p\n", self->db)); + LOGERR("Db_query: db not found " << (self->db) << "\n" ); PyErr_SetString(PyExc_AttributeError, "db"); return 0; } @@ -1630,18 +1627,18 @@ Db_query(recoll_DbObject* self) static PyObject * Db_setAbstractParams(recoll_DbObject *self, PyObject *args, PyObject *kwargs) { - LOGDEB0(("Db_setAbstractParams\n")); + LOGDEB0("Db_setAbstractParams\n" ); static const char *kwlist[] = {"maxchars", "contextwords", NULL}; int ctxwords = -1, maxchars = -1; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ii", (char**)kwlist, &maxchars, &ctxwords)) return 0; 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"); 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); Py_RETURN_NONE; } @@ -1649,7 +1646,7 @@ Db_setAbstractParams(recoll_DbObject *self, PyObject *args, PyObject *kwargs) static PyObject * Db_makeDocAbstract(recoll_DbObject* self, PyObject *args) { - LOGDEB0(("Db_makeDocAbstract\n")); + LOGDEB0("Db_makeDocAbstract\n" ); recoll_DocObject *pydoc = 0; recoll_QueryObject *pyquery = 0; if (!PyArg_ParseTuple(args, "O!O!:Db_makeDocAbstract", @@ -1658,18 +1655,18 @@ Db_makeDocAbstract(recoll_DbObject* self, PyObject *args) return 0; } 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"); return 0; } 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"); return 0; } if (pyquery->query == 0 || 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"); return 0; } @@ -1694,7 +1691,7 @@ PyDoc_STRVAR(doc_Db_termMatch, static PyObject * 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", "casesens", "diacsens", "lang", NULL}; char *tp = 0; @@ -1717,7 +1714,7 @@ Db_termMatch(recoll_DbObject* self, PyObject *args, PyObject *kwargs) return 0; 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"); goto out; } @@ -1742,7 +1739,7 @@ Db_termMatch(recoll_DbObject* self, PyObject *args, PyObject *kwargs) if (!self->db->termMatch(typ_sens, lang ? lang : "english", 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"); goto out; } @@ -1763,7 +1760,7 @@ out: static PyObject * Db_needUpdate(recoll_DbObject* self, PyObject *args, PyObject *kwds) { - LOGDEB0(("Db_needUpdate\n")); + LOGDEB0("Db_needUpdate\n" ); char *udi = 0; // needs freeing char *sig = 0; // needs freeing if (!PyArg_ParseTuple(args, "eses:Db_needUpdate", @@ -1771,7 +1768,7 @@ Db_needUpdate(recoll_DbObject* self, PyObject *args, PyObject *kwds) return 0; } 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"); PyMem_Free(udi); PyMem_Free(sig); @@ -1786,13 +1783,13 @@ Db_needUpdate(recoll_DbObject* self, PyObject *args, PyObject *kwds) static PyObject * Db_delete(recoll_DbObject* self, PyObject *args, PyObject *kwds) { - LOGDEB0(("Db_delete\n")); + LOGDEB0("Db_delete\n" ); char *udi = 0; // needs freeing if (!PyArg_ParseTuple(args, "es:Db_delete", "utf-8", &udi)) { return 0; } 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"); PyMem_Free(udi); return 0; @@ -1805,9 +1802,9 @@ Db_delete(recoll_DbObject* self, PyObject *args, PyObject *kwds) static PyObject * 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()) { - LOGERR(("Db_purge: db not found %p\n", self->db)); + LOGERR("Db_purge: db not found " << (self->db) << "\n" ); PyErr_SetString(PyExc_AttributeError, "db"); return 0; } @@ -1818,7 +1815,7 @@ Db_purge(recoll_DbObject* self) static PyObject * Db_addOrUpdate(recoll_DbObject* self, PyObject *args, PyObject *) { - LOGDEB0(("Db_addOrUpdate\n")); + LOGDEB0("Db_addOrUpdate\n" ); char *sudi = 0; // needs freeing char *sparent_udi = 0; // needs freeing recoll_DocObject *pydoc; @@ -1834,17 +1831,17 @@ Db_addOrUpdate(recoll_DbObject* self, PyObject *args, PyObject *) PyMem_Free(sparent_udi); 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"); return 0; } 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"); return 0; } 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"); return 0; } @@ -1959,7 +1956,7 @@ static PyTypeObject recoll_DbType = { static PyObject * recoll_connect(PyObject *self, PyObject *args, PyObject *kwargs) { - LOGDEB2(("recoll_connect\n")); + LOGDEB2("recoll_connect\n" ); recoll_DbObject *db = (recoll_DbObject *) PyObject_Call((PyObject *)&recoll_DbType, args, kwargs); return (PyObject *)db; @@ -2094,3 +2091,4 @@ initrecoll(void) return module; #endif } + diff --git a/src/python/recoll/setup.py.in b/src/python/recoll/setup.py.in index ba8ebabd..eb49217e 100644 --- a/src/python/recoll/setup.py.in +++ b/src/python/recoll/setup.py.in @@ -18,6 +18,7 @@ if "CYGWIN" in os.environ: else: libraries = ['recoll'] +extra_compile_args = ['-std=c++11'] if 'libdir' in os.environ and os.environ['libdir'] != "": 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, 'unac') ], + extra_compile_args = extra_compile_args, libraries = libraries, library_dirs = library_dirs, runtime_library_dirs = runtime_library_dirs, @@ -57,6 +59,7 @@ module2 = Extension('rclextract', os.path.join(top, 'internfile'), os.path.join(top, 'rcldb'), ], + extra_compile_args = extra_compile_args, libraries = libraries, library_dirs = library_dirs, runtime_library_dirs = runtime_library_dirs, diff --git a/src/qtgui/advsearch_w.cpp b/src/qtgui/advsearch_w.cpp index 1233f9a3..17d6a86f 100644 --- a/src/qtgui/advsearch_w.cpp +++ b/src/qtgui/advsearch_w.cpp @@ -38,7 +38,7 @@ using namespace std; #include "recoll.h" #include "rclconfig.h" -#include "debuglog.h" +#include "log.h" #include "searchdata.h" #include "guiutils.h" #include "rclhelp.h" @@ -443,7 +443,7 @@ void AdvSearch::runSearch() entries.push_back(subtreeCMB->currentText()); entries.sort(); entries.unique(); - LOGDEB(("Subtree list now has %d entries\n", entries.size())); + LOGDEB("Subtree list now has " << (entries.size()) << " entries\n" ); subtreeCMB->clear(); for (list::iterator it = entries.begin(); it != entries.end(); it++) { @@ -479,7 +479,7 @@ void AdvSearch::fromSearch(STD_SHARED_PTR sdata) for (unsigned int i = 0; i < sdata->m_query.size(); i++) { // Set fields from clause if (sdata->m_query[i]->getTp() == SCLT_SUB) { - LOGERR(("AdvSearch::fromSearch: SUB clause found !\n")); + LOGERR("AdvSearch::fromSearch: SUB clause found !\n" ); continue; } if (sdata->m_query[i]->getTp() == SCLT_PATH) { @@ -576,3 +576,4 @@ void AdvSearch::slotHistoryPrev() fromSearch(sd); } + diff --git a/src/qtgui/advshist.cpp b/src/qtgui/advshist.cpp index 26b388cc..cad7cad3 100644 --- a/src/qtgui/advshist.cpp +++ b/src/qtgui/advshist.cpp @@ -19,7 +19,7 @@ #include "advshist.h" #include "guiutils.h" -#include "debuglog.h" +#include "log.h" #include "xmltosd.h" using namespace std; @@ -94,3 +94,4 @@ void AdvSearchHist::clear() { g_dynconf->eraseAll(advSearchHistSk); } + diff --git a/src/qtgui/confgui/confgui.cpp b/src/qtgui/confgui/confgui.cpp index f81665f4..94afdc86 100644 --- a/src/qtgui/confgui/confgui.cpp +++ b/src/qtgui/confgui/confgui.cpp @@ -40,7 +40,7 @@ #include "confgui.h" #include "smallut.h" -#include "debuglog.h" +#include "log.h" #include "rcldb.h" #include "guiutils.h" @@ -376,7 +376,7 @@ void ConfParamSLW::showInputDialog() void ConfParamSLW::listToConf() { list 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++) { // General parameters are encoded as utf-8. File names as // local8bit There is no hope for 8bit file names anyway @@ -423,7 +423,7 @@ void ConfParamSLW::deleteSelected() } for (vector::reverse_iterator it = idxes.rbegin(); it != idxes.rend(); it++) { - LOGDEB0(("deleteSelected: %d was selected\n", *it)); + LOGDEB0("deleteSelected: " << (*it) << " was selected\n" ); QListWidgetItem *item = m_lb->takeItem(*it); emit entryDeleted(item->text()); delete item; @@ -476,3 +476,4 @@ void ConfParamCSLW::showInputDialog() } } // Namespace confgui + diff --git a/src/qtgui/confgui/confguiindex.cpp b/src/qtgui/confgui/confguiindex.cpp index 4ccdc67c..860a8e1b 100644 --- a/src/qtgui/confgui/confguiindex.cpp +++ b/src/qtgui/confgui/confguiindex.cpp @@ -35,7 +35,7 @@ using std::list; #include "recoll.h" #include "confguiindex.h" #include "smallut.h" -#include "debuglog.h" +#include "log.h" #include "rcldb.h" #include "conflinkrcl.h" #include "execmd.h" @@ -68,9 +68,9 @@ ConfIndexW::ConfIndexW(QWidget *parent, RclConfig *config) void ConfIndexW::acceptChanges() { - LOGDEB(("ConfIndexW::acceptChanges()\n")); + LOGDEB("ConfIndexW::acceptChanges()\n" ); if (!m_conf) { - LOGERR(("ConfIndexW::acceptChanges: no config\n")); + LOGERR("ConfIndexW::acceptChanges: no config\n" ); return; } // Let the changes to disk @@ -88,7 +88,7 @@ void ConfIndexW::acceptChanges() void ConfIndexW::rejectChanges() { - LOGDEB(("ConfIndexW::rejectChanges()\n")); + LOGDEB("ConfIndexW::rejectChanges()\n" ); // Discard local changes. delete m_conf; m_conf = 0; @@ -477,7 +477,7 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, ConfNull *config, string cmd = "iconv"; int status = ex.doexec(cmd, args, 0, &icout); 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, ","); list ccsets; @@ -579,7 +579,7 @@ void ConfSubPanelW::reloadAll() void ConfSubPanelW::subDirChanged(QListWidgetItem *current, QListWidgetItem *) { - LOGDEB(("ConfSubPanelW::subDirChanged\n")); + LOGDEB("ConfSubPanelW::subDirChanged\n" ); if (current == 0 || current->text() == "") { m_sk = ""; @@ -588,13 +588,13 @@ void ConfSubPanelW::subDirChanged(QListWidgetItem *current, QListWidgetItem *) m_sk = (const char *) current->text().toUtf8(); m_groupbox->setTitle(current->text()); } - LOGDEB(("ConfSubPanelW::subDirChanged: now [%s]\n", m_sk.c_str())); + LOGDEB("ConfSubPanelW::subDirChanged: now [" << (m_sk) << "]\n" ); reloadAll(); } void ConfSubPanelW::subDirDeleted(QString sbd) { - LOGDEB(("ConfSubPanelW::subDirDeleted(%s)\n", (const char *)sbd.toUtf8())); + LOGDEB("ConfSubPanelW::subDirDeleted(" << ((const char *)sbd.toUtf8()) << ")\n" ); if (sbd == "") { // Can't do this, have to reinsert it QTimer::singleShot(0, this, SLOT(restoreEmpty())); @@ -606,8 +606,9 @@ void ConfSubPanelW::subDirDeleted(QString sbd) void ConfSubPanelW::restoreEmpty() { - LOGDEB(("ConfSubPanelW::restoreEmpty()\n")); + LOGDEB("ConfSubPanelW::restoreEmpty()\n" ); m_subdirs->getListBox()->insertItem(0, ""); } } // Namespace confgui + diff --git a/src/qtgui/confgui/conflinkrcl.h b/src/qtgui/confgui/conflinkrcl.h index 34f8155d..c5554887 100644 --- a/src/qtgui/confgui/conflinkrcl.h +++ b/src/qtgui/confgui/conflinkrcl.h @@ -25,7 +25,7 @@ */ #include "confgui.h" #include "conftree.h" -#include "debuglog.h" +#include "log.h" namespace confgui { @@ -42,10 +42,10 @@ public: { if (!m_conf) 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:""); if (!ret) - LOGERR(("Value set failed\n")); + LOGERR("Value set failed\n" ); return ret; } virtual bool get(string& val) @@ -53,9 +53,7 @@ public: if (!m_conf) return false; bool ret = m_conf->get(m_nm, val, m_sk?*m_sk:""); - LOGDEB1(("ConfLinkRcl::get: [%s] sk [%s] -> [%s]\n", - m_nm.c_str(), m_sk?m_sk->c_str():"", - ret ? val.c_str() : "no value")); + LOGDEB1("ConfLinkRcl::get: [" << (m_nm) << "] sk [" << (m_sk?m_sk:"") << "] -> [" << (ret ? val : "no value") << "]\n" ); return ret; } private: @@ -67,3 +65,4 @@ private: } // Namespace confgui #endif /* _CONFLINKRCL_H_INCLUDED_ */ + diff --git a/src/qtgui/confgui/main.cpp b/src/qtgui/confgui/main.cpp index e62efbc9..8731bcde 100644 --- a/src/qtgui/confgui/main.cpp +++ b/src/qtgui/confgui/main.cpp @@ -39,7 +39,7 @@ using namespace std; #include "pathut.h" #include "confguiindex.h" -#include "debuglog.h" +#include "log.h" #include "rclconfig.h" #include "execmd.h" #include "conflinkrcl.h" @@ -89,9 +89,6 @@ int main(int argc, char **argv) argc--; argv++; } - DebugLog::getdbl()->setloglevel(DEBDEB1); - DebugLog::setfilename("stderr"); - string a_config = "tstconfdir"; config = new RclConfig(&a_config); if (config == 0 || !config->ok()) { @@ -130,3 +127,4 @@ int main(int argc, char **argv) // Let's go return app.exec(); } + diff --git a/src/qtgui/fragbuts.cpp b/src/qtgui/fragbuts.cpp index 269320d4..a07e643b 100644 --- a/src/qtgui/fragbuts.cpp +++ b/src/qtgui/fragbuts.cpp @@ -34,7 +34,7 @@ #include "pathut.h" #include "smallut.h" #include "recoll.h" -#include "debuglog.h" +#include "log.h" #include "readfile.h" #include "copyfile.h" @@ -158,7 +158,7 @@ FragButs::FragButs(QWidget* parent) QMessageBox::warning(0, "Recoll", tr("%1 not found.").arg( 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; } FragButsParser parser(this, m_buttons); @@ -199,7 +199,7 @@ bool FragButs::isStale(time_t *reftime) void FragButs::onButtonClicked(bool on) { - LOGDEB(("FragButs::onButtonClicked: [%d]\n", int(on))); + LOGDEB("FragButs::onButtonClicked: [" << (int(on)) << "]\n" ); emit fragmentsChanged(); } @@ -208,8 +208,9 @@ void FragButs::getfrags(std::vector& frags) for (vector::iterator it = m_buttons.begin(); it != m_buttons.end(); it++) { 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); } } } + diff --git a/src/qtgui/guiutils.cpp b/src/qtgui/guiutils.cpp index 1855c438..d682261b 100644 --- a/src/qtgui/guiutils.cpp +++ b/src/qtgui/guiutils.cpp @@ -20,7 +20,7 @@ #include #include "recoll.h" -#include "debuglog.h" +#include "log.h" #include "smallut.h" #include "guiutils.h" #include "pathut.h" @@ -73,7 +73,7 @@ static bool havereadsettings; void rwSettings(bool writing) { - LOGDEB1(("rwSettings: write %d\n", int(writing))); + LOGDEB1("rwSettings: write " << (int(writing)) << "\n" ); if (writing && !havereadsettings) return; QSettings settings("Recoll.org", "recoll"); @@ -312,12 +312,11 @@ void rwSettings(bool writing) continue; bool 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; } if (stripped != o_index_stripchars) { - LOGERR(("Incompatible character stripping: [%s]\n", - dbdir.c_str())); + LOGERR("Incompatible character stripping: [" << (dbdir) << "]\n" ); continue; } prefs.allExtraDbs.push_back(dbdir); @@ -334,8 +333,7 @@ void rwSettings(bool writing) bool stripped; if (!Rcl::Db::testDbDir(*it, &stripped) || stripped != o_index_stripchars) { - LOGINFO(("Not a Xapian index or char stripping differs: [%s]\n", - it->c_str())); + LOGINFO("Not a Xapian index or char stripping differs: [" << *it << "]\n" ); it = prefs.activeExtraDbs.erase(it); } else { it++; @@ -359,8 +357,7 @@ void rwSettings(bool writing) bool strpd; if (!Rcl::Db::testDbDir(dbdir, &strpd) || strpd != o_index_stripchars) { - LOGERR(("Not a Xapian dir or diff. char stripping: [%s]\n", - dbdir.c_str())); + LOGERR("Not a Xapian dir or diff. char stripping: [" << (dbdir) << "]\n" ); continue; } prefs.activeExtraDbs.push_back(dbdir); @@ -414,3 +411,4 @@ string PrefsPack::stemlang() } return stemLang; } + diff --git a/src/qtgui/main.cpp b/src/qtgui/main.cpp index 4cbbe3bd..a9e84ffe 100644 --- a/src/qtgui/main.cpp +++ b/src/qtgui/main.cpp @@ -36,7 +36,7 @@ #include "recoll.h" #include "smallut.h" #include "rclinit.h" -#include "debuglog.h" +#include "log.h" #include "rclmain_w.h" #include "ssearch_w.h" #include "guiutils.h" @@ -98,7 +98,7 @@ void startManual(const string& helpindex) bool maybeOpenDb(string &reason, bool force, bool *maindberror) { - LOGDEB2(("maybeOpenDb: force %d\n", force)); + LOGDEB2("maybeOpenDb: force " << (force) << "\n" ); if (!rcldb) { reason = "Internal error: db not created"; return false; @@ -109,7 +109,7 @@ bool maybeOpenDb(string &reason, bool force, bool *maindberror) rcldb->rmQueryDb(""); for (list::const_iterator it = prefs.activeExtraDbs.begin(); it != prefs.activeExtraDbs.end(); it++) { - LOGDEB(("main: adding [%s]\n", it->c_str())); + LOGDEB("main: adding [" << *it << "]\n" ); rcldb->addQueryDb(*it); } Rcl::Db::OpenError error; @@ -136,8 +136,7 @@ bool getStemLangs(vector& vlangs) string reason; if (maybeOpenDb(reason)) { vlangs = rcldb->getStemLangs(); - LOGDEB0(("getStemLangs: from index: %s\n", - stringsToString(vlangs).c_str())); + LOGDEB0("getStemLangs: from index: " << (stringsToString(vlangs)) << "\n" ); return true; } else { // Cant get the langs from the index. Maybe it just does not @@ -153,7 +152,7 @@ bool getStemLangs(vector& vlangs) static void recollCleanup() { - LOGDEB2(("recollCleanup: closing database\n")); + LOGDEB2("recollCleanup: closing database\n" ); deleteZ(rcldb); deleteZ(theconfig); @@ -163,13 +162,13 @@ static void recollCleanup() deleteZ(aspell); #endif - LOGDEB2(("recollCleanup: done\n")); + LOGDEB2("recollCleanup: done\n" ); } void applyStyleSheet(const QString& ssfname) { const char *cfname = (const char *)ssfname.toLocal8Bit(); - LOGDEB0(("Applying style sheet: [%s]\n", cfname)); + LOGDEB0("Applying style sheet: [" << (cfname) << "]\n" ); if (cfname && *cfname) { string stylesheet; file_to_string(cfname, stylesheet); @@ -327,7 +326,7 @@ int main(int argc, char **argv) aspell = new Aspell(theconfig); aspell->init(reason); if (!aspell || !aspell->ok()) { - LOGDEB(("Aspell speller creation failed %s\n", reason.c_str())); + LOGDEB("Aspell speller creation failed " << (reason) << "\n" ); aspell = 0; } #endif @@ -396,7 +395,7 @@ int main(int argc, char **argv) mainWindow-> sSearch->setSearchString(QString::fromLocal8Bit(question.c_str())); } 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())); } return app.exec(); @@ -404,7 +403,7 @@ int main(int argc, char **argv) QString myGetFileName(bool isdir, QString caption, bool filenosave) { - LOGDEB1(("myFileDialog: isdir %d\n", isdir)); + LOGDEB1("myFileDialog: isdir " << (isdir) << "\n" ); QFileDialog dialog(0, caption); if (isdir) { @@ -430,3 +429,4 @@ QString myGetFileName(bool isdir, QString caption, bool filenosave) } return QString(); } + diff --git a/src/qtgui/multisave.cpp b/src/qtgui/multisave.cpp index b96d264a..00849d66 100644 --- a/src/qtgui/multisave.cpp +++ b/src/qtgui/multisave.cpp @@ -30,7 +30,7 @@ using namespace std; #include "recoll.h" #include "multisave.h" #include "smallut.h" -#include "debuglog.h" +#include "log.h" #include "pathut.h" #include "internfile.h" @@ -52,7 +52,7 @@ void multiSave(QWidget *p, vector& docs) return; } 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: - It is quite common to have docs in the array with the save @@ -90,13 +90,13 @@ void multiSave(QWidget *p, vector& docs) string utf8fn; it->getmeta(Rcl::Doc::keyfn, &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) { 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); - LOGDEB(("Multisave: simple [%s]\n", simple.c_str())); + LOGDEB("Multisave: simple [" << (simple) << "]\n" ); if (simple.empty()) simple = "rclsave"; if (simple.size() > maxlen) { @@ -141,3 +141,4 @@ void multiSave(QWidget *p, vector& docs) } } } + diff --git a/src/qtgui/preview_load.cpp b/src/qtgui/preview_load.cpp index 1dd1f8ba..2e732264 100644 --- a/src/qtgui/preview_load.cpp +++ b/src/qtgui/preview_load.cpp @@ -16,7 +16,7 @@ */ #include -#include "debuglog.h" +#include "log.h" #include "preview_load.h" #include "internfile.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), m_config(*config) { - // Save log level while we're running in the calling thread. - m_loglevel = DebugLog::getdbl()->getlevel(); } void LoadThread::run() { - DebugLog::getdbl()->setloglevel(m_loglevel); - FileInterner interner(m_idoc, &m_config, FileInterner::FIF_forPreview); FIMissingStore mst; interner.setMissingStore(&mst); @@ -69,7 +65,8 @@ void LoadThread::run() status = -1; } } catch (CancelExcept) { - LOGDEB(("LoadThread: cancelled\n")); + LOGDEB("LoadThread: cancelled\n" ); status = -1; } } + diff --git a/src/qtgui/preview_load.h b/src/qtgui/preview_load.h index 328c4ba1..970a6a29 100644 --- a/src/qtgui/preview_load.h +++ b/src/qtgui/preview_load.h @@ -51,7 +51,6 @@ public: private: Rcl::Doc m_idoc; - int m_loglevel; bool m_previewHtml; RclConfig m_config; }; diff --git a/src/qtgui/preview_plaintorich.cpp b/src/qtgui/preview_plaintorich.cpp index 86469f0b..9204e5c6 100644 --- a/src/qtgui/preview_plaintorich.cpp +++ b/src/qtgui/preview_plaintorich.cpp @@ -26,7 +26,7 @@ #include "preview_plaintorich.h" #include "plaintorich.h" -#include "debuglog.h" +#include "log.h" #include "guiutils.h" #include "cancelcheck.h" @@ -71,9 +71,9 @@ string PlainToRichQtPreview::PlainToRichQtPreview::header() string PlainToRichQtPreview::startMatch(unsigned int grpidx) { - LOGDEB2(("startMatch, grpidx %u\n", grpidx)); + LOGDEB2("startMatch, grpidx " << (grpidx) << "\n" ); grpidx = m_hdata->grpsugidx[grpidx]; - LOGDEB2(("startMatch, ugrpidx %u\n", grpidx)); + LOGDEB2("startMatch, ugrpidx " << (grpidx) << "\n" ); m_groupanchors[grpidx].push_back(++m_lastanchor); m_groupcuranchors[grpidx] = 0; return string("currentWidget(); PreviewTextEdit *edit = 0; if (tw) { @@ -325,9 +323,7 @@ void Preview::emitSaveDocToFile() void Preview::doSearch(const QString &_text, bool next, bool reverse, bool wordOnly) { - LOGDEB(("Preview::doSearch: text [%s] idx %d next %d rev %d word %d\n", - (const char *)_text.toUtf8(), m_searchTextFromIndex, int(next), - int(reverse), int(wordOnly))); + LOGDEB("Preview::doSearch: text [" << ((const char *)_text.toUtf8()) << "] idx " << (m_searchTextFromIndex) << " next " << (int(next)) << " rev " << (int(reverse)) << " word " << (int(wordOnly)) << "\n" ); QString text = _text; 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 (!edit->m_plaintorich->haveAnchors()) { - LOGDEB(("NO ANCHORS\n")); + LOGDEB("NO ANCHORS\n" ); return; } // 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); } 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); // Position the cursor approximately at the anchor (top of // viewport) so that searches start from here @@ -370,7 +366,7 @@ void Preview::doSearch(const QString &_text, bool next, bool reverse, edit->setTextCursor(cursor); } Chrono chron; - LOGDEB(("Preview::doSearch: first find call\n")); + LOGDEB("Preview::doSearch: first find call\n" ); QTextDocument::FindFlags flags = 0; if (reverse) flags |= QTextDocument::FindBackward; @@ -379,21 +375,19 @@ void Preview::doSearch(const QString &_text, bool next, bool reverse, if (matchCase) flags |= QTextDocument::FindCaseSensitively; bool found = edit->find(text, flags); - LOGDEB(("Preview::doSearch: first find call return: found %d %.2f S\n", - found, chron.secs())); + LOGDEB("Preview::doSearch: first find call return: found " << (found) << " " << (chron.secs()) << " S\n" ); // If not found, try to wrap around. if (!found) { - LOGDEB(("Preview::doSearch: wrapping around\n")); + LOGDEB("Preview::doSearch: wrapping around\n" ); if (reverse) { edit->moveCursor (QTextCursor::End); } else { edit->moveCursor (QTextCursor::Start); } - LOGDEB(("Preview::doSearch: 2nd find call\n")); + LOGDEB("Preview::doSearch: 2nd find call\n" ); chron.restart(); found = edit->find(text, flags); - LOGDEB(("Preview::doSearch: 2nd find call return found %d %.2f S\n", - found, chron.secs())); + LOGDEB("Preview::doSearch: 2nd find call return found " << (found) << " " << (chron.secs()) << " S\n" ); } if (found) { @@ -403,37 +397,37 @@ void Preview::doSearch(const QString &_text, bool next, bool reverse, QApplication::beep(); m_canBeep = false; } - LOGDEB(("Preview::doSearch: return\n")); + LOGDEB("Preview::doSearch: return\n" ); } void Preview::nextPressed() { - LOGDEB2(("Preview::nextPressed\n")); + LOGDEB2("Preview::nextPressed\n" ); doSearch(searchTextCMB->currentText(), true, false); } void Preview::prevPressed() { - LOGDEB2(("Preview::prevPressed\n")); + LOGDEB2("Preview::prevPressed\n" ); doSearch(searchTextCMB->currentText(), true, true); } // Called when user clicks on tab void Preview::currentChanged(int index) { - LOGDEB2(("PreviewTextEdit::currentChanged\n")); + LOGDEB2("PreviewTextEdit::currentChanged\n" ); QWidget *tw = pvTab->widget(index); PreviewTextEdit *edit = tw->findChild("pvEdit"); - LOGDEB1(("Preview::currentChanged(). Editor: %p\n", edit)); + LOGDEB1("Preview::currentChanged(). Editor: " << (edit) << "\n" ); if (edit == 0) { - LOGERR(("Editor child not found\n")); + LOGERR("Editor child not found\n" ); return; } edit->setFocus(); // 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); connect(this, SIGNAL(printCurrentPreviewRequest()), edit, SLOT(print())); edit->installEventFilter(this); @@ -444,7 +438,7 @@ void Preview::currentChanged(int index) void Preview::closeCurrentTab() { - LOGDEB1(("Preview::closeCurrentTab: m_loading %d\n", m_loading)); + LOGDEB1("Preview::closeCurrentTab: m_loading " << (m_loading) << "\n" ); if (m_loading) { CancelCheck::instance().setCancel(); return; @@ -461,7 +455,7 @@ void Preview::closeCurrentTab() PreviewTextEdit *Preview::addEditorTab() { - LOGDEB1(("PreviewTextEdit::addEditorTab()\n")); + LOGDEB1("PreviewTextEdit::addEditorTab()\n" ); QWidget *anon = new QWidget((QWidget *)pvTab); QVBoxLayout *anonLayout = new QVBoxLayout(anon); PreviewTextEdit *editor = new PreviewTextEdit(anon, "pvEdit", this); @@ -475,7 +469,7 @@ PreviewTextEdit *Preview::addEditorTab() void Preview::setCurTabProps(const Rcl::Doc &doc, int docnum) { - LOGDEB1(("Preview::setCurTabProps\n")); + LOGDEB1("Preview::setCurTabProps\n" ); QString title; string ctitle; 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); 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; printableUrl(theconfig->getDefCharset(), doc.url, url); 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) { - LOGDEB(("Preview::makeDocCurrent: %s\n", doc.url.c_str())); + LOGDEB("Preview::makeDocCurrent: " << (doc.url) << "\n" ); if (m_loading) { - LOGERR(("Already loading\n")); + LOGERR("Already loading\n" ); return false; } @@ -609,7 +603,7 @@ public: bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum) { - LOGDEB1(("Preview::loadDocInCurrentTab()\n")); + LOGDEB1("Preview::loadDocInCurrentTab()\n" ); LoadGuard guard(&m_loading); CancelCheck::instance().setCancel(false); @@ -647,10 +641,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum) progress.show(); } - LOGDEB(("loadDocInCurrentTab: after file load: cancel %d status %d" - " text length %d\n", - CancelCheck::instance().cancelState(), lthr.status, - lthr.fdoc.text.length())); + LOGDEB("loadDocInCurrentTab: after file load: cancel " << (CancelCheck::instance().cancelState()) << " status " << (lthr.status) << " text length " << (lthr.fdoc.text.length()) << "\n" ); if (CancelCheck::instance().cancelState()) return false; @@ -719,10 +710,10 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum) qApp->processEvents(); 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); } 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); } @@ -753,8 +744,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum) } } } else { - LOGDEB(("Preview: no hilighting, loading %d bytes\n", - int(lthr.fdoc.text.size()))); + LOGDEB("Preview: no hilighting, loading " << (int(lthr.fdoc.text.size())) << " bytes\n" ); // No plaintorich() call. In this case, either the text is // html and the html quoting is hopefully correct, or it's // 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()) { editor->append("Cancelled !"); - LOGDEB(("loadDocInCurrentTab: cancelled in editor load\n")); + LOGDEB("loadDocInCurrentTab: cancelled in editor load\n" ); break; } } @@ -836,7 +826,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum) if (fn.empty() || !idoc.ipath.empty()) { TempFile temp = lthr.tmpimg; 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(), theconfig, idoc)) { temp.reset(); // just in case. @@ -868,7 +858,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum) // Position to the first query term if (editor->m_plaintorich->haveAnchors()) { 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); // Position the cursor approximately at the anchor (top of // viewport) so that searches start from here @@ -886,7 +876,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum) editor->setFocus(); emit(previewExposed(this, m_searchId, docnum)); - LOGDEB(("loadDocInCurrentTab: returning true\n")); + LOGDEB("loadDocInCurrentTab: returning true\n" ); return true; } @@ -905,7 +895,7 @@ PreviewTextEdit::PreviewTextEdit(QWidget* parent, const char* nm, Preview *pv) void PreviewTextEdit::createPopupMenu(const QPoint& pos) { - LOGDEB1(("PreviewTextEdit::createPopupMenu()\n")); + LOGDEB1("PreviewTextEdit::createPopupMenu()\n" ); QMenu *popup = new QMenu(this); switch (m_curdsp) { case PTE_DSPTXT: @@ -944,7 +934,7 @@ void PreviewTextEdit::createPopupMenu(const QPoint& pos) // Display main text void PreviewTextEdit::displayText() { - LOGDEB1(("PreviewTextEdit::displayText()\n")); + LOGDEB1("PreviewTextEdit::displayText()\n" ); if (m_format == Qt::PlainText) setPlainText(m_richtxt); else @@ -955,7 +945,7 @@ void PreviewTextEdit::displayText() // Display field values void PreviewTextEdit::displayFields() { - LOGDEB1(("PreviewTextEdit::displayFields()\n")); + LOGDEB1("PreviewTextEdit::displayFields()\n" ); QString txt = "\n"; txt += "" + QString::fromLocal8Bit(m_url.c_str()); @@ -977,7 +967,7 @@ void PreviewTextEdit::displayFields() void PreviewTextEdit::displayImage() { - LOGDEB1(("PreviewTextEdit::displayImage()\n")); + LOGDEB1("PreviewTextEdit::displayImage()\n" ); if (m_image.isNull()) displayText(); @@ -995,7 +985,7 @@ void PreviewTextEdit::displayImage() void PreviewTextEdit::mouseDoubleClickEvent(QMouseEvent *event) { - LOGDEB2(("PreviewTextEdit::mouseDoubleClickEvent\n")); + LOGDEB2("PreviewTextEdit::mouseDoubleClickEvent\n" ); QTextEdit::mouseDoubleClickEvent(event); if (textCursor().hasSelection() && m_preview) m_preview->emitWordSelect(textCursor().selectedText()); @@ -1003,7 +993,7 @@ void PreviewTextEdit::mouseDoubleClickEvent(QMouseEvent *event) void PreviewTextEdit::print() { - LOGDEB(("PreviewTextEdit::print\n")); + LOGDEB("PreviewTextEdit::print\n" ); if (!m_preview) return; @@ -1016,3 +1006,4 @@ void PreviewTextEdit::print() QTextEdit::print(&printer); #endif } + diff --git a/src/qtgui/ptrans_w.cpp b/src/qtgui/ptrans_w.cpp index ca98fbdf..0253a5ab 100644 --- a/src/qtgui/ptrans_w.cpp +++ b/src/qtgui/ptrans_w.cpp @@ -34,7 +34,7 @@ using namespace std; #include #include "recoll.h" -#include "debuglog.h" +#include "log.h" #include "guiutils.h" #include "conftree.h" @@ -133,3 +133,4 @@ void EditTrans::on_transTW_itemSelectionChanged() else delPB->setEnabled(1); } + diff --git a/src/qtgui/rclhelp.cpp b/src/qtgui/rclhelp.cpp index 026466e6..34ba5698 100644 --- a/src/qtgui/rclhelp.cpp +++ b/src/qtgui/rclhelp.cpp @@ -22,7 +22,7 @@ #include "recoll.h" #include "rclhelp.h" -#include "debuglog.h" +#include "log.h" map HelpClient::helpmap; @@ -42,7 +42,7 @@ bool HelpClient::eventFilter(QObject *obj, QEvent *event) static time_t last_start; if (event->type() == QEvent::KeyPress || event->type() == QEvent::ShortcutOverride) { - // LOGDEB(("HelpClient::eventFilter: %d\n", (int)event->type())); + // LOGDEB("HelpClient::eventFilter: " << ((int)event->type()) << "\n" ); QKeyEvent *ke = static_cast(event); if (ke->key() == Qt::Key_F1 || ke->key() == Qt::Key_Help) { if (obj->isWidgetType()) { @@ -57,11 +57,10 @@ bool HelpClient::eventFilter(QObject *obj, QEvent *event) if (time(0) - last_start > 5) { last_start = time(0); if (it != helpmap.end()) { - LOGDEB(("HelpClient::eventFilter: %s->%s\n", - it->first.c_str(), it->second.c_str())); + LOGDEB("HelpClient::eventFilter: " << (it->first) << "->" << (it->second) << "\n" ); startManual(it->second); } else { - LOGDEB(("HelpClient::eventFilter: no help section\n")); + LOGDEB("HelpClient::eventFilter: no help section\n" ); startManual(""); } } @@ -71,3 +70,4 @@ bool HelpClient::eventFilter(QObject *obj, QEvent *event) } return false; } + diff --git a/src/qtgui/rclm_idx.cpp b/src/qtgui/rclm_idx.cpp index 04790d52..63928201 100644 --- a/src/qtgui/rclm_idx.cpp +++ b/src/qtgui/rclm_idx.cpp @@ -23,7 +23,7 @@ #include #include "execmd.h" -#include "debuglog.h" +#include "log.h" #include "transcode.h" #include "indexer.h" #include "rclmain_w.h" @@ -83,7 +83,7 @@ void RclMain::updateIdxStatus() // indexing, a possible need to exit, and cleanup exited viewers void RclMain::periodic100() { - LOGDEB2(("Periodic100\n")); + LOGDEB2("Periodic100\n" ); if (m_idxproc) { // An indexing process was launched. If its' done, see status. int status; @@ -268,7 +268,7 @@ void RclMain::rebuildIndex() case IXST_NOTRUNNING: { if (m_idxproc) { - LOGERR(("RclMain::rebuildIndex: current indexer exec not null\n")); + LOGERR("RclMain::rebuildIndex: current indexer exec not null\n" ); return; } int rep = @@ -354,7 +354,7 @@ static string execToString(const string& cmd, const vector& args) void RclMain::specialIndex() { - LOGDEB(("RclMain::specialIndex\n")); + LOGDEB("RclMain::specialIndex\n" ); switch (m_indexerState) { case IXST_UNKNOWN: case IXST_RUNNINGMINE: @@ -365,7 +365,7 @@ void RclMain::specialIndex() break; } if (m_idxproc) { - LOGERR(("RclMain::rebuildIndex: current indexer exec not null\n")); + LOGERR("RclMain::rebuildIndex: current indexer exec not null\n" ); return; } if (!specidx) // ?? @@ -418,8 +418,7 @@ void RclMain::specialIndex() args.push_back(top); } m_idxproc = new ExecCmd; - LOGINFO(("specialIndex: exec: %s\n", - execToString("recollindex", args).c_str())); + LOGINFO("specialIndex: exec: " << execToString("recollindex", args) <startExec("recollindex", args, false, false); } @@ -449,3 +448,4 @@ void RclMain::updateIdxForDocs(vector& docs) actionSpecial_Indexing->setEnabled(false); } + diff --git a/src/qtgui/rclm_preview.cpp b/src/qtgui/rclm_preview.cpp index 3008bf86..7f56f6f3 100644 --- a/src/qtgui/rclm_preview.cpp +++ b/src/qtgui/rclm_preview.cpp @@ -19,7 +19,7 @@ #include #include -#include "debuglog.h" +#include "log.h" #include "internfile.h" #include "rclzg.h" #include "rclmain_w.h" @@ -31,12 +31,12 @@ static const QKeySequence quitKeySeq("Ctrl+q"); // where the current one is closed void RclMain::previewClosed(Preview *w) { - LOGDEB(("RclMain::previewClosed(%p)\n", w)); + LOGDEB("RclMain::previewClosed(" << (w) << ")\n" ); if (w == curPreview) { - LOGDEB(("Active preview closed\n")); + LOGDEB("Active preview closed\n" ); curPreview = 0; } else { - LOGDEB(("Old preview closed\n")); + LOGDEB("Old preview closed\n" ); } delete w; } @@ -114,7 +114,7 @@ bool RclMain::containerUpToDate(Rcl::Doc& doc) QMessageBox::Cancel : QMessageBox::NoButton); 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 docs(1, doc); updateIdxForDocs(docs); } @@ -135,7 +135,7 @@ bool RclMain::containerUpToDate(Rcl::Doc& doc) */ 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)) return; @@ -221,8 +221,7 @@ void RclMain::previewPrevInTab(Preview * w, int sid, int docnum) // Combined next/prev from result list in current preview tab void RclMain::previewPrevOrNextInTab(Preview * w, int sid, int docnum, bool nxt) { - LOGDEB(("RclMain::previewNextInTab sid %d docnum %d, listId %d\n", - sid, docnum, reslist->listId())); + LOGDEB("RclMain::previewNextInTab sid " << (sid) << " docnum " << (docnum) << ", listId " << (reslist->listId()) << "\n" ); if (w == 0) // ?? 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) void RclMain::previewExposed(Preview *, int sid, int docnum) { - LOGDEB2(("RclMain::previewExposed: sid %d docnum %d, m_sid %d\n", - sid, docnum, reslist->listId())); + LOGDEB2("RclMain::previewExposed: sid " << (sid) << " docnum " << (docnum) << ", m_sid " << (reslist->listId()) << "\n" ); if (sid != reslist->listId()) { return; } reslist->previewExposed(docnum); } + diff --git a/src/qtgui/rclm_saveload.cpp b/src/qtgui/rclm_saveload.cpp index 4d2120d8..9f143f5a 100644 --- a/src/qtgui/rclm_saveload.cpp +++ b/src/qtgui/rclm_saveload.cpp @@ -25,7 +25,7 @@ #include #include "rclmain_w.h" -#include "debuglog.h" +#include "log.h" #include "readfile.h" #include "xmltosd.h" #include "searchdata.h" @@ -88,7 +88,7 @@ void RclMain::saveLastQuery() string tofile((const char *)s.toLocal8Bit()); - LOGDEB(("RclMain::saveLastQuery: XML: [%s]\n", xml.c_str())); + LOGDEB("RclMain::saveLastQuery: XML: [" << (xml) << "]\n" ); string reason; if (!stringtofile(xml, tofile.c_str(), reason)) { QMessageBox::warning(this, tr("Write failed"), @@ -132,3 +132,4 @@ void RclMain::loadSavedQuery() QMessageBox::warning(this, tr("Load error"), tr("Could not load saved query")); } + diff --git a/src/qtgui/rclm_view.cpp b/src/qtgui/rclm_view.cpp index e256a74e..baa607ec 100644 --- a/src/qtgui/rclm_view.cpp +++ b/src/qtgui/rclm_view.cpp @@ -24,7 +24,7 @@ #include "qxtconfirmationmessage.h" -#include "debuglog.h" +#include "log.h" #include "fileudi.h" #include "execmd.h" #include "transcode.h" @@ -47,9 +47,7 @@ void RclMain::viewUrl() return; QUrl qurl(m_urltoview); - LOGDEB(("RclMain::viewUrl: Path [%s] fragment [%s]\n", - (const char *)qurl.path().toLocal8Bit(), - (const char *)qurl.fragment().toLocal8Bit())); + LOGDEB("RclMain::viewUrl: Path [" << ((const char *)qurl.path().toLocal8Bit()) << "] fragment [" << ((const char *)qurl.fragment().toLocal8Bit()) << "]\n" ); /* In theory, the url might not be for a file managed by the fs 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) { - LOGDEB(("RclMain::openWith: %s\n", cmdspec.c_str())); + LOGDEB("RclMain::openWith: " << (cmdspec) << "\n" ); // Split the command line vector lcmd; @@ -159,11 +157,7 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term) { string apptag; doc.getmeta(Rcl::Doc::keyapptg, &apptag); - LOGDEB(("RclMain::startNativeViewer: mtype [%s] apptag [%s] page %d " - "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() - )); + LOGDEB("RclMain::startNativeViewer: mtype [" << (doc.mimetype) << "] apptag [" << (apptag) << "] page " << (pagenum) << " term [" << ((const char *)(term.toUtf8())) << "] url [" << (doc.url) << "] ipath [" << (doc.ipath) << "]\n" ); // Look for appropriate viewer 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 istempfile = false; - LOGDEB(("RclMain::startNV: groksipath %d wantsf %d wantsparentf %d\n", - groksipath, wantsfile, wantsparentfile)); + LOGDEB("RclMain::startNV: groksipath " << (groksipath) << " wantsf " << (wantsfile) << " wantsparentf " << (wantsparentfile) << "\n" ); // 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: @@ -409,7 +402,7 @@ void RclMain::execViewer(const map& subs, bool enterHistory, for (vector::const_iterator it = _lcmd.begin(); it != _lcmd.end(); it++) { pcSubst(*it, ncmd, subs); - LOGDEB(("%s->%s\n", it->c_str(), ncmd.c_str())); + LOGDEB("" << *it << "->" << (ncmd) << "\n" ); lcmd.push_back(ncmd); } @@ -457,8 +450,7 @@ void RclMain::startManual(const string& index) webhelp = path_cat(webhelp, "index.html"); bool has_wh = path_exists(webhelp); - LOGDEB(("RclMain::startManual: help index is %s\n", - index.empty()?"(null)":index.c_str())); + LOGDEB("RclMain::startManual: help index is " << (index.empty()?"(null)":index) << "\n" ); bool indexempty = index.empty(); #ifdef _WIN32 @@ -481,3 +473,4 @@ void RclMain::startManual(const string& index) doc.mimetype = "text/html"; startNativeViewer(doc); } + diff --git a/src/qtgui/rclm_wins.cpp b/src/qtgui/rclm_wins.cpp index f1b9f422..1c5836a8 100644 --- a/src/qtgui/rclm_wins.cpp +++ b/src/qtgui/rclm_wins.cpp @@ -19,7 +19,7 @@ #include #include -#include "debuglog.h" +#include "log.h" #include "internfile.h" #include "listdialog.h" #include "confgui/confguiindex.h" @@ -171,7 +171,7 @@ void RclMain::execIndexConfig() } void RclMain::showIndexConfig(bool modal) { - LOGDEB(("showIndexConfig()\n")); + LOGDEB("showIndexConfig()\n" ); if (indexConfig == 0) { indexConfig = new ConfIndexW(0, theconfig); connect(new QShortcut(quitKeySeq, indexConfig), SIGNAL (activated()), @@ -205,7 +205,7 @@ void RclMain::showIndexSched(bool modal) "to update the index")); return; #endif - LOGDEB(("showIndexSched()\n")); + LOGDEB("showIndexSched()\n" ); if (indexSched == 0) { indexSched = new IdxSchedW(this); connect(new QShortcut(quitKeySeq, indexSched), SIGNAL (activated()), @@ -246,7 +246,7 @@ void RclMain::execCronTool() } void RclMain::showCronTool(bool modal) { - LOGDEB(("showCronTool()\n")); + LOGDEB("showCronTool()\n" ); if (cronTool == 0) { cronTool = new CronToolW(0); connect(new QShortcut(quitKeySeq, cronTool), SIGNAL (activated()), @@ -273,7 +273,7 @@ void RclMain::execRTITool() } void RclMain::showRTITool(bool modal) { - LOGDEB(("showRTITool()\n")); + LOGDEB("showRTITool()\n" ); if (rtiTool == 0) { rtiTool = new RTIToolW(0); connect(new QShortcut(quitKeySeq, rtiTool), SIGNAL (activated()), @@ -453,3 +453,4 @@ void RclMain::showSnippets(Rcl::Doc doc) sp, SLOT (close())); sp->show(); } + diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index eb03e4bd..634a735c 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -43,7 +43,7 @@ #include #include "recoll.h" -#include "debuglog.h" +#include "log.h" #include "mimehandler.h" #include "pathut.h" #include "smallut.h" @@ -585,7 +585,7 @@ void RclMain::initDbOpen() 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 // (might also be "show prefs" etc. bool isLangId = false; @@ -615,8 +615,7 @@ void RclMain::setStemLang(QAction *id) lang = id->text(); } prefs.queryStemLang = lang; - LOGDEB(("RclMain::setStemLang(%d): lang [%s]\n", - id, (const char *)prefs.queryStemLang.toUtf8())); + LOGDEB("RclMain::setStemLang(" << (id) << "): lang [" << ((const char *)prefs.queryStemLang.toUtf8()) << "]\n" ); rwSettings(true); emit stemLangChanged(lang); } @@ -624,7 +623,7 @@ void RclMain::setStemLang(QAction *id) // Set the checked stemming language item before showing the prefs menu 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; if (lang == "") { id = m_idNoStem; @@ -658,7 +657,7 @@ void RclMain::showTrayMessage(const QString& text) void RclMain::closeEvent(QCloseEvent *ev) { - LOGDEB(("RclMain::closeEvent\n")); + LOGDEB("RclMain::closeEvent\n" ); if (prefs.closeToTray && m_trayicon && m_trayicon->isVisible()) { hide(); ev->ignore(); @@ -669,7 +668,7 @@ void RclMain::closeEvent(QCloseEvent *ev) void RclMain::fileExit() { - LOGDEB(("RclMain: fileExit\n")); + LOGDEB("RclMain: fileExit\n" ); // Don't save geometry if we're currently fullscreened if (!isFullScreen()) { prefs.mainwidth = width(); @@ -697,10 +696,9 @@ void RclMain::fileExit() // Start a db query and set the reslist docsource void RclMain::startSearch(STD_SHARED_PTR sdata, bool issimple) { - LOGDEB(("RclMain::startSearch. Indexing %s Active %d\n", - m_idxproc?"on":"off", m_queryActive)); + LOGDEB("RclMain::startSearch. Indexing " << (m_idxproc?"on":"off") << " Active " << (m_queryActive) << "\n" ); if (m_queryActive) { - LOGDEB(("startSearch: already active\n")); + LOGDEB("startSearch: already active\n" ); return; } m_queryActive = true; @@ -749,18 +747,15 @@ void RclMain::startSearch(STD_SHARED_PTR sdata, bool issimple) } class QueryThread : public QThread { - int loglevel; STD_SHARED_PTR m_source; public: QueryThread(STD_SHARED_PTR source) : m_source(source) { - loglevel = DebugLog::getdbl()->getlevel(); } ~QueryThread() { } virtual void run() { - DebugLog::getdbl()->setloglevel(loglevel); cnt = m_source->getResCnt(); } int cnt; @@ -830,7 +825,7 @@ void RclMain::onSortCtlChanged() if (m_sortspecnochange) return; - LOGDEB(("RclMain::onSortCtlChanged()\n")); + LOGDEB("RclMain::onSortCtlChanged()\n" ); m_sortspec.reset(); if (actionSortByDateAsc->isChecked()) { m_sortspec.field = "mtime"; @@ -856,7 +851,7 @@ void RclMain::onSortCtlChanged() void RclMain::onSortDataChanged(DocSeqSortSpec spec) { - LOGDEB(("RclMain::onSortDataChanged\n")); + LOGDEB("RclMain::onSortDataChanged\n" ); m_sortspecnochange = true; if (spec.field.compare("mtime")) { actionSortByDateDesc->setChecked(false); @@ -879,7 +874,7 @@ void RclMain::onSortDataChanged(DocSeqSortSpec spec) 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; displayingTable = on; restable->setVisible(on); @@ -908,7 +903,7 @@ void RclMain::on_actionShowResultsAsTable_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 (actionSortByDateDesc->isChecked()) { actionSortByDateDesc->setChecked(false); @@ -921,7 +916,7 @@ void RclMain::on_actionSortByDateAsc_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 (actionSortByDateAsc->isChecked()) { actionSortByDateAsc->setChecked(false); @@ -951,7 +946,7 @@ void RclMain::saveDocToFile(Rcl::Doc doc) void RclMain::showSubDocs(Rcl::Doc doc) { - LOGDEB(("RclMain::showSubDocs\n")); + LOGDEB("RclMain::showSubDocs\n" ); string reason; if (!maybeOpenDb(reason)) { 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. void RclMain::docExpand(Rcl::Doc doc) { - LOGDEB(("RclMain::docExpand()\n")); + LOGDEB("RclMain::docExpand()\n" ); if (!rcldb) return; list terms; terms = m_source->expand(doc); if (terms.empty()) { - LOGDEB(("RclMain::docExpand: no terms\n")); + LOGDEB("RclMain::docExpand: no terms\n" ); return; } // 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() { - LOGDEB(("RclMain::showDocHistory\n")); + LOGDEB("RclMain::showDocHistory\n" ); emit searchReset(); m_source = STD_SHARED_PTR(); curPreview = 0; @@ -1062,7 +1057,7 @@ void RclMain::setUIPrefs() { if (!uiprefs) return; - LOGDEB(("Recollmain::setUIPrefs\n")); + LOGDEB("Recollmain::setUIPrefs\n" ); reslist->setFont(); sSearch->setPrefs(); enbSynAction->setDisabled(prefs.synFile.isEmpty()); @@ -1100,7 +1095,7 @@ void RclMain::catgFilter(QAction *act) // User pressed a filter button: set filter params in reslist 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())) return; @@ -1173,3 +1168,4 @@ void RclMain::applyStyleSheet() { ::applyStyleSheet(prefs.qssFile); } + diff --git a/src/qtgui/rclzg.cpp b/src/qtgui/rclzg.cpp index 15a92501..3c3e8071 100644 --- a/src/qtgui/rclzg.cpp +++ b/src/qtgui/rclzg.cpp @@ -20,7 +20,7 @@ #include "rclzg.h" -#include "debuglog.h" +#include "log.h" #include "pathut.h" #include @@ -78,9 +78,9 @@ void zg_send_event(ZgSendType, const Rcl::Doc& doc) QtZeitgeist::DataModel::EventList events; events.push_back(event); - LOGDEB(("zg_send_event, sending for %s %s\n", - doc.mimetype.c_str(), doc.url.c_str())); + LOGDEB("zg_send_event, sending for " << (doc.mimetype) << " " << (doc.url) << "\n" ); zglogger.insertEvents(events); } #endif + diff --git a/src/qtgui/recoll.pro.in b/src/qtgui/recoll.pro.in index 445546c5..c58105f0 100644 --- a/src/qtgui/recoll.pro.in +++ b/src/qtgui/recoll.pro.in @@ -6,6 +6,7 @@ DEFINES += BUILDING_RECOLL @QMAKE_ENABLE_WEBKIT@ QT += webkit @QMAKE_DISABLE_WEBKIT@ QMAKE_CXXFLAGS += -DRESLIST_TEXTBROWSER -DSNIPPETS_TEXTBROWSER +QMAKE_CXXFLAGS += -std=c++11 @QMAKE_ENABLE_ZEITGEIST@ QT += dbus @QMAKE_ENABLE_ZEITGEIST@ QMAKE_CXXFLAGS += -DUSE_ZEITGEIST diff --git a/src/qtgui/reslist.cpp b/src/qtgui/reslist.cpp index aa916792..9eb47ea4 100644 --- a/src/qtgui/reslist.cpp +++ b/src/qtgui/reslist.cpp @@ -38,7 +38,7 @@ //#include #endif -#include "debuglog.h" +#include "log.h" #include "smallut.h" #include "recoll.h" #include "guiutils.h" @@ -116,7 +116,7 @@ void logdata(const char *data) // /// QtGuiResListPager methods: bool QtGuiResListPager::append(const string& data) { - LOGDEB2(("QtGuiReslistPager::appendString : %s\n", data.c_str())); + LOGDEB2("QtGuiReslistPager::appendString : " << (data) << "\n" ); logdata(data.c_str()); m_reslist->append(QString::fromUtf8(data.c_str())); return true; @@ -125,8 +125,7 @@ bool QtGuiResListPager::append(const string& data) bool QtGuiResListPager::append(const string& data, int docnum, const Rcl::Doc&) { - LOGDEB2(("QtGuiReslistPager::appendDoc: blockCount %d, %s\n", - m_reslist->document()->blockCount(), data.c_str())); + LOGDEB2("QtGuiReslistPager::appendDoc: blockCount " << (m_reslist->document()->blockCount()) << ", " << (data) << "\n" ); logdata(data.c_str()); #ifdef RESLIST_TEXTBROWSER int blkcnt0 = m_reslist->document()->blockCount(); @@ -208,7 +207,7 @@ void QtGuiResListPager::suggest(const vectoruterms, if (noaspell) return; if (!aspell) { - LOGERR(("QtGuiResListPager:: aspell not initialized\n")); + LOGERR("QtGuiResListPager:: aspell not initialized\n" ); return; } @@ -225,8 +224,7 @@ void QtGuiResListPager::suggest(const vectoruterms, // frequencies and propose something anyway if a possible // variation is much more common (as google does) ? if (!aspell->suggest(*rcldb, *uit, asuggs, reason)) { - LOGERR(("QtGuiResListPager::suggest: aspell failed: %s\n", - reason.c_str())); + LOGERR("QtGuiResListPager::suggest: aspell failed: " << (reason) << "\n" ); continue; } @@ -261,16 +259,15 @@ string QtGuiResListPager::iconUrl(RclConfig *config, Rcl::Doc& doc) ConfIndexer::docsToPaths(docs, paths); if (!paths.empty()) { 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)) { - LOGDEB0(("ResList::iconUrl: icon path [%s]\n", path.c_str())); + LOGDEB0("ResList::iconUrl: icon path [" << (path) << "]\n" ); return cstr_fileu + path; } else { - LOGDEB0(("ResList::iconUrl: no icon: path [%s]\n", - path.c_str())); + LOGDEB0("ResList::iconUrl: no icon: path [" << (path) << "]\n" ); } } else { - LOGDEB(("ResList::iconUrl: docsToPaths failed\n")); + LOGDEB("ResList::iconUrl: docsToPaths failed\n" ); } } return ResListPager::iconUrl(config, doc); @@ -286,7 +283,7 @@ public: string s1, s2; stringsToString >(m_hdata->groups[idx], s1); stringsToString >(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(" dups; @@ -908,7 +897,7 @@ void ResList::linkWasClicked(const QUrl &url) int i = atoi(ascurl.c_str()+1) - 1; Rcl::Doc 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; } emit editRequested(ResultPopup::getParent(STD_SHARED_PTR(), @@ -930,7 +919,7 @@ void ResList::linkWasClicked(const QUrl &url) int i = atoi(ascurl.c_str()+1) - 1; Rcl::Doc 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; } if (what == 'P') { @@ -990,18 +979,18 @@ void ResList::linkWasClicked(const QUrl &url) break; default: - LOGERR(("ResList::linkWasClicked: bad link [%s]\n", ascurl.c_str())); + LOGERR("ResList::linkWasClicked: bad link [" << (ascurl) << "]\n" ); break;// ?? } } 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 QTextCursor cursor = cursorForPosition(pos); int blocknum = cursor.blockNumber(); - LOGDEB(("ResList::createPopupMenu(): block %d\n", blocknum)); + LOGDEB("ResList::createPopupMenu(): block " << (blocknum) << "\n" ); m_popDoc = docnumfromparnum(blocknum); #else QWebHitTestResult htr = page()->mainFrame()->hitTestContent(pos); @@ -1122,3 +1111,4 @@ int ResList::pageFirstDocNum() { return m_pager->pageFirstDocNum(); } + diff --git a/src/qtgui/respopup.cpp b/src/qtgui/respopup.cpp index 32d9754c..5c861743 100644 --- a/src/qtgui/respopup.cpp +++ b/src/qtgui/respopup.cpp @@ -20,7 +20,7 @@ #include #include -#include "debuglog.h" +#include "log.h" #include "smallut.h" #include "recoll.h" #include "docseq.h" @@ -33,10 +33,8 @@ QMenu *create(QWidget *me, int opts, STD_SHARED_PTR source, Rcl::Do { QMenu *popup = new QMenu(me); - LOGDEB(("ResultPopup::create: opts %x haspages %d %s %s\n", opts, - doc.haspages, source ? "Source not null" : "Source is Null", - source ? (source->snippetsCapable() ? - "snippetsCapable" : "not snippetsCapable") : "")); + LOGDEB("ResultPopup::create: opts " << (opts) << " haspages " << (doc.haspages) << " " << (source ? "Source not null" : "Source is Null") << " " << (source ? (source->snippetsCapable() ? + "snippetsCapable" : "not snippetsCapable") : "") << "\n" ); string apptag; doc.getmeta(Rcl::Doc::keyapptg, &apptag); @@ -175,3 +173,4 @@ void copyURL(const Rcl::Doc &doc) } } + diff --git a/src/qtgui/restable.cpp b/src/qtgui/restable.cpp index f4a85627..9b8b901d 100644 --- a/src/qtgui/restable.cpp +++ b/src/qtgui/restable.cpp @@ -37,7 +37,7 @@ #include "recoll.h" #include MEMORY_INCLUDE #include "docseq.h" -#include "debuglog.h" +#include "log.h" #include "restable.h" #include "guiutils.h" #include "reslistpager.h" @@ -271,7 +271,7 @@ RecollModel::RecollModel(const QStringList fields, QObject *parent) int RecollModel::rowCount(const QModelIndex&) const { - LOGDEB2(("RecollModel::rowCount\n")); + LOGDEB2("RecollModel::rowCount\n" ); if (!m_source) return 0; return m_source->getResCnt(); @@ -279,20 +279,20 @@ int RecollModel::rowCount(const QModelIndex&) const int RecollModel::columnCount(const QModelIndex&) const { - LOGDEB2(("RecollModel::columnCount\n")); + LOGDEB2("RecollModel::columnCount\n" ); return m_fields.size(); } void RecollModel::readDocSource() { - LOGDEB(("RecollModel::readDocSource()\n")); + LOGDEB("RecollModel::readDocSource()\n" ); beginResetModel(); endResetModel(); } void RecollModel::setDocSource(STD_SHARED_PTR nsource) { - LOGDEB(("RecollModel::setDocSource\n")); + LOGDEB("RecollModel::setDocSource\n" ); if (!nsource) { m_source = STD_SHARED_PTR(); } else { @@ -317,7 +317,7 @@ void RecollModel::deleteColumn(int col) 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())) { col++; vector::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, int role) const { - LOGDEB2(("RecollModel::headerData: idx %d orientation %s role %d\n", - idx, orientation == Qt::Vertical ? "vertical":"horizontal", role)); + LOGDEB2("RecollModel::headerData: idx " << (idx) << " orientation " << (orientation == Qt::Vertical ? "vertical":"horizontal") << " role " << (role) << "\n" ); if (orientation == Qt::Vertical && role == Qt::DisplayRole) { return idx; } @@ -354,8 +353,7 @@ QVariant RecollModel::headerData(int idx, Qt::Orientation orientation, QVariant RecollModel::data(const QModelIndex& index, int role) const { - LOGDEB2(("RecollModel::data: row %d col %d role %d\n", index.row(), - index.column(), role)); + LOGDEB2("RecollModel::data: row " << (index.row()) << " col " << (index.column()) << " role " << (role) << "\n" ); if (!m_source || role != Qt::DisplayRole || !index.isValid() || index.column() >= int(m_fields.size())) { return QVariant(); @@ -410,7 +408,7 @@ void RecollModel::sort(int column, Qt::SortOrder order) { if (m_ignoreSort) return; - LOGDEB(("RecollModel::sort(%d, %d)\n", column, int(order))); + LOGDEB("RecollModel::sort(" << (column) << ", " << (int(order)) << ")\n" ); DocSeqSortSpec spec; if (column >= 0 && column < int(m_fields.size())) { @@ -592,7 +590,7 @@ int ResTable::getDetailDocNumOrTopRow() void ResTable::makeRowVisible(int row) { - LOGDEB(("ResTable::showRow(%d)\n", row)); + LOGDEB("ResTable::showRow(" << (row) << ")\n" ); QModelIndex modelIndex = m_model->index(row, 0); tableView->scrollTo(modelIndex, QAbstractItemView::PositionAtTop); tableView->selectionModel()->clear(); @@ -611,7 +609,7 @@ void ResTable::saveColState() QHeaderView *header = tableView->horizontalHeader(); const vector& vf = m_model->getFields(); if (!header) { - LOGERR(("ResTable::saveColState: no table header ??\n")); + LOGERR("ResTable::saveColState: no table header ??\n" ); return; } @@ -622,7 +620,7 @@ void ResTable::saveColState() for (int vi = 0; vi < header->count(); vi++) { int li = header->logicalIndex(vi); if (li < 0 || li >= int(vf.size())) { - LOGERR(("saveColState: logical index beyond list size!\n")); + LOGERR("saveColState: logical index beyond list size!\n" ); continue; } newfields.push_back(QString::fromUtf8(vf[li].c_str())); @@ -634,8 +632,7 @@ void ResTable::saveColState() void ResTable::onTableView_currentChanged(const QModelIndex& index) { - LOGDEB2(("ResTable::onTableView_currentChanged(%d, %d)\n", - index.row(), index.column())); + LOGDEB2("ResTable::onTableView_currentChanged(" << (index.row()) << ", " << (index.column()) << ")\n" ); if (!m_model || !m_model->getDocSource()) return; @@ -653,21 +650,20 @@ void ResTable::onTableView_currentChanged(const QModelIndex& index) void ResTable::on_tableView_entered(const QModelIndex& index) { - LOGDEB2(("ResTable::on_tableView_entered(%d, %d)\n", - index.row(), index.column())); + LOGDEB2("ResTable::on_tableView_entered(" << (index.row()) << ", " << (index.column()) << ")\n" ); if (!tableView->selectionModel()->hasSelection()) onTableView_currentChanged(index); } void ResTable::takeFocus() { -// LOGDEB(("resTable: take focus\n")); +// LOGDEB("resTable: take focus\n" ); tableView->setFocus(Qt::ShortcutFocusReason); } void ResTable::setDocSource(STD_SHARED_PTR nsource) { - LOGDEB(("ResTable::setDocSource\n")); + LOGDEB("ResTable::setDocSource\n" ); if (m_model) m_model->setDocSource(nsource); if (m_pager) @@ -679,13 +675,13 @@ void ResTable::setDocSource(STD_SHARED_PTR nsource) void ResTable::resetSource() { - LOGDEB(("ResTable::resetSource\n")); + LOGDEB("ResTable::resetSource\n" ); setDocSource(STD_SHARED_PTR()); } void ResTable::saveAsCSV() { - LOGDEB(("ResTable::saveAsCSV\n")); + LOGDEB("ResTable::saveAsCSV\n" ); if (!m_model) return; QString s = @@ -709,8 +705,7 @@ void ResTable::saveAsCSV() // This is called when the sort order is changed from another widget void ResTable::onSortDataChanged(DocSeqSortSpec spec) { - LOGDEB(("ResTable::onSortDataChanged: [%s] desc %d\n", - spec.field.c_str(), int(spec.desc))); + LOGDEB("ResTable::onSortDataChanged: [" << (spec.field) << "] desc " << (int(spec.desc)) << "\n" ); QHeaderView *header = tableView->horizontalHeader(); if (!header || !m_model) return; @@ -734,7 +729,7 @@ void ResTable::onSortDataChanged(DocSeqSortSpec spec) void ResTable::resetSort() { - LOGDEB(("ResTable::resetSort()\n")); + LOGDEB("ResTable::resetSort()\n" ); QHeaderView *header = tableView->horizontalHeader(); if (header) header->setSortIndicator(-1, Qt::AscendingOrder); @@ -745,7 +740,7 @@ void ResTable::resetSort() void ResTable::readDocSource(bool resetPos) { - LOGDEB(("ResTable::readDocSource(%d)\n", int(resetPos))); + LOGDEB("ResTable::readDocSource(" << (int(resetPos)) << ")\n" ); if (resetPos) tableView->verticalScrollBar()->setSliderPosition(0); @@ -761,7 +756,7 @@ void ResTable::linkWasClicked(const QUrl &url) } QString s = url.toString(); const char *ascurl = s.toUtf8(); - LOGDEB(("ResTable::linkWasClicked: [%s]\n", ascurl)); + LOGDEB("ResTable::linkWasClicked: [" << (ascurl) << "]\n" ); int i = atoi(ascurl+1) -1; int what = ascurl[0]; @@ -821,7 +816,7 @@ void ResTable::linkWasClicked(const QUrl &url) break; default: - LOGERR(("ResTable::linkWasClicked: bad link [%s]\n", ascurl)); + LOGERR("ResTable::linkWasClicked: bad link [" << (ascurl) << "]\n" ); break;// ?? } } @@ -844,7 +839,7 @@ void ResTable::onDoubleClick(const QModelIndex& index) 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) { int opts = m_ismainres? ResultPopup::isMain : 0; @@ -975,7 +970,7 @@ void ResTable::menuShowSubDocs() 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(); if (!header || !m_model) return; @@ -1021,7 +1016,7 @@ void ResTable::addColumn() if (!m_model) return; QAction *action = (QAction *)sender(); - LOGDEB(("addColumn: text %s, data %s\n", qs2utf8s(action->text()).c_str(), - qs2utf8s(action->data().toString()).c_str())); + LOGDEB("addColumn: text " << (qs2utf8s(action->text())) << ", data " << (qs2utf8s(action->data().toString())) << "\n" ); m_model->addColumn(m_popcolumn, qs2utf8s(action->data().toString())); } + diff --git a/src/qtgui/searchclause_w.cpp b/src/qtgui/searchclause_w.cpp index 6d4fa584..8f6be03d 100644 --- a/src/qtgui/searchclause_w.cpp +++ b/src/qtgui/searchclause_w.cpp @@ -17,8 +17,7 @@ #include "autoconfig.h" #include "recoll.h" -#include "debuglog.h" - +#include "log.h" #include "searchclause_w.h" #include @@ -142,7 +141,7 @@ SearchDataClause *SearchClauseW::getClause() void SearchClauseW::setFromClause(SearchDataClauseSimple *cl) { - LOGDEB(("SearchClauseW::setFromClause\n")); + LOGDEB("SearchClauseW::setFromClause\n" ); switch(cl->getTp()) { case SCLT_OR: if (cl->getexclude()) tpChange(2); else tpChange(0); break; case SCLT_AND: tpChange(1); break; @@ -151,7 +150,7 @@ void SearchClauseW::setFromClause(SearchDataClauseSimple *cl) case SCLT_FILENAME: tpChange(5); break; default: return; } - LOGDEB(("SearchClauseW::setFromClause: calling erase\n")); + LOGDEB("SearchClauseW::setFromClause: calling erase\n" ); clear(); QString text = QString::fromUtf8(cl->gettext().c_str()); @@ -220,3 +219,4 @@ void SearchClauseW::tpChange(int index) fldCMB->show(); } } + diff --git a/src/qtgui/snippets_w.cpp b/src/qtgui/snippets_w.cpp index eb5fcbfd..7713c721 100644 --- a/src/qtgui/snippets_w.cpp +++ b/src/qtgui/snippets_w.cpp @@ -32,7 +32,7 @@ using namespace std; #endif #include -#include "debuglog.h" +#include "log.h" #include "recoll.h" #include "snippets_w.h" #include "guiutils.h" @@ -170,7 +170,7 @@ void SnippetsW::init() } list lr; 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; } nomatch = false; @@ -238,7 +238,7 @@ void SnippetsW::slotSearchTextChanged(const QString& txt) void SnippetsW::linkWasClicked(const QUrl &url) { string ascurl = (const char *)url.toString().toUtf8(); - LOGDEB(("Snippets::linkWasClicked: [%s]\n", ascurl.c_str())); + LOGDEB("Snippets::linkWasClicked: [" << (ascurl) << "]\n" ); if (ascurl.size() > 3) { 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" ); } + diff --git a/src/qtgui/spell_w.cpp b/src/qtgui/spell_w.cpp index b53d943f..67f7d6f8 100644 --- a/src/qtgui/spell_w.cpp +++ b/src/qtgui/spell_w.cpp @@ -35,7 +35,7 @@ #include #include -#include "debuglog.h" +#include "log.h" #include "recoll.h" #include "spell_w.h" #include "guiutils.h" @@ -147,7 +147,7 @@ void SpellW::doExpand() string reason; if (!maybeOpenDb(reason)) { 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; } @@ -178,7 +178,7 @@ void SpellW::doExpand() string l_stemlang = qs2utf8s(stemLangCMB->currentText()); if (!rcldb->termMatch(mt, l_stemlang, expr, res, maxexpand)) { - LOGERR(("SpellW::doExpand:rcldb::termMatch failed\n")); + LOGERR("SpellW::doExpand:rcldb::termMatch failed\n" ); return; } statsLBL->setText(tr("Index: %1 documents, average length %2 terms." @@ -192,19 +192,19 @@ void SpellW::doExpand() #ifdef RCL_USE_ASPELL case TYPECMB_ASPELL: { - LOGDEB(("SpellW::doExpand: aspelling\n")); + LOGDEB("SpellW::doExpand: aspelling\n" ); if (!aspell) { QMessageBox::warning(0, "Recoll", tr("Aspell init failed. " "Aspell not installed?")); - LOGDEB(("SpellW::doExpand: aspell init error\n")); + LOGDEB("SpellW::doExpand: aspell init error\n" ); return; } list suggs; if (!aspell->suggest(*rcldb, expr, suggs, reason)) { QMessageBox::warning(0, "Recoll", tr("Aspell expansion error. ")); - LOGERR(("SpellW::doExpand:suggest failed: %s\n", reason.c_str())); + LOGERR("SpellW::doExpand:suggest failed: " << (reason) << "\n" ); } for (list::const_iterator it = suggs.begin(); it != suggs.end(); it++) @@ -253,7 +253,7 @@ void SpellW::doExpand() for (vector::iterator it = res.entries.begin(); 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]; if (it->wcf) sprintf(num, "%d / %d", it->docs, it->wcf); @@ -275,7 +275,7 @@ void SpellW::showStats() Rcl::DbStats res; if (!rcldb->dbStats(res)) { - LOGERR(("SpellW::doExpand:rcldb::dbStats failed\n")); + LOGERR("SpellW::doExpand:rcldb::dbStats failed\n" ); return; } @@ -365,7 +365,7 @@ void SpellW::showStats() STD_SHARED_PTR rq(sd); Rcl::Query query(rcldb); if (!query.setQuery(rq)) { - LOGERR(("Query setup failed: %s",query.getReason().c_str())); + LOGERR("Query setup failed: " << (query.getReason()) << "" ); return; } int cnt = query.getResCnt(); @@ -521,3 +521,4 @@ bool SpellW::eventFilter(QObject *target, QEvent *event) } return false; } + diff --git a/src/qtgui/ssearch_w.cpp b/src/qtgui/ssearch_w.cpp index 767ca994..7b247913 100644 --- a/src/qtgui/ssearch_w.cpp +++ b/src/qtgui/ssearch_w.cpp @@ -33,7 +33,7 @@ #include #include -#include "debuglog.h" +#include "log.h" #include "guiutils.h" #include "searchdata.h" #include "ssearch_w.h" @@ -95,7 +95,7 @@ void SSearch::init() void SSearch::takeFocus() { - LOGDEB2(("SSearch: take focus\n")); + LOGDEB2("SSearch: take focus\n" ); queryText->setFocus(Qt::ShortcutFocusReason); // If the focus was already in the search entry, the text is not selected. // Do it for consistency @@ -105,15 +105,14 @@ void SSearch::takeFocus() void SSearch::timerDone() { QString qs = queryText->currentText(); - LOGDEB1(("SSearch::timerDone: qs [%s]\n", qs2utf8s(qs).c_str())); + LOGDEB1("SSearch::timerDone: qs [" << (qs2utf8s(qs)) << "]\n" ); searchTextChanged(qs); } void SSearch::searchTextChanged(const QString& text) { QString qs = queryText->currentText(); - LOGDEB1(("SSearch::searchTextChanged. ks %d qs [%s]\n", - m_keystroke, qs2utf8s(text).c_str())); + LOGDEB1("SSearch::searchTextChanged. ks " << (m_keystroke) << " qs [" << (qs2utf8s(text)) << "]\n" ); if (text.isEmpty()) { searchPB->setEnabled(false); clearqPB->setEnabled(false); @@ -130,8 +129,7 @@ void SSearch::searchTextChanged(const QString& text) m_disableAutosearch = true; string s; int cs = partialWord(s); - LOGDEB1(("SSearch::searchTextChanged: autosearch. cs %d s [%s]\n", - cs, s.c_str())); + LOGDEB1("SSearch::searchTextChanged: autosearch. cs " << (cs) << " s [" << (s) << "]\n" ); if (cs < 0) { startSimpleSearch(); } else if (!m_stroketimeout->isActive() && s.size() >= 2) { @@ -146,7 +144,7 @@ void SSearch::searchTextChanged(const QString& text) void SSearch::searchTypeChanged(int typ) { - LOGDEB(("Search type now %d\n", typ)); + LOGDEB("Search type now " << (typ) << "\n" ); // Adjust context help if (typ == SST_LANG) HelpClient::installMap((const char *)this->objectName().toUtf8(), @@ -188,7 +186,7 @@ void SSearch::searchTypeChanged(int typ) void SSearch::startSimpleSearch() { 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) return; @@ -201,7 +199,7 @@ void SSearch::startSimpleSearch() if (!startSimpleSearch(u8)) return; - LOGDEB(("startSimpleSearch: updating history\n")); + LOGDEB("startSimpleSearch: updating history\n" ); // Search terms history: // 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 ? @@ -242,7 +240,7 @@ string SSearch::asXML() 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(); ostringstream xml; @@ -309,7 +307,7 @@ bool SSearch::startSimpleSearch(const string& u8, int maxexp) xml << "\n"; m_xml = xml.str(); - LOGDEB(("SSearch::startSimpleSearch:xml:[%s]\n", m_xml.c_str())); + LOGDEB("SSearch::startSimpleSearch:xml:[" << (m_xml) << "]\n" ); STD_SHARED_PTR rsdata(sdata); emit startSearch(rsdata, true); @@ -392,7 +390,7 @@ bool SSearch::hasSearchString() static const char* punct = " \t()<>\"'[]{}!^*.,:;\n\r"; 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::size_type pos = t.find_last_not_of(punct); if (pos == string::npos) @@ -414,8 +412,7 @@ void SSearch::addTerm(QString term) void SSearch::onWordReplace(const QString& o, const QString& n) { - LOGDEB(("SSearch::onWordReplace: o [%s] n [%s]\n", - qs2utf8s(o).c_str(), qs2utf8s(n).c_str())); + LOGDEB("SSearch::onWordReplace: o [" << (qs2utf8s(o)) << "] n [" << (qs2utf8s(n)) << "]\n" ); QString txt = queryText->currentText(); QRegExp exp = QRegExp(QString("\\b") + o + QString("\\b")); 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. void SSearch::completion() { - LOGDEB(("SSearch::completion\n")); + LOGDEB("SSearch::completion\n" ); m_disableAutosearch = true; m_stroketimeout->stop(); @@ -506,7 +503,7 @@ void SSearch::completion() return; } if (lst.size() >= maxdpy) { - LOGDEB0(("SSearch::completion(): truncating list\n")); + LOGDEB0("SSearch::completion(): truncating list\n" ); lst = lst.mid(0, maxdpy); lst.append("[...]"); } @@ -542,7 +539,7 @@ void SSearch::completionTermChosen(const QString& text) void SSearch::wrapupCompletion() { - LOGDEB(("SSearch::wrapupCompletion\n")); + LOGDEB("SSearch::wrapupCompletion\n" ); queryText->clear(); queryText->addItems(prefs.ssearchHistory); @@ -707,9 +704,7 @@ bool SSearch::eventFilter(QObject *target, QEvent *event) event->type() == QEvent::UpdateRequest || event->type() == QEvent::Paint) return false; - LOGDEB2(("SSearch::eventFilter: target %p (%p) type %s\n", - target, queryText->lineEdit(), - eventTypeToStr(event->type()))); + LOGDEB2("SSearch::eventFilter: target " << (target) << " (" << (queryText->lineEdit()) << ") type " << (eventTypeToStr(event->type())) << "\n" ); #endif if (target == queryText->view()) { @@ -725,16 +720,15 @@ bool SSearch::eventFilter(QObject *target, QEvent *event) if (event->type() == QEvent::KeyPress) { QKeyEvent *ke = (QKeyEvent *)event; - LOGDEB1(("SSearch::eventFilter: keyPress (m_escape %d) key %d\n", - m_escape, ke->key())); + LOGDEB1("SSearch::eventFilter: keyPress (m_escape " << (m_escape) << ") key " << (ke->key()) << "\n" ); if (ke->key() == Qt::Key_Escape) { - LOGDEB(("Escape\n")); + LOGDEB("Escape\n" ); m_escape = true; m_disableAutosearch = true; m_stroketimeout->stop(); return true; } else if (m_escape && ke->key() == Qt::Key_Space) { - LOGDEB(("Escape space\n")); + LOGDEB("Escape space\n" ); ke->accept(); completion(); m_escape = false; @@ -750,11 +744,11 @@ bool SSearch::eventFilter(QObject *target, QEvent *event) if (prefs.ssearchAsYouType) { m_disableAutosearch = false; QString qs = queryText->currentText(); - LOGDEB0(("SSearch::eventFilter: start timer, qs [%s]\n", - qs2utf8s(qs).c_str())); + LOGDEB0("SSearch::eventFilter: start timer, qs [" << (qs2utf8s(qs)) << "]\n" ); m_stroketimeout->start(strokeTimeoutMS); } } } return false; } + diff --git a/src/qtgui/uiprefs_w.cpp b/src/qtgui/uiprefs_w.cpp index 91495bd9..e527409f 100644 --- a/src/qtgui/uiprefs_w.cpp +++ b/src/qtgui/uiprefs_w.cpp @@ -49,7 +49,7 @@ #include "pathut.h" #include "uiprefs_w.h" #include "viewaction_w.h" -#include "debuglog.h" +#include "log.h" #include "editdialog.h" #include "rclmain_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); bool stripped; if (!Rcl::Db::testDbDir(dbdir, &stripped)) { @@ -642,3 +642,4 @@ void UIPrefsDialog::addExtraDbPB_clicked() item->setCheckState(Qt::Checked); idxLV->sortItems(); } + diff --git a/src/qtgui/viewaction_w.cpp b/src/qtgui/viewaction_w.cpp index e6802e39..08f0927f 100644 --- a/src/qtgui/viewaction_w.cpp +++ b/src/qtgui/viewaction_w.cpp @@ -34,7 +34,7 @@ using namespace std; #include #include "recoll.h" -#include "debuglog.h" +#include "log.h" #include "guiutils.h" #include "viewaction_w.h" @@ -234,3 +234,4 @@ void ViewAction::editActions() theconfig->setMimeViewerAllEx(s); fillLists(); } + diff --git a/src/qtgui/xmltosd.cpp b/src/qtgui/xmltosd.cpp index fa1e3d70..fd139f80 100644 --- a/src/qtgui/xmltosd.cpp +++ b/src/qtgui/xmltosd.cpp @@ -22,7 +22,7 @@ #include "ssearch_w.h" #include "guiutils.h" -#include "debuglog.h" +#include "log.h" #include "xmltosd.h" #include "smallut.h" #include "recoll.h" @@ -82,21 +82,13 @@ bool SDHXMLHandler::startElement(const QString & /* namespaceURI */, const QString &qName, const QXmlAttributes &attrs) { - LOGDEB2(("SDHXMLHandler::startElement: name [%s]\n", - (const char *)qName.toUtf8())); + LOGDEB2("SDHXMLHandler::startElement: name [" << ((const char *)qName.toUtf8()) << "]\n" ); if (qName == "SD") { // Advanced search history entries have no type. So we're good // either if type is absent, or if it's searchdata int idx = attrs.index("type"); if (idx >= 0 && attrs.value(idx).compare("searchdata")) { - LOGDEB(("XMLTOSD: bad type\n")) - return false; - } - resetTemps(); - // A new search descriptor. Allocate data structure - sd = STD_SHARED_PTR(new SearchData); - if (!sd) { - LOGERR(("SDHXMLHandler::startElement: out of memory\n")); + LOGDEB("XMLTOSD: bad type\n" ); return false; } } @@ -107,8 +99,7 @@ bool SDHXMLHandler::endElement(const QString & /* namespaceURI */, const QString & /* localName */, const QString &qName) { - LOGDEB2(("SDHXMLHandler::endElement: name [%s]\n", - (const char *)qName.toUtf8())); + LOGDEB2("SDHXMLHandler::endElement: name [" << ((const char *)qName.toUtf8()) << "]\n" ); if (qName == "CLT") { if (currentText == "OR") { @@ -147,7 +138,7 @@ bool SDHXMLHandler::endElement(const QString & /* namespaceURI */, c = new SearchDataClauseDist(SCLT_NEAR, text, slack, field); c->setexclude(exclude); } else { - LOGERR(("Bad clause type [%s]\n", qs2utf8s(whatclause).c_str())); + LOGERR("Bad clause type [" << (qs2utf8s(whatclause)) << "]\n" ); return false; } sd->addClause(c); @@ -219,8 +210,7 @@ STD_SHARED_PTR xmlToSearchData(const string& xml) xmlInputSource.setData(QString::fromUtf8(xml.c_str())); if (!reader.parse(xmlInputSource) || !handler.isvalid) { - LOGERR(("xmlToSearchData: parse failed for [%s]\n", - xml.c_str())); + LOGERR("xmlToSearchData: parse failed for [" << (xml) << "]\n" ); return STD_SHARED_PTR(); } return handler.sd; @@ -270,13 +260,12 @@ bool SSHXMLHandler::startElement(const QString & /* namespaceURI */, const QString &qName, const QXmlAttributes &attrs) { - LOGDEB2(("SSHXMLHandler::startElement: name [%s]\n", - (const char *)qName.toUtf8())); + LOGDEB2("SSHXMLHandler::startElement: name [" << ((const char *)qName.toUtf8()) << "]\n" ); if (qName == "SD") { // Simple search saved data has a type='ssearch' attribute. int idx = attrs.index("type"); if (idx < 0 && attrs.value(idx).compare("ssearch")) { - LOGDEB(("XMLTOSSS: bad type\n")); + LOGDEB("XMLTOSSS: bad type\n" ); return false; } resetTemps(); @@ -288,8 +277,7 @@ bool SSHXMLHandler::endElement(const QString & /* namespaceURI */, const QString & /* localName */, const QString &qName) { - LOGDEB2(("SSHXMLHandler::endElement: name [%s]\n", - (const char *)qName.toUtf8())); + LOGDEB2("SSHXMLHandler::endElement: name [" << ((const char *)qName.toUtf8()) << "]\n" ); currentText = currentText.trimmed(); @@ -309,7 +297,7 @@ bool SSHXMLHandler::endElement(const QString & /* namespaceURI */, } else if (!currentText.compare("AND")) { data.mode = SSearch::SST_ALL; } else { - LOGERR(("BAD SEARCH MODE: [%s]\n", qs2utf8s(currentText).c_str())); + LOGERR("BAD SEARCH MODE: [" << (qs2utf8s(currentText)) << "]\n" ); return false; } } else if (qName == "AS") { @@ -336,10 +324,10 @@ bool xmlToSSearch(const string& xml, SSearchDef& data) xmlInputSource.setData(QString::fromUtf8(xml.c_str())); if (!reader.parse(xmlInputSource) || !handler.isvalid) { - LOGERR(("xmlToSSearch: parse failed for [%s]\n", - xml.c_str())); + LOGERR("xmlToSSearch: parse failed for [" << (xml) << "]\n" ); return false; } data = handler.data; return true; } + diff --git a/src/query/docseq.cpp b/src/query/docseq.cpp index ebd89e89..928bf7c6 100644 --- a/src/query/docseq.cpp +++ b/src/query/docseq.cpp @@ -19,7 +19,7 @@ #include "docseq.h" #include "filtseq.h" #include "sortseq.h" -#include "debuglog.h" +#include "log.h" #include "internfile.h" PTMutexInit DocSequence::o_dblock; @@ -43,7 +43,7 @@ bool DocSequence::getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc) { Rcl::Db *db = getDb(); if (db == 0) { - LOGERR(("DocSequence::getEnclosing: no db\n")); + LOGERR("DocSequence::getEnclosing: no db\n" ); return false; } PTMutexLocker locker(o_dblock); @@ -67,7 +67,7 @@ void DocSource::stripStack() bool DocSource::buildStack() { - LOGDEB2(("DocSource::buildStack()\n")); + LOGDEB2("DocSource::buildStack()\n" ); stripStack(); if (!m_seq) @@ -77,7 +77,7 @@ bool DocSource::buildStack() // truncates the original list) if (m_seq->canFilter()) { if (!m_seq->setFiltSpec(m_fspec)) { - LOGERR(("DocSource::buildStack: setfiltspec failed\n")); + LOGERR("DocSource::buildStack: setfiltspec failed\n" ); } } else { if (m_fspec.isNotNull()) { @@ -88,7 +88,7 @@ bool DocSource::buildStack() if (m_seq->canSort()) { if (!m_seq->setSortSpec(m_sspec)) { - LOGERR(("DocSource::buildStack: setsortspec failed\n")); + LOGERR("DocSource::buildStack: setsortspec failed\n" ); } } else { if (m_sspec.isNotNull()) { @@ -114,7 +114,7 @@ string DocSource::title() bool DocSource::setFiltSpec(const DocSeqFiltSpec &f) { - LOGDEB2(("DocSource::setFiltSpec\n")); + LOGDEB2("DocSource::setFiltSpec\n" ); m_fspec = f; buildStack(); return true; @@ -122,9 +122,10 @@ bool DocSource::setFiltSpec(const DocSeqFiltSpec &f) bool DocSource::setSortSpec(const DocSeqSortSpec &s) { - LOGDEB2(("DocSource::setSortSpec\n")); + LOGDEB2("DocSource::setSortSpec\n" ); m_sspec = s; buildStack(); return true; } + diff --git a/src/query/docseqdb.cpp b/src/query/docseqdb.cpp index 75f84b9e..a0c4f998 100644 --- a/src/query/docseqdb.cpp +++ b/src/query/docseqdb.cpp @@ -23,7 +23,7 @@ #include "docseqdb.h" #include "rcldb.h" -#include "debuglog.h" +#include "log.h" #include "wasatorcl.h" using std::list; @@ -77,7 +77,7 @@ static const string cstr_mre("[...]"); // We ignore most abstract/snippets preferences. bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector& vpabs) { - LOGDEB(("DocSequenceDb::getAbstract/pair\n")); + LOGDEB("DocSequenceDb::getAbstract/pair\n" ); PTMutexLocker locker(o_dblock); if (!setQuery()) return false; @@ -89,8 +89,7 @@ bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector& vpabs) ret = m_q->makeDocAbstract(doc, vpabs, maxoccs, m_q->whatDb()->getAbsCtxLen()+ 2); } - LOGDEB(("DocSequenceDb::getAbstract: got ret %d vpabs len %u\n", ret, - vpabs.size())); + LOGDEB("DocSequenceDb::getAbstract: got ret " << (ret) << " vpabs len " << (vpabs.size()) << "\n" ); if (vpabs.empty()) { return true; } @@ -161,7 +160,7 @@ string DocSequenceDb::title() bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs) { - LOGDEB(("DocSequenceDb::setFiltSpec\n")); + LOGDEB("DocSequenceDb::setFiltSpec\n" ); PTMutexLocker locker(o_dblock); if (fs.isNotNull()) { // 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) { - LOGDEB(("DocSequenceDb::setSortSpec: fld [%s] %s\n", - spec.field.c_str(), spec.desc ? "desc" : "asc")); + LOGDEB("DocSequenceDb::setSortSpec: fld [" << (spec.field) << "] " << (spec.desc ? "desc" : "asc") << "\n" ); PTMutexLocker locker(o_dblock); if (spec.isNotNull()) { m_q->setSortBy(spec.field, !spec.desc); @@ -233,8 +231,7 @@ bool DocSequenceDb::setQuery() m_lastSQStatus = m_q->setQuery(m_fsdata); if (!m_lastSQStatus) { m_reason = m_q->getReason(); - LOGERR(("DocSequenceDb::setQuery: rclquery::setQuery failed: %s\n", - m_reason.c_str())); + LOGERR("DocSequenceDb::setQuery: rclquery::setQuery failed: " << (m_reason) << "\n" ); } return m_lastSQStatus; } @@ -248,3 +245,4 @@ bool DocSequenceDb::docDups(const Rcl::Doc& doc, std::vector& dups) return false; } } + diff --git a/src/query/docseqhist.cpp b/src/query/docseqhist.cpp index c89a93c1..4a3d40e6 100644 --- a/src/query/docseqhist.cpp +++ b/src/query/docseqhist.cpp @@ -26,7 +26,7 @@ using std::list; #include "rcldb.h" #include "fileudi.h" #include "base64.h" -#include "debuglog.h" +#include "log.h" #include "smallut.h" // 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 make_udi(fn, ipath, udi); } - LOGDEB1(("RclDHistoryEntry::decode: udi [%s]\n", udi.c_str())); + LOGDEB1("RclDHistoryEntry::decode: udi [" << (udi) << "]\n" ); return true; } @@ -89,8 +89,7 @@ bool RclDHistoryEntry::equal(const DynConfEntry& other) bool historyEnterDoc(RclDynConf *dncf, const string& udi) { - LOGDEB1(("historyEnterDoc: [%s] into %s\n", - udi.c_str(), dncf->getFilename().c_str())); + LOGDEB1("historyEnterDoc: [" << (udi) << "] into " << (dncf->getFilename()) << "\n" ); RclDHistoryEntry ne(time(0), udi); RclDHistoryEntry scratch; return dncf->insertNew(docHistSubKey, ne, scratch, 200); @@ -161,3 +160,4 @@ int DocSequenceHistory::getResCnt() m_hlist = getDocHistory(m_hist); return int(m_hlist.size()); } + diff --git a/src/query/dynconf.cpp b/src/query/dynconf.cpp index c8527071..17e6338a 100644 --- a/src/query/dynconf.cpp +++ b/src/query/dynconf.cpp @@ -23,7 +23,7 @@ #include "dynconf.h" #include "base64.h" #include "smallut.h" -#include "debuglog.h" +#include "log.h" 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++) { string oval; if (!m_data.get(*it, oval, sk)) { - LOGDEB(("No data for %s\n", (*it).c_str())); + LOGDEB("No data for " << ((*it)) << "\n" ); continue; } s.decode(oval); if (s.equal(n)) { - LOGDEB(("Erasing old entry\n")); + LOGDEB("Erasing old entry\n" ); m_data.erase(*it, sk); changed = true; } @@ -80,9 +80,9 @@ bool RclDynConf::insertNew(const string &sk, DynConfEntry &n, DynConfEntry &s, string 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)) { - LOGERR(("RclDHistory::insertNew: set failed\n")); + LOGERR("RclDHistory::insertNew: set failed\n" ); return false; } return true; @@ -124,7 +124,8 @@ list RclDynConf::getStringList(const string sk) #include #include "history.h" -#include "debuglog.h" +#include "log.h" + #ifndef NO_NAMESPACES using namespace std; @@ -211,3 +212,4 @@ int main(int argc, char **argv) } #endif + diff --git a/src/query/filtseq.cpp b/src/query/filtseq.cpp index 2c9b1c17..02f14871 100644 --- a/src/query/filtseq.cpp +++ b/src/query/filtseq.cpp @@ -15,7 +15,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "debuglog.h" +#include "log.h" #include "filtseq.h" #include "rclconfig.h" @@ -23,20 +23,19 @@ using std::string; 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: // 1st ok ends for (unsigned int i = 0; i < fs.crits.size(); i++) { switch (fs.crits[i]) { case DocSeqFiltSpec::DSFS_MIMETYPE: - LOGDEB2((" filter: MIMETYPE: me [%s] doc [%s]\n", - fs.values[i].c_str(), x->mimetype.c_str())); + LOGDEB2(" filter: MIMETYPE: me [" << (fs.values[i]) << "] doc [" << (x->mimetype) << "]\n" ); if (x->mimetype == fs.values[i]) return true; break; case DocSeqFiltSpec::DSFS_QLANG: { - LOGDEB((" filter: QLANG [%s]!!\n", fs.values[i].c_str())); + LOGDEB(" filter: QLANG [" << (fs.values[i]) << "]!!\n" ); } break; case DocSeqFiltSpec::DSFS_PASSALL: @@ -56,7 +55,7 @@ DocSeqFiltered::DocSeqFiltered(RclConfig *conf, STD_SHARED_PTR iseq bool DocSeqFiltered::setFiltSpec(const DocSeqFiltSpec &filtspec) { - LOGDEB0(("DocSeqFiltered::setFiltSpec\n")); + LOGDEB0("DocSeqFiltered::setFiltSpec\n" ); for (unsigned int i = 0; i < filtspec.crits.size(); i++) { switch (filtspec.crits[i]) { case DocSeqFiltSpec::DSFS_MIMETYPE: @@ -74,7 +73,7 @@ bool DocSeqFiltered::setFiltSpec(const DocSeqFiltSpec &filtspec) m_config->getMimeCatTypes(catg, tps); for (vector::const_iterator it = tps.begin(); it != tps.end(); it++) { - LOGDEB2(("Adding mime: [%s]\n", it->c_str())); + LOGDEB2("Adding mime: [" << (it) << "]\n" ); 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 *) { - LOGDEB2(("DocSeqFiltered::getDoc() fetching %d\n", idx)); + LOGDEB2("DocSeqFiltered::getDoc() fetching " << (idx) << "\n" ); if (idx >= (int)m_dbindices.size()) { // 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; } + diff --git a/src/query/plaintorich.cpp b/src/query/plaintorich.cpp index 559c9002..a1752e46 100644 --- a/src/query/plaintorich.cpp +++ b/src/query/plaintorich.cpp @@ -31,7 +31,7 @@ using std::set; #include "rcldb.h" #include "rclconfig.h" -#include "debuglog.h" +#include "log.h" #include "textsplit.h" #include "utf8iter.h" #include "smallut.h" @@ -86,14 +86,12 @@ class TextSplitPTR : public TextSplit { string dumb = term; if (o_index_stripchars) { if (!unacmaybefold(term, dumb, "UTF-8", UNACOP_UNACFOLD)) { - LOGINFO(("PlainToRich::takeword: unac failed for [%s]\n", - term.c_str())); + LOGINFO("PlainToRich::takeword: unac failed for [" << (term) << "]\n" ); return true; } } - //LOGDEB2(("Input dumbbed term: '%s' %d %d %d\n", dumb.c_str(), - // pos, bts, bte)); + //LOGDEB2("Input dumbbed term: '" << (dumb) << "' " << (// pos) << " " << (bts) << " " << (bte) << "\n" ); // If this word is a search term, remember its byte-offset span. map::const_iterator it = m_terms.find(dumb); @@ -106,7 +104,7 @@ class TextSplitPTR : public TextSplit { // Term group (phrase/near) handling m_plists[dumb].push_back(pos); m_gpostobytes[pos] = pair(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 @@ -169,8 +167,7 @@ static bool do_proximity_test(int window, vector* >& plists, unsigned int i, int min, int max, int *sp, int *ep, int minpos) { - LOGDEB1(("do_prox_test: win %d i %d min %d max %d minpos %d\n", - window, i, min, max, minpos)); + LOGDEB1("do_prox_test: win " << (window) << " i " << (i) << " min " << (min) << " max " << (max) << " minpos " << (minpos) << "\n" ); int tmp = max + 1 - window; if (tmp < minpos) tmp = minpos; @@ -207,8 +204,7 @@ bool TextSplitPTR::matchGroup(unsigned int grpidx) const vector& terms = m_hdata.groups[grpidx]; int window = int(m_hdata.groups[grpidx].size() + m_hdata.slacks[grpidx]); - LOGDEB1(("TextSplitPTR::matchGroup:d %d: %s\n", window, - vecStringToString(terms).c_str())); + LOGDEB1("TextSplitPTR::matchGroup:d " << (window) << ": " << (vecStringToString(terms)) << "\n" ); // The position lists we are going to work with. We extract them from the // (string->plist) map @@ -224,8 +220,7 @@ bool TextSplitPTR::matchGroup(unsigned int grpidx) it != terms.end(); it++) { map >::iterator pl = m_plists.find(*it); if (pl == m_plists.end()) { - LOGDEB1(("TextSplitPTR::matchGroup: [%s] not found in m_plists\n", - (*it).c_str())); + LOGDEB1("TextSplitPTR::matchGroup: [" << ((*it)) << "] not found in m_plists\n" ); return false; } 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 // prune the groups, but doesn't hurt. if (plists.size() < 2) { - LOGDEB1(("TextSplitPTR::matchGroup: no actual groups found\n")); + LOGDEB1("TextSplitPTR::matchGroup: no actual groups found\n" ); return false; } // 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]); if (it == plistToTerm.end()) { // SuperWeird - LOGERR(("matchGroup: term for first list not found !?!\n")); + LOGERR("matchGroup: term for first list not found !?!\n" ); return false; } - LOGDEB1(("matchGroup: walking the shortest plist. Term [%s], len %d\n", - it->second.c_str(), plists[0]->size())); + LOGDEB1("matchGroup: walking the shortest plist. Term [" << (it->second) << "], len " << (plists[0]->size()) << "\n" ); } // 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++) { int pos = *it; 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)) { - LOGDEB1(("TextSplitPTR::matchGroup: MATCH termpos [%d,%d]\n", - sta, sto)); + LOGDEB1("TextSplitPTR::matchGroup: MATCH termpos [" << (sta) << "," << (sto) << "]\n" ); // Maybe extend the window by 1st term position, this was not // done by do_prox.. SETMINMAX(pos, sta, sto); @@ -274,15 +267,14 @@ bool TextSplitPTR::matchGroup(unsigned int grpidx) map >::iterator i1 = m_gpostobytes.find(sta); map >::iterator i2 = m_gpostobytes.find(sto); if (i1 != m_gpostobytes.end() && i2 != m_gpostobytes.end()) { - LOGDEB2(("TextSplitPTR::matchGroup: pushing bpos %d %d\n", - i1->second.first, i2->second.second)); + LOGDEB2("TextSplitPTR::matchGroup: pushing bpos " << (i1->second.first) << " " << (i2->second.second) << "\n" ); tboffs.push_back(MatchEntry(i1->second.first, i2->second.second, grpidx)); } else { - LOGDEB0(("matchGroup: no bpos found for %d or %d\n", sta, sto)); + LOGDEB0("matchGroup: no bpos found for " << (sta) << " or " << (sto) << "\n" ); } } 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; bool ret = true; - LOGDEB1(("plaintorichich: in: [%s]\n", in.c_str())); + LOGDEB1("plaintorichich: in: [" << (in) << "]\n" ); m_hdata = &hdata; // 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 // character, offsets. 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. splitter.matchGroups(); - LOGDEB2(("plaintorich: group match done %d mS\n", chron.millis())); + LOGDEB2("plaintorich: group match done " << (chron.millis()) << " mS\n" ); out.clear(); 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 // (the snippet generator does this...). if (splitter.tboffs.empty()) { - LOGDEB1(("plaintorich: no term matches\n")); + LOGDEB1("plaintorich: no term matches\n" ); ret = false; } @@ -372,7 +364,7 @@ bool PlainToRich::plaintorich(const string& in, #if 0 for (vector >::const_iterator it = splitter.tboffs.begin(); it != splitter.tboffs.end(); it++) { - LOGDEB2(("plaintorich: region: %d %d\n", it->first, it->second)); + LOGDEB2("plaintorich: region: " << (it->first) << " " << (it->second) << "\n" ); } #endif @@ -532,6 +524,7 @@ bool PlainToRich::plaintorich(const string& in, fclose(fp); } #endif - LOGDEB2(("plaintorich: done %d mS\n", chron.millis())); + LOGDEB2("plaintorich: done " << (chron.millis()) << " mS\n" ); return ret; } + diff --git a/src/query/recollq.cpp b/src/query/recollq.cpp index e84b2e0d..22c4bb7b 100644 --- a/src/query/recollq.cpp +++ b/src/query/recollq.cpp @@ -31,7 +31,7 @@ #include "rclconfig.h" #include "pathut.h" #include "rclinit.h" -#include "debuglog.h" +#include "log.h" #include "wasatorcl.h" #include "internfile.h" #include "wipedir.h" @@ -427,3 +427,4 @@ endopts: return 0; } + diff --git a/src/query/reslistpager.cpp b/src/query/reslistpager.cpp index af23a5da..44be35ef 100644 --- a/src/query/reslistpager.cpp +++ b/src/query/reslistpager.cpp @@ -31,7 +31,7 @@ using std::list; #include "cstr.h" #include "reslistpager.h" -#include "debuglog.h" +#include "log.h" #include "rclconfig.h" #include "smallut.h" #include "rclutil.h" @@ -67,13 +67,12 @@ ResListPager::ResListPager(int pagesize) void ResListPager::resultPageNext() { if (!m_docSource) { - LOGDEB(("ResListPager::resultPageNext: null source\n")); + LOGDEB("ResListPager::resultPageNext: null source\n" ); return; } int resCnt = m_docSource->getResCnt(); - LOGDEB(("ResListPager::resultPageNext: rescnt %d, winfirst %d\n", - resCnt, m_winfirst)); + LOGDEB("ResListPager::resultPageNext: rescnt " << (resCnt) << ", winfirst " << (m_winfirst) << "\n" ); if (m_winfirst < 0) { m_winfirst = 0; @@ -125,13 +124,12 @@ static string maybeEscapeHtml(const string& fld) void ResListPager::resultPageFor(int docnum) { if (!m_docSource) { - LOGDEB(("ResListPager::resultPageFor: null source\n")); + LOGDEB("ResListPager::resultPageFor: null source\n" ); return; } int resCnt = m_docSource->getResCnt(); - LOGDEB(("ResListPager::resultPageFor(%d): rescnt %d, winfirst %d\n", - docnum, resCnt, m_winfirst)); + LOGDEB("ResListPager::resultPageFor(" << (docnum) << "): rescnt " << (resCnt) << ", winfirst " << (m_winfirst) << "\n" ); m_winfirst = (docnum / m_pagesize) * m_pagesize; // 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) // chunk << "
" << 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); } @@ -340,13 +338,13 @@ bool ResListPager::getDoc(int num, Rcl::Doc& doc) void ResListPager::displayPage(RclConfig *config) { - LOGDEB(("ResListPager::displayPage\n")); + LOGDEB("ResListPager::displayPage\n" ); if (!m_docSource) { - LOGDEB(("ResListPager::displayPage: null source\n")); + LOGDEB("ResListPager::displayPage: null source\n" ); return; } if (m_winfirst < 0 && !pageEmpty()) { - LOGDEB(("ResListPager::displayPage: sequence error: winfirst < 0\n")); + LOGDEB("ResListPager::displayPage: sequence error: winfirst < 0\n" ); return; } @@ -526,3 +524,4 @@ const string &ResListPager::dateFormat() return cstr_format; } + diff --git a/src/query/sortseq.cpp b/src/query/sortseq.cpp index 6624338b..97492303 100644 --- a/src/query/sortseq.cpp +++ b/src/query/sortseq.cpp @@ -16,7 +16,7 @@ */ #include -#include "debuglog.h" +#include "log.h" #include "sortseq.h" using std::string; @@ -30,7 +30,7 @@ public: // behaves as operator< int operator()(const Rcl::Doc *x, const Rcl::Doc *y) { - LOGDEB1(("Comparing .. \n")); + LOGDEB1("Comparing .. \n" ); map::const_iterator xit, yit; xit = x->meta.find(ss.field); @@ -43,15 +43,15 @@ public: bool DocSeqSorted::setSortSpec(const DocSeqSortSpec &sortspec) { - LOGDEB(("DocSeqSorted::setSortSpec\n")); + LOGDEB("DocSeqSorted::setSortSpec\n" ); m_spec = sortspec; int count = m_seq->getResCnt(); - LOGDEB(("DocSeqSorted:: count %d\n", count)); + LOGDEB("DocSeqSorted:: count " << (count) << "\n" ); m_docs.resize(count); int i; for (i = 0; i < count; 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; break; } @@ -68,9 +68,10 @@ bool DocSeqSorted::setSortSpec(const DocSeqSortSpec &sortspec) 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())) return false; doc = *m_docsp[num]; return true; } + diff --git a/src/query/wasaparseaux.cpp b/src/query/wasaparseaux.cpp index aa6b4fed..85a9d19f 100644 --- a/src/query/wasaparseaux.cpp +++ b/src/query/wasaparseaux.cpp @@ -21,7 +21,7 @@ #include "wasatorcl.h" #include "wasaparserdriver.h" #include "searchdata.h" -#include "debuglog.h" +#include "log.h" #define YYDEBUG 1 @@ -177,14 +177,12 @@ bool WasaParserDriver::addClause(SearchData *sd, if (!fld.compare("date")) { DateInterval di; if (!parsedateinterval(cl->gettext(), &di)) { - LOGERR(("Bad date interval format: %s\n", - cl->gettext().c_str())); + LOGERR("Bad date interval format: " << (cl->gettext()) << "\n" ); m_reason = "Bad date interval format"; delete cl; return false; } - LOGDEB(("addClause:: date span: %d-%d-%d/%d-%d-%d\n", - di.y1,di.m1,di.d1, di.y2,di.m2,di.d2)); + LOGDEB("addClause:: date span: " << (di.y1) << "-" << (di.m1) << "-" << (di.d1) << "/" << (di.y2) << "-" << (di.m2) << "-" << (di.d2) << "\n" ); m_haveDates = true; m_dates = di; delete cl; @@ -268,3 +266,4 @@ bool WasaParserDriver::addClause(SearchData *sd, } return sd->addClause(cl); } + diff --git a/src/rcldb/daterange.cpp b/src/rcldb/daterange.cpp index 6800a2e4..38a21cd5 100644 --- a/src/rcldb/daterange.cpp +++ b/src/rcldb/daterange.cpp @@ -31,7 +31,7 @@ using namespace std; #include -#include "debuglog.h" +#include "log.h" #include "rclconfig.h" namespace Rcl { @@ -124,3 +124,4 @@ Xapian::Query date_range_filter(int y1, int m1, int d1, int y2, int m2, int d2) } + diff --git a/src/rcldb/expansiondbs.cpp b/src/rcldb/expansiondbs.cpp index 2b01f9a8..435fdc3e 100644 --- a/src/rcldb/expansiondbs.cpp +++ b/src/rcldb/expansiondbs.cpp @@ -20,7 +20,7 @@ #include MEMORY_INCLUDE -#include "debuglog.h" +#include "log.h" #include "utf8iter.h" #include "smallut.h" #include "chrono.h" @@ -41,8 +41,7 @@ namespace Rcl { bool createExpansionDbs(Xapian::WritableDatabase& wdb, const vector& langs) { - LOGDEB(("StemDb::createExpansionDbs: languages: %s\n", - stringsToString(langs).c_str())); + LOGDEB("StemDb::createExpansionDbs: languages: " << (stringsToString(langs)) << "\n" ); Chrono cron; // Erase and recreate all the expansion groups @@ -102,7 +101,7 @@ bool createExpansionDbs(Xapian::WritableDatabase& wdb, if (utfit.eof()) // Empty term?? Seems to happen. continue; if (TextSplit::isCJK(*utfit)) { - // LOGDEB(("stemskipped: Skipping CJK\n")); + // LOGDEB("stemskipped: Skipping CJK\n" ); continue; } @@ -119,7 +118,7 @@ bool createExpansionDbs(Xapian::WritableDatabase& wdb, // Dont' apply stemming to terms which don't look like // natural language words. if (!Db::isSpellingCandidate(*it)) { - LOGDEB1(("createExpansionDbs: skipped: [%s]\n", (*it).c_str())); + LOGDEB1("createExpansionDbs: skipped: [" << ((*it)) << "]\n" ); continue; } @@ -145,12 +144,13 @@ bool createExpansionDbs(Xapian::WritableDatabase& wdb, } } XCATCHERROR(ermsg); if (!ermsg.empty()) { - LOGERR(("Db::createStemDb: map build failed: %s\n", ermsg.c_str())); + LOGERR("Db::createStemDb: map build failed: " << (ermsg) << "\n" ); return false; } - LOGDEB(("StemDb::createExpansionDbs: done: %.2f S\n", cron.secs())); + LOGDEB("StemDb::createExpansionDbs: done: " << (cron.secs()) << " S\n" ); return true; } } + diff --git a/src/rcldb/rclabstract.cpp b/src/rcldb/rclabstract.cpp index 6f16f41b..de88b543 100644 --- a/src/rcldb/rclabstract.cpp +++ b/src/rcldb/rclabstract.cpp @@ -20,7 +20,7 @@ #include -#include "debuglog.h" +#include "log.h" #include "rcldb.h" #include "rcldb_p.h" #include "rclquery.h" @@ -50,7 +50,7 @@ static void listList(const string& what, const vector&l) for (vector::const_iterator it = l.begin(); it != l.end(); it++) { a = a + *it + " "; } - LOGDEB(("%s: %s\n", what.c_str(), a.c_str())); + LOGDEB("" << (what) << ": " << (a) << "\n" ); } #else #define LOGABS LOGDEB2 @@ -82,7 +82,7 @@ static void noPrefixList(const vector& in, vector& out) bool Query::Native::getMatchTerms(unsigned long xdocid, vector& terms) { if (!xenquire) { - LOGERR(("Query::getMatchTerms: no query opened\n")); + LOGERR("Query::getMatchTerms: no query opened\n" ); return false; } @@ -95,7 +95,7 @@ bool Query::Native::getMatchTerms(unsigned long xdocid, vector& terms) xenquire->get_matching_terms_end(id)), m_q->m_db->m_ndb->xrdb, m_q->m_reason); 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; } noPrefixList(iterms, terms); @@ -178,7 +178,7 @@ double Query::Native::qualityTerms(Xapian::docid docid, if (eit != hld.terms.end()) { byRoot[eit->second].push_back(*qit); } 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); } } @@ -257,7 +257,7 @@ double Query::Native::qualityTerms(Xapian::docid docid, 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) { - LOGERR(("Query::getFirstMatchPage: no db\n")); + LOGERR("Query::getFirstMatchPage: no db\n" ); return -1; } 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); if (terms.empty()) { - LOGDEB(("getFirstMatchPage: empty match term list (field match?)\n")); + LOGDEB("getFirstMatchPage: empty match term list (field match?)\n" ); return -1; } @@ -322,7 +322,7 @@ int Query::Native::makeAbstract(Xapian::docid docid, vector matchedTerms; getMatchTerms(docid, matchedTerms); if (matchedTerms.empty()) { - LOGDEB(("makeAbstract::Empty term list\n")); + LOGDEB("makeAbstract::Empty term list\n" ); return ABSRES_ERROR; } @@ -342,7 +342,7 @@ int Query::Native::makeAbstract(Xapian::docid docid, LOGABS(("makeAbstract:%d: computed Qcoefs.\n", chron.ms())); // This can't happen, but would crash us if (totalweight == 0.0) { - LOGERR(("makeAbstract: totalweight == 0.0 !\n")); + LOGERR("makeAbstract: totalweight == 0.0 !\n" ); 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 // etc. but not elsewhere ? if (totaloccs == 0) { - LOGDEB(("makeAbstract: no occurrences\n")); + LOGDEB("makeAbstract: no occurrences\n" ); return ABSRES_OK; } @@ -513,8 +513,7 @@ int Query::Native::makeAbstract(Xapian::docid docid, continue; if (m_q->m_snipMaxPosWalk > 0 && cutoff-- < 0) { ret |= ABSRES_TERMMISS; - LOGDEB0(("makeAbstract: max term count cutoff %d\n", - m_q->m_snipMaxPosWalk)); + LOGDEB0("makeAbstract: max term count cutoff " << (m_q->m_snipMaxPosWalk) << "\n" ); break; } @@ -524,8 +523,7 @@ int Query::Native::makeAbstract(Xapian::docid docid, pos != xrdb.positionlist_end(docid, *term); pos++) { if (m_q->m_snipMaxPosWalk > 0 && cutoff-- < 0) { ret |= ABSRES_TERMMISS; - LOGDEB0(("makeAbstract: max term count cutoff %d\n", - m_q->m_snipMaxPosWalk)); + LOGDEB0("makeAbstract: max term count cutoff " << (m_q->m_snipMaxPosWalk) << "\n" ); break; } // 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 // first one (ie: dockes and dockes@wanadoo.fr) if (vit->second.empty()) { - LOGDEB2(("makeAbstract: populating: [%s] at %d\n", - (*term).c_str(), *pos)); + LOGDEB2("makeAbstract: populating: [" << ((*term)) << "] at " << (*pos) << "\n" ); sparseDoc[*pos] = *term; } } @@ -557,11 +554,11 @@ int Query::Native::makeAbstract(Xapian::docid docid, it++, ipos++) { if (it->empty()) { if (!epty) - LOGDEB(("makeAbstract:vec[%d]: [%s]\n", ipos, it->c_str())); + LOGDEB("makeAbstract:vec[" << (ipos) << "]: [" << (it) << "]\n" ); epty=true; } else { epty = false; - LOGDEB(("makeAbstract:vec[%d]: [%s]\n", ipos, it->c_str())); + LOGDEB("makeAbstract:vec[" << (ipos) << "]: [" << (it) << "]\n" ); } } #endif @@ -579,9 +576,9 @@ int Query::Native::makeAbstract(Xapian::docid docid, string term; for (map::const_iterator it = sparseDoc.begin(); 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)) { - LOGDEB(("Abstract: qtrm position not filled ??\n")); + LOGDEB("Abstract: qtrm position not filled ??\n" ); continue; } if (chunk.empty() && !vpbreaks.empty()) { @@ -611,9 +608,10 @@ int Query::Native::makeAbstract(Xapian::docid docid, if (!chunk.empty()) 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; } } + diff --git a/src/rcldb/rcldb.cpp b/src/rcldb/rcldb.cpp index 63f66951..95a842d0 100644 --- a/src/rcldb/rcldb.cpp +++ b/src/rcldb/rcldb.cpp @@ -33,7 +33,7 @@ using namespace std; #include "xapian.h" #include "rclconfig.h" -#include "debuglog.h" +#include "log.h" #include "rcldb.h" #include "rcldb_p.h" #include "stemdb.h" @@ -148,20 +148,19 @@ Db::Native::Native(Db *db) #ifdef IDX_THREADS , m_wqueue("DbUpd", m_rcldb->m_config->getThrConf(RclConfig::ThrDbWrite).first), - m_loglevel(4), m_totalworkns(0LL), m_havewriteq(false) #endif // IDX_THREADS { - LOGDEB1(("Native::Native: me %p\n", this)); + LOGDEB1("Native::Native: me " << (this) << "\n" ); } Db::Native::~Native() { - LOGDEB1(("Native::~Native: me %p\n", this)); + LOGDEB1("Native::~Native: me " << (this) << "\n" ); #ifdef IDX_THREADS if (m_havewriteq) { void *status = m_wqueue.setTerminateAndWait(); - LOGDEB2(("Native::~Native: worker status %ld\n", long(status))); + LOGDEB2("Native::~Native: worker status " << (long(status)) << "\n" ); } #endif // IDX_THREADS } @@ -172,7 +171,6 @@ void *DbUpdWorker(void* vdbp) recoll_threadinit(); Db::Native *ndbp = (Db::Native *)vdbp; WorkQueue *tqp = &(ndbp->m_wqueue); - DebugLog::getdbl()->setloglevel(ndbp->m_loglevel); DbUpdTask *tsk = 0; for (;;) { @@ -184,24 +182,24 @@ void *DbUpdWorker(void* vdbp) bool status = false; switch (tsk->op) { case DbUpdTask::AddOrUpdate: - LOGDEB(("DbUpdWorker: got add/update task, ql %d\n", int(qsz))); + LOGDEB("DbUpdWorker: got add/update task, ql " << (int(qsz)) << "\n" ); status = ndbp->addOrUpdateWrite(tsk->udi, tsk->uniterm, tsk->doc, tsk->txtlen); break; case DbUpdTask::Delete: - LOGDEB(("DbUpdWorker: got delete task, ql %d\n", int(qsz))); + LOGDEB("DbUpdWorker: got delete task, ql " << (int(qsz)) << "\n" ); status = ndbp->purgeFileWrite(false, tsk->udi, tsk->uniterm); break; case DbUpdTask::PurgeOrphans: - LOGDEB(("DbUpdWorker: got orphans purge task, ql %d\n", int(qsz))); + LOGDEB("DbUpdWorker: got orphans purge task, ql " << (int(qsz)) << "\n" ); status = ndbp->purgeFileWrite(true, tsk->udi, tsk->uniterm); break; default: - LOGERR(("DbUpdWorker: unknown op %d !!\n", tsk->op)); + LOGERR("DbUpdWorker: unknown op " << (tsk->op) << " !!\n" ); break; } if (!status) { - LOGERR(("DbUpdWorker: xxWrite failed\n")); + LOGERR("DbUpdWorker: xxWrite failed\n" ); tqp->workerExit(); delete tsk; return (void*)0; @@ -212,25 +210,22 @@ void *DbUpdWorker(void* vdbp) void Db::Native::maybeStartThreads() { - m_loglevel = DebugLog::getdbl()->getlevel(); - m_havewriteq = false; const RclConfig *cnf = m_rcldb->m_config; int writeqlen = cnf->getThrConf(RclConfig::ThrDbWrite).first; int writethreads = cnf->getThrConf(RclConfig::ThrDbWrite).second; if (writethreads > 1) { - LOGINFO(("RclDb: write threads count was forced down to 1\n")); + LOGINFO("RclDb: write threads count was forced down to 1\n" ); writethreads = 1; } if (writeqlen >= 0 && writethreads > 0) { if (!m_wqueue.start(writethreads, DbUpdWorker, this)) { - LOGERR(("Db::Db: Worker start failed\n")); + LOGERR("Db::Db: Worker start failed\n" ); return; } m_havewriteq = true; } - LOGDEB(("RclDb:: threads: haveWriteQ %d, wqlen %d wqts %d\n", - m_havewriteq, writeqlen, writethreads)); + LOGDEB("RclDb:: threads: haveWriteQ " << (m_havewriteq) << ", wqlen " << (writeqlen) << " wqts " << (writethreads) << "\n" ); } #endif // IDX_THREADS @@ -241,7 +236,7 @@ void Db::Native::maybeStartThreads() bool Db::Native::subDocs(const string &udi, int idxi, vector& docids) { - LOGDEB2(("subDocs: [%s]\n", uniterm.c_str())); + LOGDEB2("subDocs: [" << (uniterm) << "]\n" ); string pterm = make_parentterm(udi); vector candidates; XAPTRY(docids.clear(); @@ -249,7 +244,7 @@ bool Db::Native::subDocs(const string &udi, int idxi, xrdb.postlist_end(pterm)), xrdb, m_rcldb->m_reason); if (!m_rcldb->m_reason.empty()) { - LOGERR(("Rcl::Db::subDocs: %s\n", m_rcldb->m_reason.c_str())); + LOGERR("Rcl::Db::subDocs: " << (m_rcldb->m_reason) << "\n" ); return false; } else { for (unsigned int i = 0; i < candidates.size(); i++) { @@ -257,7 +252,7 @@ bool Db::Native::subDocs(const string &udi, int idxi, docids.push_back(candidates[i]); } } - LOGDEB0(("Db::Native::subDocs: returning %d ids\n", docids.size())); + LOGDEB0("Db::Native::subDocs: returning " << (docids.size()) << " ids\n" ); return true; } } @@ -269,7 +264,7 @@ bool Db::Native::xdocToUdi(Xapian::Document& xdoc, string &udi) xit.skip_to(wrap_prefix(udi_prefix)), xrdb, m_rcldb->m_reason); if (!m_rcldb->m_reason.empty()) { - LOGERR(("xdocToUdi: xapian error: %s\n", m_rcldb->m_reason.c_str())); + LOGERR("xdocToUdi: xapian error: " << (m_rcldb->m_reason) << "\n" ); return false; } if (xit != xdoc.termlist_end()) { @@ -287,30 +282,27 @@ bool Db::Native::xdocToUdi(Xapian::Document& xdoc, string &udi) // posting, but we have to do it ourselves bool Db::Native::clearDocTermIfWdf0(Xapian::Document& xdoc, const string& term) { - LOGDEB1(("Db::clearDocTermIfWdf0: [%s]\n", term.c_str())); + LOGDEB1("Db::clearDocTermIfWdf0: [" << (term) << "]\n" ); // Find the term Xapian::TermIterator xit; XAPTRY(xit = xdoc.termlist_begin(); xit.skip_to(term);, xrdb, m_rcldb->m_reason); if (!m_rcldb->m_reason.empty()) { - LOGERR(("Db::clearDocTerm...: [%s] skip failed: %s\n", - term.c_str(), m_rcldb->m_reason.c_str())); + LOGERR("Db::clearDocTerm...: [" << (term) << "] skip failed: " << (m_rcldb->m_reason) << "\n" ); return false; } if (xit == xdoc.termlist_end() || term.compare(*xit)) { - LOGDEB0(("Db::clearDocTermIFWdf0: term [%s] not found. xit: [%s]\n", - term.c_str(), xit == xdoc.termlist_end() ? "EOL":(*xit).c_str())); + LOGDEB0("Db::clearDocTermIFWdf0: term [" << (term) << "] not found. xit: [" << (xit == xdoc.termlist_end() ? "EOL":(*xit)) << "]\n" ); return false; } // Clear the term if its frequency is 0 if (xit.get_wdf() == 0) { - LOGDEB1(("Db::clearDocTermIfWdf0: clearing [%s]\n", term.c_str())); + LOGDEB1("Db::clearDocTermIfWdf0: clearing [" << (term) << "]\n" ); XAPTRY(xdoc.remove_term(term), xwdb, m_rcldb->m_reason); if (!m_rcldb->m_reason.empty()) { - LOGDEB0(("Db::clearDocTermIfWdf0: failed [%s]: %s\n", - term.c_str(), m_rcldb->m_reason.c_str())); + LOGDEB0("Db::clearDocTermIfWdf0: failed [" << (term) << "]: " << (m_rcldb->m_reason) << "\n" ); } } return true; @@ -331,8 +323,7 @@ struct DocPosting { bool Db::Native::clearField(Xapian::Document& xdoc, const string& pfx, Xapian::termcount wdfdec) { - LOGDEB1(("Db::clearField: clearing prefix [%s] for docid %u\n", - pfx.c_str(), unsigned(xdoc.get_docid()))); + LOGDEB1("Db::clearField: clearing prefix [" << (pfx) << "] for docid " << (unsigned(xdoc.get_docid())) << "\n" ); vector eraselist; @@ -346,7 +337,7 @@ bool Db::Native::clearField(Xapian::Document& xdoc, const string& pfx, xit.skip_to(wrapd); while (xit != xdoc.termlist_end() && !(*xit).compare(0, wrapd.size(), wrapd)) { - LOGDEB1(("Db::clearfield: erasing for [%s]\n", (*xit).c_str())); + LOGDEB1("Db::clearfield: erasing for [" << ((*xit)) << "]\n" ); Xapian::PositionIterator posit; for (posit = xit.positionlist_begin(); posit != xit.positionlist_end(); posit++) { @@ -363,23 +354,20 @@ bool Db::Native::clearField(Xapian::Document& xdoc, const string& pfx, break; } if (!m_rcldb->m_reason.empty()) { - LOGERR(("Db::clearField: failed building erase list: %s\n", - m_rcldb->m_reason.c_str())); + LOGERR("Db::clearField: failed building erase list: " << (m_rcldb->m_reason) << "\n" ); return false; } // Now remove the found positions, and the terms if the wdf is 0 for (vector::const_iterator it = eraselist.begin(); it != eraselist.end(); it++) { - LOGDEB1(("Db::clearField: remove posting: [%s] pos [%d]\n", - it->term.c_str(), int(it->pos))); + LOGDEB1("Db::clearField: remove posting: [" << (it->term) << "] pos [" << (int(it->pos)) << "]\n" ); XAPTRY(xdoc.remove_posting(it->term, it->pos, wdfdec);, xwdb,m_rcldb->m_reason); if (!m_rcldb->m_reason.empty()) { // Not that this normally fails for non-prefixed XXST and // ND, don't make a fuss - LOGDEB1(("Db::clearFiedl: remove_posting failed for [%s],%d: %s\n", - it->term.c_str(),int(it->pos), m_rcldb->m_reason.c_str())); + LOGDEB1("Db::clearFiedl: remove_posting failed for [" << (it->term) << "]," << (int(it->pos)) << ": " << (m_rcldb->m_reason) << "\n" ); } clearDocTermIfWdf0(xdoc, it->term); } @@ -389,7 +377,7 @@ bool Db::Native::clearField(Xapian::Document& xdoc, const string& pfx, // Check if doc given by udi is indexed by term bool Db::Native::hasTerm(const string& udi, int idxi, const string& term) { - LOGDEB2(("Native::hasTerm: udi [%s] term [%s]\n",udi.c_str(),term.c_str())); + LOGDEB2("Native::hasTerm: udi [" << (udi) << "] term [" << (term) << "]\n" ); Xapian::Document xdoc; if (getDoc(udi, idxi, xdoc)) { Xapian::TermIterator xit; @@ -397,7 +385,7 @@ bool Db::Native::hasTerm(const string& udi, int idxi, const string& term) xit.skip_to(term);, xrdb, m_rcldb->m_reason); if (!m_rcldb->m_reason.empty()) { - LOGERR(("Rcl::Native::hasTerm: %s\n", m_rcldb->m_reason.c_str())); + LOGERR("Rcl::Native::hasTerm: " << (m_rcldb->m_reason) << "\n" ); return false; } if (xit != xdoc.termlist_end() && !term.compare(*xit)) { @@ -431,8 +419,7 @@ Xapian::docid Db::Native::getDoc(const string& udi, int idxi, } XCATCHERROR(m_rcldb->m_reason); break; } - LOGERR(("Db::Native::getDoc: Xapian error: %s\n", - m_rcldb->m_reason.c_str())); + LOGERR("Db::Native::getDoc: Xapian error: " << (m_rcldb->m_reason) << "\n" ); return 0; } @@ -440,7 +427,7 @@ Xapian::docid Db::Native::getDoc(const string& udi, int idxi, bool Db::Native::dbDataToRclDoc(Xapian::docid docid, std::string &data, Doc &doc) { - LOGDEB2(("Db::dbDataToRclDoc: data:\n%s\n", data.c_str())); + LOGDEB2("Db::dbDataToRclDoc: data:\n" << (data) << "\n" ); ConfSimple parms(data); if (!parms.ok()) return false; @@ -511,7 +498,7 @@ bool Db::Native::hasPages(Xapian::docid docid) }, xrdb, ermsg); if (!ermsg.empty()) { - LOGERR(("Db::Native::hasPages: xapian error: %s\n", ermsg.c_str())); + LOGERR("Db::Native::hasPages: xapian error: " << (ermsg) << "\n" ); } return false; } @@ -548,15 +535,13 @@ bool Db::Native::getPagePositions(Xapian::docid docid, vector& vpos) pos != xrdb.positionlist_end(docid, qterm); pos++) { int ipos = *pos; if (ipos < int(baseTextPosition)) { - LOGDEB(("getPagePositions: got page position %d not in body\n", - ipos)); + LOGDEB("getPagePositions: got page position " << (ipos) << " not in body\n" ); // Not in text body. Strange... continue; } map::iterator it = mbreaksmap.find(ipos); if (it != mbreaksmap.end()) { - LOGDEB1(("getPagePositions: found multibreak at %d incr %d\n", - ipos, it->second)); + LOGDEB1("getPagePositions: found multibreak at " << (ipos) << " incr " << (it->second) << "\n" ); for (int i = 0 ; i < it->second; i++) vpos.push_back(ipos); } @@ -596,12 +581,12 @@ bool Db::Native::addOrUpdateWrite(const string& udi, const string& uniterm, if (m_rcldb->m_maxFsOccupPc > 0 && (m_rcldb->m_occFirstCheck || (m_rcldb->m_curtxtsz - m_rcldb->m_occtxtsz) / MB >= 1)) { - LOGDEB(("Db::add: checking file system usage\n")); + LOGDEB("Db::add: checking file system usage\n" ); int pc; m_rcldb->m_occFirstCheck = 0; if (fsocc(m_rcldb->m_basedir, &pc) && pc >= m_rcldb->m_maxFsOccupPc) { - LOGERR(("Db::add: stop indexing: file system " - "%d%% full > max %d%%\n", pc, m_rcldb->m_maxFsOccupPc)); + LOGERR("Db::add: stop indexing: file system " << pc << " %" << + " full > max " << m_rcldb->m_maxFsOccupPc << " %" << "\n"); return false; } m_rcldb->m_occtxtsz = m_rcldb->m_curtxtsz; @@ -619,23 +604,22 @@ bool Db::Native::addOrUpdateWrite(const string& udi, const string& uniterm, // by needUpdate(), so the subdocs existence flags are only set // here. m_rcldb->updated[did] = true; - LOGINFO(("Db::add: docid %d updated [%s]\n", did, fnc)); + LOGINFO("Db::add: docid " << (did) << " updated [" << (fnc) << "]\n" ); } else { - LOGINFO(("Db::add: docid %d added [%s]\n", did, fnc)); + LOGINFO("Db::add: docid " << (did) << " added [" << (fnc) << "]\n" ); } } XCATCHERROR(ermsg); if (!ermsg.empty()) { - LOGERR(("Db::add: replace_document failed: %s\n", ermsg.c_str())); + LOGERR("Db::add: replace_document failed: " << (ermsg) << "\n" ); ermsg.erase(); // FIXME: is this ever actually needed? try { xwdb.add_document(*newdocument_ptr); - LOGDEB(("Db::add: %s added (failed re-seek for duplicate)\n", - fnc)); + LOGDEB("Db::add: " << (fnc) << " added (failed re-seek for duplicate)\n" ); } XCATCHERROR(ermsg); if (!ermsg.empty()) { - LOGERR(("Db::add: add_document failed: %s\n", ermsg.c_str())); + LOGERR("Db::add: add_document failed: " << (ermsg) << "\n" ); return false; } } @@ -674,16 +658,16 @@ bool Db::Native::purgeFileWrite(bool orphansOnly, const string& udi, Xapian::Document doc = xwdb.get_document(*docid); sig = doc.get_value(VALUE_SIG); if (sig.empty()) { - LOGINFO(("purgeFileWrite: got empty sig\n")); + LOGINFO("purgeFileWrite: got empty sig\n" ); return false; } } else { - LOGDEB(("purgeFile: delete docid %d\n", *docid)); + LOGDEB("purgeFile: delete docid " << (*docid) << "\n" ); xwdb.delete_document(*docid); } vector docids; subDocs(udi, 0, docids); - LOGDEB(("purgeFile: subdocs cnt %d\n", docids.size())); + LOGDEB("purgeFile: subdocs cnt " << (docids.size()) << "\n" ); for (vector::iterator it = docids.begin(); it != docids.end(); it++) { if (m_rcldb->m_flushMb > 0) { @@ -695,20 +679,20 @@ bool Db::Native::purgeFileWrite(bool orphansOnly, const string& udi, Xapian::Document doc = xwdb.get_document(*it); subdocsig = doc.get_value(VALUE_SIG); if (subdocsig.empty()) { - LOGINFO(("purgeFileWrite: got empty sig for subdoc??\n")); + LOGINFO("purgeFileWrite: got empty sig for subdoc??\n" ); continue; } } if (!orphansOnly || sig != subdocsig) { - LOGDEB(("Db::purgeFile: delete subdoc %d\n", *it)); + LOGDEB("Db::purgeFile: delete subdoc " << (*it) << "\n" ); xwdb.delete_document(*it); } } return true; } XCATCHERROR(ermsg); if (!ermsg.empty()) { - LOGERR(("Db::purgeFileWrite: %s\n", ermsg.c_str())); + LOGERR("Db::purgeFileWrite: " << (ermsg) << "\n" ); } return false; } @@ -745,11 +729,10 @@ Db::Db(const RclConfig *cfp) Db::~Db() { - LOGDEB2(("Db::~Db\n")); + LOGDEB2("Db::~Db\n" ); if (m_ndb == 0) return; - LOGDEB(("Db::~Db: isopen %d m_iswritable %d\n", m_ndb->m_isopen, - m_ndb->m_iswritable)); + LOGDEB("Db::~Db: isopen " << (m_ndb->m_isopen) << " m_iswritable " << (m_ndb->m_iswritable) << "\n" ); i_close(true); delete m_config; } @@ -770,8 +753,7 @@ bool Db::open(OpenMode mode, OpenError *error) m_reason = "Null configuration or Xapian Db"; return false; } - LOGDEB(("Db::open: m_isopen %d m_iswritable %d mode %d\n", m_ndb->m_isopen, - m_ndb->m_iswritable, mode)); + LOGDEB("Db::open: m_isopen " << (m_ndb->m_isopen) << " m_iswritable " << (m_ndb->m_iswritable) << " mode " << (mode) << "\n" ); if (m_ndb->m_isopen) { // We used to return an error here but I see no reason to @@ -809,9 +791,8 @@ bool Db::open(OpenMode mode, OpenError *error) // trigger other Xapian issues, so the query db is now // a clone of the update one. m_ndb->xrdb = m_ndb->xwdb; - LOGDEB(("Db::open: lastdocid: %d\n", - m_ndb->xwdb.get_lastdocid())); - LOGDEB2(("Db::open: resetting updated\n")); + LOGDEB("Db::open: lastdocid: " << (m_ndb->xwdb.get_lastdocid()) << "\n" ); + LOGDEB2("Db::open: resetting updated\n" ); updated.resize(m_ndb->xwdb.get_lastdocid() + 1); for (unsigned int i = 0; i < updated.size(); i++) updated[i] = false; @@ -825,7 +806,7 @@ bool Db::open(OpenMode mode, OpenError *error) it != m_extraDbs.end(); it++) { if (error) *error = DbOpenExtraDb; - LOGDEB(("Db::Open: adding query db [%s]\n", it->c_str())); + LOGDEB("Db::Open: adding query db [" << &(*it) << "]\n" ); // An error here used to be non-fatal (1.13 and older) // but I can't see why m_ndb->xrdb.add_database(Xapian::Database(*it)); @@ -841,8 +822,7 @@ bool Db::open(OpenMode mode, OpenError *error) string version = m_ndb->xrdb.get_metadata(cstr_RCL_IDX_VERSION_KEY); if (version.compare(cstr_RCL_IDX_VERSION)) { m_ndb->m_noversionwrite = true; - LOGERR(("Rcl::Db::open: file index [%s], software [%s]\n", - version.c_str(), cstr_RCL_IDX_VERSION.c_str())); + LOGERR("Rcl::Db::open: file index [" << (version) << "], software [" << (cstr_RCL_IDX_VERSION) << "]\n" ); throw Xapian::DatabaseError("Recoll index version mismatch", "", ""); } @@ -856,23 +836,21 @@ bool Db::open(OpenMode mode, OpenError *error) } XCATCHERROR(ermsg); m_reason = ermsg; - LOGERR(("Db::open: exception while opening [%s]: %s\n", - dir.c_str(), ermsg.c_str())); + LOGERR("Db::open: exception while opening [" << (dir) << "]: " << (ermsg) << "\n" ); return false; } // Note: xapian has no close call, we delete and recreate the db bool Db::close() { - LOGDEB1(("Db::close()\n")); + LOGDEB1("Db::close()\n" ); return i_close(false); } bool Db::i_close(bool final) { if (m_ndb == 0) return false; - LOGDEB(("Db::i_close(%d): m_isopen %d m_iswritable %d\n", final, - m_ndb->m_isopen, m_ndb->m_iswritable)); + LOGDEB("Db::i_close(" << (final) << "): m_isopen " << (m_ndb->m_isopen) << " m_iswritable " << (m_ndb->m_iswritable) << "\n" ); if (m_ndb->m_isopen == false && !final) return true; @@ -886,11 +864,11 @@ bool Db::i_close(bool final) if (!m_ndb->m_noversionwrite) m_ndb->xwdb.set_metadata(cstr_RCL_IDX_VERSION_KEY, cstr_RCL_IDX_VERSION); - LOGDEB(("Rcl::Db:close: xapian will close. May take some time\n")); + LOGDEB("Rcl::Db:close: xapian will close. May take some time\n" ); } deleteZ(m_ndb); if (w) - LOGDEB(("Rcl::Db:close() xapian close done.\n")); + LOGDEB("Rcl::Db:close() xapian close done.\n" ); if (final) { return true; } @@ -898,10 +876,10 @@ bool Db::i_close(bool final) if (m_ndb) { return true; } - LOGERR(("Rcl::Db::close(): cant recreate db object\n")); + LOGERR("Rcl::Db::close(): cant recreate db object\n" ); return false; } XCATCHERROR(ermsg); - LOGERR(("Db:close: exception while deleting db: %s\n", ermsg.c_str())); + LOGERR("Db:close: exception while deleting db: " << (ermsg) << "\n" ); return false; } @@ -909,7 +887,7 @@ bool Db::i_close(bool final) bool Db::adjustdbs() { if (m_mode != DbRO) { - LOGERR(("Db::adjustdbs: mode not RO\n")); + LOGERR("Db::adjustdbs: mode not RO\n" ); return false; } if (m_ndb && m_ndb->m_isopen) { @@ -931,7 +909,7 @@ int Db::docCnt() XAPTRY(res = m_ndb->xrdb.get_doccount(), m_ndb->xrdb, m_reason); if (!m_reason.empty()) { - LOGERR(("Db::docCnt: got error: %s\n", m_reason.c_str())); + LOGERR("Db::docCnt: got error: " << (m_reason) << "\n" ); return -1; } return res; @@ -946,19 +924,19 @@ int Db::termDocCnt(const string& _term) string term = _term; if (o_index_stripchars) if (!unacmaybefold(_term, term, "UTF-8", UNACOP_UNACFOLD)) { - LOGINFO(("Db::termDocCnt: unac failed for [%s]\n", _term.c_str())); + LOGINFO("Db::termDocCnt: unac failed for [" << (_term) << "]\n" ); return 0; } if (m_stops.isStop(term)) { - LOGDEB1(("Db::termDocCnt [%s] in stop list\n", term.c_str())); + LOGDEB1("Db::termDocCnt [" << (term) << "] in stop list\n" ); return 0; } XAPTRY(res = m_ndb->xrdb.get_termfreq(term), m_ndb->xrdb, m_reason); if (!m_reason.empty()) { - LOGERR(("Db::termDocCnt: got error: %s\n", m_reason.c_str())); + LOGERR("Db::termDocCnt: got error: " << (m_reason) << "\n" ); return -1; } return res; @@ -967,8 +945,7 @@ int Db::termDocCnt(const string& _term) bool Db::addQueryDb(const string &_dir) { string dir = _dir; - LOGDEB0(("Db::addQueryDb: ndb %p iswritable %d db [%s]\n", m_ndb, - (m_ndb)?m_ndb->m_iswritable:0, dir.c_str())); + LOGDEB0("Db::addQueryDb: ndb " << (m_ndb) << " iswritable " << ((m_ndb)?m_ndb->m_iswritable:0) << " db [" << (dir) << "]\n" ); if (!m_ndb) return false; if (m_ndb->m_iswritable) @@ -1008,8 +985,8 @@ size_t Db::whatDbIdx(const Doc& doc) size_t Db::Native::whatDbIdx(Xapian::docid id) { - LOGDEB1(("Db::whatDbIdx: xdocid %lu, %u extraDbs\n", - (unsigned long)id, m_extraDbs.size())); + LOGDEB1("Db::whatDbIdx: xdocid " << ((unsigned long)id) << ", " << + (m_rcldb->m_extraDbs.size()) << " extraDbs\n" ); if (id == 0) return (size_t)-1; if (m_rcldb->m_extraDbs.size() == 0) @@ -1021,7 +998,7 @@ bool Db::testDbDir(const string &dir, bool *stripped_p) { string aerr; bool mstripped = true; - LOGDEB(("Db::testDbDir: [%s]\n", dir.c_str())); + LOGDEB("Db::testDbDir: [" << (dir) << "]\n" ); try { Xapian::Database db(dir); // If we have terms with a leading ':' it's an @@ -1033,8 +1010,7 @@ bool Db::testDbDir(const string &dir, bool *stripped_p) mstripped = false; } XCATCHERROR(aerr); if (!aerr.empty()) { - LOGERR(("Db::Open: error while trying to open database " - "from [%s]: %s\n", dir.c_str(), aerr.c_str())); + LOGERR("Db::Open: error while trying to open database from [" << (dir) << "]: " << (aerr) << "\n" ); return false; } if (stripped_p) @@ -1094,12 +1070,12 @@ class TextSplitDb : public TextSplitP { ++basepos; } XCATCHERROR(ermsg); if (!ermsg.empty()) { - LOGERR(("Db: xapian add_posting error %s\n", ermsg.c_str())); + LOGERR("Db: xapian add_posting error " << (ermsg) << "\n" ); goto out; } if (!TextSplitP::text_to_words(in)) { - LOGDEB(("TextSplitDb: TextSplit::text_to_words failed\n")); + LOGDEB("TextSplitDb: TextSplit::text_to_words failed\n" ); goto out; } @@ -1110,7 +1086,7 @@ class TextSplitDb : public TextSplitP { ++basepos; } XCATCHERROR(ermsg); if (!ermsg.empty()) { - LOGERR(("Db: xapian add_posting error %s\n", ermsg.c_str())); + LOGERR("Db: xapian add_posting error " << (ermsg) << "\n" ); goto out; } @@ -1152,7 +1128,7 @@ public: string ermsg; try { // Index without prefix, using the field-specific weighting - LOGDEB1(("Emitting term at %d : [%s]\n", pos, term.c_str())); + LOGDEB1("Emitting term at " << pos << " : [" << term << "]\n" ); if (!m_ts->ft.pfxonly) m_ts->doc.add_posting(term, pos, m_ts->ft.wdfinc); @@ -1168,30 +1144,27 @@ public: } return true; } XCATCHERROR(ermsg); - LOGERR(("Db: xapian add_posting error %s\n", ermsg.c_str())); + LOGERR("Db: xapian add_posting error " << (ermsg) << "\n" ); return false; } void newpage(int pos) { pos += m_ts->basepos; if (pos < int(baseTextPosition)) { - LOGDEB(("newpage: not in body\n", pos)); + LOGDEB("newpage: not in body: " << (pos) << "\n" ); return; } m_ts->doc.add_posting(m_ts->ft.pfx + page_break_term, pos); if (pos == m_lastpagepos) { m_pageincr++; - LOGDEB2(("newpage: same pos, pageincr %d lastpagepos %d\n", - m_pageincr, m_lastpagepos)); + LOGDEB2("newpage: same pos, pageincr " << (m_pageincr) << " lastpagepos " << (m_lastpagepos) << "\n" ); } else { - LOGDEB2(("newpage: pos change, pageincr %d lastpagepos %d\n", - m_pageincr, m_lastpagepos)); + LOGDEB2("newpage: pos change, pageincr " << (m_pageincr) << " lastpagepos " << (m_lastpagepos) << "\n" ); if (m_pageincr > 0) { // Remember the multiple page break at this position unsigned int relpos = m_lastpagepos - baseTextPosition; - LOGDEB2(("Remembering multiple page break. Relpos %u cnt %d\n", - relpos, m_pageincr)); + LOGDEB2("Remembering multiple page break. Relpos " << (relpos) << " cnt " << (m_pageincr) << "\n" ); m_pageincrvec.push_back(pair(relpos, m_pageincr)); } m_pageincr = 0; @@ -1203,8 +1176,7 @@ public: { if (m_pageincr > 0) { unsigned int relpos = m_lastpagepos - baseTextPosition; - LOGDEB2(("Remembering multiple page break. Position %u cnt %d\n", - relpos, m_pageincr)); + LOGDEB2("Remembering multiple page break. Position " << (relpos) << " cnt " << (m_pageincr) << "\n" ); m_pageincrvec.push_back(pair(relpos, m_pageincr)); m_pageincr = 0; } @@ -1231,7 +1203,7 @@ string Db::getSpellingSuggestion(const string& word) if (o_index_stripchars) if (!unacmaybefold(word, term, "UTF-8", UNACOP_UNACFOLD)) { - LOGINFO(("Db::getSpelling: unac failed for [%s]\n", word.c_str())); + LOGINFO("Db::getSpelling: unac failed for [" << (word) << "]\n" ); return string(); } @@ -1244,8 +1216,7 @@ string Db::getSpellingSuggestion(const string& word) // Let our user set the parameters for abstract processing void Db::setAbstractParams(int idxtrunc, int syntlen, int syntctxlen) { - LOGDEB1(("Db::setAbstractParams: trunc %d syntlen %d ctxlen %d\n", - idxtrunc, syntlen, syntctxlen)); + LOGDEB1("Db::setAbstractParams: trunc " << (idxtrunc) << " syntlen " << (syntlen) << " ctxlen " << (syntctxlen) << "\n" ); if (idxtrunc > 0) m_idxAbsTruncLen = idxtrunc; if (syntlen > 0) @@ -1268,8 +1239,7 @@ static const string cstr_nc("\n\r\x0c\\"); // metadata), and update database bool Db::addOrUpdate(const string &udi, const string &parent_udi, Doc &doc) { - LOGDEB(("Db::add: udi [%s] parent [%s]\n", - udi.c_str(), parent_udi.c_str())); + LOGDEB("Db::add: udi [" << (udi) << "] parent [" << (parent_udi) << "]\n" ); if (m_ndb == 0) return false; @@ -1361,17 +1331,13 @@ bool Db::addOrUpdate(const string &udi, const string &parent_udi, Doc &doc) // We don't test for an empty prefix here. Some fields are part // of the internal conf with an empty prefix (ie: abstract). if (!fieldToTraits(meta_it->first, &ftp)) { - LOGDEB0(("Db::add: no prefix for field [%s], no indexing\n", - meta_it->first.c_str())); + LOGDEB0("Db::add: no prefix for field [" << (meta_it->first) << "], no indexing\n" ); continue; } - LOGDEB0(("Db::add: field [%s] pfx [%s] inc %d: [%s]\n", - meta_it->first.c_str(), ftp->pfx.c_str(), ftp->wdfinc, - meta_it->second.c_str())); + LOGDEB0("Db::add: field [" << (meta_it->first) << "] pfx [" << (ftp->pfx) << "] inc " << (ftp->wdfinc) << ": [" << (meta_it->second) << "]\n" ); splitter.setTraits(*ftp); if (!splitter.text_to_words(meta_it->second)) - LOGDEB(("Db::addOrUpdate: split failed for %s\n", - meta_it->first.c_str())); + LOGDEB("Db::addOrUpdate: split failed for " << (meta_it->first) << "\n" ); } } @@ -1382,13 +1348,13 @@ bool Db::addOrUpdate(const string &udi, const string &parent_udi, Doc &doc) splitter.basepos = baseTextPosition; // Split and index body text - LOGDEB2(("Db::add: split body: [%s]\n", doc.text.c_str())); + LOGDEB2("Db::add: split body: [" << (doc.text) << "]\n" ); #ifdef TEXTSPLIT_STATS splitter.resetStats(); #endif if (!splitter.text_to_words(doc.text)) - LOGDEB(("Db::addOrUpdate: split failed for main text\n")); + LOGDEB("Db::addOrUpdate: split failed for main text\n" ); #ifdef TEXTSPLIT_STATS // Reject bad data. unrecognized base64 text is characterized by @@ -1397,10 +1363,7 @@ bool Db::addOrUpdate(const string &udi, const string &parent_udi, Doc &doc) TextSplit::Stats::Values v = splitter.getStats(); // v.avglen > 15 && v.sigma > 12 if (v.count > 200 && (v.avglen > 10 && v.sigma / v.avglen > 0.8)) { - LOGINFO(("RclDb::addOrUpdate: rejecting doc for bad stats " - "count %d avglen %.4f sigma %.4f url [%s] ipath [%s] text %s\n", - v.count, v.avglen, v.sigma, doc.url.c_str(), - doc.ipath.c_str(), doc.text.c_str())); + LOGINFO("RclDb::addOrUpdate: rejecting doc for bad stats count " << (v.count) << " avglen " << (v.avglen) << " sigma " << (v.sigma) << " url [" << (doc.url) << "] ipath [" << (doc.ipath) << "] text " << (doc.text) << "\n" ); delete newdocument_ptr; return true; } @@ -1597,7 +1560,7 @@ bool Db::addOrUpdate(const string &udi, const string &parent_udi, Doc &doc) newdocument.add_boolean_term(wrap_prefix("XM") + *md5); } - LOGDEB0(("Rcl::Db::add: new doc record:\n%s\n", record.c_str())); + LOGDEB0("Rcl::Db::add: new doc record:\n" << (record) << "\n" ); newdocument.set_data(record); } #ifdef IDX_THREADS @@ -1605,7 +1568,7 @@ bool Db::addOrUpdate(const string &udi, const string &parent_udi, Doc &doc) DbUpdTask *tp = new DbUpdTask(DbUpdTask::AddOrUpdate, udi, uniterm, newdocument_ptr, doc.text.length()); if (!m_ndb->m_wqueue.put(tp)) { - LOGERR(("Db::addOrUpdate:Cant queue task\n")); + LOGERR("Db::addOrUpdate:Cant queue task\n" ); delete newdocument_ptr; return false; } else { @@ -1621,20 +1584,20 @@ bool Db::addOrUpdate(const string &udi, const string &parent_udi, Doc &doc) bool Db::Native::docToXdocXattrOnly(TextSplitDb *splitter, const string &udi, Doc &doc, Xapian::Document& xdoc) { - LOGDEB0(("Db::docToXdocXattrOnly\n")); + LOGDEB0("Db::docToXdocXattrOnly\n" ); #ifdef IDX_THREADS PTMutexLocker lock(m_mutex); #endif // Read existing document and its data record if (getDoc(udi, 0, xdoc) == 0) { - LOGERR(("docToXdocXattrOnly: existing doc not found\n")); + LOGERR("docToXdocXattrOnly: existing doc not found\n" ); return false; } string data; XAPTRY(data = xdoc.get_data(), xrdb, m_rcldb->m_reason); if (!m_rcldb->m_reason.empty()) { - LOGERR(("Db::xattrOnly: got error: %s\n", m_rcldb->m_reason.c_str())); + LOGERR("Db::xattrOnly: got error: " << (m_rcldb->m_reason) << "\n" ); return false; } @@ -1643,26 +1606,22 @@ bool Db::Native::docToXdocXattrOnly(TextSplitDb *splitter, const string &udi, for (meta_it = doc.meta.begin(); meta_it != doc.meta.end(); meta_it++) { const FieldTraits *ftp; if (!m_rcldb->fieldToTraits(meta_it->first, &ftp) || ftp->pfx.empty()) { - LOGDEB0(("Db::xattrOnly: no prefix for field [%s], skipped\n", - meta_it->first.c_str())); + LOGDEB0("Db::xattrOnly: no prefix for field [" << (meta_it->first) << "], skipped\n" ); continue; } // Clear the previous terms for the field clearField(xdoc, ftp->pfx, ftp->wdfinc); - LOGDEB0(("Db::xattrOnly: field [%s] pfx [%s] inc %d: [%s]\n", - meta_it->first.c_str(), ftp->pfx.c_str(), ftp->wdfinc, - meta_it->second.c_str())); + LOGDEB0("Db::xattrOnly: field [" << (meta_it->first) << "] pfx [" << (ftp->pfx) << "] inc " << (ftp->wdfinc) << ": [" << (meta_it->second) << "]\n" ); splitter->setTraits(*ftp); if (!splitter->text_to_words(meta_it->second)) - LOGDEB(("Db::xattrOnly: split failed for %s\n", - meta_it->first.c_str())); + LOGDEB("Db::xattrOnly: split failed for " << (meta_it->first) << "\n" ); } xdoc.add_value(VALUE_SIG, doc.sig); // Parse current data record into a dict for ease of processing ConfSimple datadic(data); if (!datadic.ok()) { - LOGERR(("db::docToXdocXattrOnly: failed turning data rec to dict\n")); + LOGERR("db::docToXdocXattrOnly: failed turning data rec to dict\n" ); return false; } @@ -1707,11 +1666,10 @@ void Db::waitUpdIdle() m_ndb->xwdb.flush(); } XCATCHERROR(ermsg); if (!ermsg.empty()) { - LOGERR(("Db::waitUpdIdle: flush() failed: %s\n", ermsg.c_str())); + LOGERR("Db::waitUpdIdle: flush() failed: " << (ermsg) << "\n" ); } m_ndb->m_totalworkns += chron.nanos(); - LOGINFO(("Db::waitUpdIdle: total xapian work %s mS\n", - lltodecstr(m_ndb->m_totalworkns/1000000).c_str())); + LOGINFO("Db::waitUpdIdle: total xapian work " << (lltodecstr(m_ndb->m_totalworkns/1000000)) << " mS\n" ); } } #endif @@ -1722,8 +1680,7 @@ bool Db::maybeflush(off_t moretext) if (m_flushMb > 0) { m_curtxtsz += moretext; if ((m_curtxtsz - m_flushtxtsz) / MB >= m_flushMb) { - LOGDEB(("Db::add/delete: txt size >= %d Mb, flushing\n", - m_flushMb)); + LOGDEB("Db::add/delete: txt size >= " << (m_flushMb) << " Mb, flushing\n" ); return doFlush(); } } @@ -1733,7 +1690,7 @@ bool Db::maybeflush(off_t moretext) bool Db::doFlush() { if (!m_ndb) { - LOGERR(("Db::doFLush: no ndb??\n")); + LOGERR("Db::doFLush: no ndb??\n" ); return false; } string ermsg; @@ -1741,7 +1698,7 @@ bool Db::doFlush() m_ndb->xwdb.flush(); } XCATCHERROR(ermsg); if (!ermsg.empty()) { - LOGERR(("Db::doFlush: flush() failed: %s\n", ermsg.c_str())); + LOGERR("Db::doFlush: flush() failed: " << (ermsg) << "\n" ); return false; } m_flushtxtsz = m_curtxtsz; @@ -1753,7 +1710,7 @@ void Db::setExistingFlags(const string& udi, unsigned int docid) if (m_mode == DbRO) return; if (docid == (unsigned int)-1) { - LOGERR(("Db::setExistingFlags: called with bogus docid !!\n")); + LOGERR("Db::setExistingFlags: called with bogus docid !!\n" ); return; } #ifdef IDX_THREADS @@ -1766,10 +1723,7 @@ void Db::i_setExistingFlags(const string& udi, unsigned int docid) { // Set the up to date flag for the document and its subdocs if (docid >= updated.size()) { - LOGERR(("needUpdate: existing docid beyond " - "updated.size(). Udi [%s], docid %u, " - "updated.size() %u\n", udi.c_str(), - unsigned(docid), (unsigned)updated.size())); + LOGERR("needUpdate: existing docid beyond updated.size(). Udi [" << (udi) << "], docid " << (unsigned(docid)) << ", updated.size() " << ((unsigned)updated.size()) << "\n" ); return; } else { updated[docid] = true; @@ -1778,13 +1732,13 @@ void Db::i_setExistingFlags(const string& udi, unsigned int docid) // Set the existence flag for all the subdocs (if any) vector docids; if (!m_ndb->subDocs(udi, 0, docids)) { - LOGERR(("Rcl::Db::needUpdate: can't get subdocs\n")); + LOGERR("Rcl::Db::needUpdate: can't get subdocs\n" ); return; } for (vector::iterator it = docids.begin(); it != docids.end(); it++) { if (*it < updated.size()) { - LOGDEB2(("Db::needUpdate: docid %d set\n", *it)); + LOGDEB2("Db::needUpdate: docid " << (*it) << " set\n" ); updated[*it] = true; } } @@ -1827,19 +1781,18 @@ bool Db::needUpdate(const string &udi, const string& sig, Xapian::PostingIterator docid; XAPTRY(docid = m_ndb->xrdb.postlist_begin(uniterm), m_ndb->xrdb, m_reason); if (!m_reason.empty()) { - LOGERR(("Db::needUpdate: xapian::postlist_begin failed: %s\n", - m_reason.c_str())); + LOGERR("Db::needUpdate: xapian::postlist_begin failed: " << (m_reason) << "\n" ); return false; } if (docid == m_ndb->xrdb.postlist_end(uniterm)) { // No document exists with this path: we do need update - LOGDEB(("Db::needUpdate:yes (new): [%s]\n", uniterm.c_str())); + LOGDEB("Db::needUpdate:yes (new): [" << (uniterm) << "]\n" ); return true; } Xapian::Document xdoc; XAPTRY(xdoc = m_ndb->xrdb.get_document(*docid), m_ndb->xrdb, m_reason); if (!m_reason.empty()) { - LOGERR(("Db::needUpdate: get_document error: %s\n", m_reason.c_str())); + LOGERR("Db::needUpdate: get_document error: " << (m_reason) << "\n" ); return true; } @@ -1851,11 +1804,10 @@ bool Db::needUpdate(const string &udi, const string& sig, string osig; XAPTRY(osig = xdoc.get_value(VALUE_SIG), m_ndb->xrdb, m_reason); if (!m_reason.empty()) { - LOGERR(("Db::needUpdate: get_value error: %s\n", m_reason.c_str())); + LOGERR("Db::needUpdate: get_value error: " << (m_reason) << "\n" ); return true; } - LOGDEB2(("Db::needUpdate: oldsig [%s] new [%s]\n", - osig.c_str(), sig.c_str())); + LOGDEB2("Db::needUpdate: oldsig [" << (osig) << "] new [" << (sig) << "]\n" ); if (osigp) { *osigp = osig; @@ -1863,15 +1815,14 @@ bool Db::needUpdate(const string &udi, const string& sig, // Compare new/old sig if (sig != osig) { - LOGDEB(("Db::needUpdate:yes: olsig [%s] new [%s] [%s]\n", - osig.c_str(), sig.c_str(), uniterm.c_str())); + LOGDEB("Db::needUpdate:yes: olsig [" << (osig) << "] new [" << (sig) << "] [" << (uniterm) << "]\n" ); // Db is not up to date. Let's index the file return true; } // Up to date. Set the existance flags in the map for the doc and // its subdocs. - LOGDEB(("Db::needUpdate:no: [%s]\n", uniterm.c_str())); + LOGDEB("Db::needUpdate:no: [" << (uniterm) << "]\n" ); i_setExistingFlags(udi, *docid); return false; } @@ -1879,7 +1830,7 @@ bool Db::needUpdate(const string &udi, const string& sig, // Return existing stem db languages vector Db::getStemLangs() { - LOGDEB(("Db::getStemLang\n")); + LOGDEB("Db::getStemLang\n" ); vector langs; if (m_ndb == 0 || m_ndb->m_isopen == false) return langs; @@ -1893,7 +1844,7 @@ vector Db::getStemLangs() */ bool Db::deleteStemDb(const string& lang) { - LOGDEB(("Db::deleteStemDb(%s)\n", lang.c_str())); + LOGDEB("Db::deleteStemDb(" << (lang) << ")\n" ); if (m_ndb == 0 || m_ndb->m_isopen == false || !m_ndb->m_iswritable) return false; XapWritableSynFamily db(m_ndb->xwdb, synFamStem); @@ -1908,9 +1859,9 @@ bool Db::deleteStemDb(const string& lang) */ bool Db::createStemDbs(const vector& langs) { - LOGDEB(("Db::createStemDbs\n")); + LOGDEB("Db::createStemDbs\n" ); if (m_ndb == 0 || m_ndb->m_isopen == false || !m_ndb->m_iswritable) { - LOGERR(("createStemDb: db not open or not writable\n")); + LOGERR("createStemDb: db not open or not writable\n" ); return false; } @@ -1925,11 +1876,10 @@ bool Db::createStemDbs(const vector& langs) */ bool Db::purge() { - LOGDEB(("Db::purge\n")); + LOGDEB("Db::purge\n" ); if (m_ndb == 0) return false; - LOGDEB(("Db::purge: m_isopen %d m_iswritable %d\n", m_ndb->m_isopen, - m_ndb->m_iswritable)); + LOGDEB("Db::purge: m_isopen " << (m_ndb->m_isopen) << " m_iswritable " << (m_ndb->m_iswritable) << "\n" ); if (m_ndb->m_isopen == false || m_ndb->m_iswritable == false) return false; @@ -1952,7 +1902,7 @@ bool Db::purge() try { m_ndb->xwdb.flush(); } catch (...) { - LOGERR(("Db::purge: 1st flush failed\n")); + LOGERR("Db::purge: 1st flush failed\n" ); } @@ -1965,7 +1915,7 @@ bool Db::purge() try { CancelCheck::instance().checkCancel(); } catch(CancelExcept) { - LOGINFO(("Db::purge: partially cancelled\n")); + LOGINFO("Db::purge: partially cancelled\n" ); break; } } @@ -1982,13 +1932,13 @@ bool Db::purge() maybeflush(trms * 5); } m_ndb->xwdb.delete_document(docid); - LOGDEB(("Db::purge: deleted document #%d\n", docid)); + LOGDEB("Db::purge: deleted document #" << (docid) << "\n" ); } catch (const Xapian::DocNotFoundError &) { - LOGDEB0(("Db::purge: document #%d not found\n", docid)); + LOGDEB0("Db::purge: document #" << (docid) << " not found\n" ); } catch (const Xapian::Error &e) { - LOGERR(("Db::purge: document #%d: %s\n", docid, e.get_msg().c_str())); + LOGERR("Db::purge: document #" << (docid) << ": " << (e.get_msg()) << "\n" ); } catch (...) { - LOGERR(("Db::purge: document #%d: unknown error\n", docid)); + LOGERR("Db::purge: document #" << (docid) << ": unknown error\n" ); } purgecount++; } @@ -1997,7 +1947,7 @@ bool Db::purge() try { m_ndb->xwdb.flush(); } catch (...) { - LOGERR(("Db::purge: 2nd flush failed\n")); + LOGERR("Db::purge: 2nd flush failed\n" ); } return true; } @@ -2020,7 +1970,7 @@ bool Db::docExists(const string& uniterm) } } XCATCHERROR(ermsg); if (!ermsg.empty()) { - LOGERR(("Db::docExists(%s) %s\n", uniterm.c_str(), ermsg.c_str())); + LOGERR("Db::docExists(" << (uniterm) << ") " << (ermsg) << "\n" ); } return false; } @@ -2028,7 +1978,7 @@ bool Db::docExists(const string& uniterm) /* Delete document(s) for given unique identifier (doc and descendents) */ bool Db::purgeFile(const string &udi, bool *existed) { - LOGDEB(("Db:purgeFile: [%s]\n", udi.c_str())); + LOGDEB("Db:purgeFile: [" << (udi) << "]\n" ); if (m_ndb == 0 || !m_ndb->m_iswritable) return false; @@ -2044,7 +1994,7 @@ bool Db::purgeFile(const string &udi, bool *existed) DbUpdTask *tp = new DbUpdTask(DbUpdTask::Delete, udi, uniterm, 0, (size_t)-1); if (!m_ndb->m_wqueue.put(tp)) { - LOGERR(("Db::purgeFile:Cant queue task\n")); + LOGERR("Db::purgeFile:Cant queue task\n" ); return false; } else { return true; @@ -2060,7 +2010,7 @@ bool Db::purgeFile(const string &udi, bool *existed) will be done */ bool Db::purgeOrphans(const string &udi) { - LOGDEB(("Db:purgeOrphans: [%s]\n", udi.c_str())); + LOGDEB("Db:purgeOrphans: [" << (udi) << "]\n" ); if (m_ndb == 0 || !m_ndb->m_iswritable) return false; @@ -2071,7 +2021,7 @@ bool Db::purgeOrphans(const string &udi) DbUpdTask *tp = new DbUpdTask(DbUpdTask::PurgeOrphans, udi, uniterm, 0, (size_t)-1); if (!m_ndb->m_wqueue.put(tp)) { - LOGERR(("Db::purgeFile:Cant queue task\n")); + LOGERR("Db::purgeFile:Cant queue task\n" ); return false; } else { return true; @@ -2104,7 +2054,7 @@ bool Db::dbStats(DbStats& res) // existence should be tested by looking at doc.pc bool Db::getDoc(const string &udi, const Doc& idxdoc, Doc &doc) { - LOGDEB(("Db:getDoc: [%s]\n", udi.c_str())); + LOGDEB("Db:getDoc: [" << (udi) << "]\n" ); if (m_ndb == 0) return false; @@ -2125,7 +2075,7 @@ bool Db::getDoc(const string &udi, const Doc& idxdoc, Doc &doc) // other ok docs further) but indicate the error with // pc = -1 doc.pc = -1; - LOGINFO(("Db:getDoc: no such doc in index: [%s]\n", udi.c_str())); + LOGINFO("Db:getDoc: no such doc in index: [" << (udi) << "]\n" ); return true; } } @@ -2136,10 +2086,10 @@ bool Db::hasSubDocs(const Doc &idoc) return false; string inudi; if (!idoc.getmeta(Doc::keyudi, &inudi) || inudi.empty()) { - LOGERR(("Db::hasSubDocs: no input udi or empty\n")); + LOGERR("Db::hasSubDocs: no input udi or empty\n" ); return false; } - LOGDEB1(("Db::hasSubDocs: idxi %d inudi [%s]\n", idoc.idxi, inudi.c_str())); + LOGDEB1("Db::hasSubDocs: idxi " << (idoc.idxi) << " inudi [" << (inudi) << "]\n" ); // Not sure why we perform both the subDocs() call and the test on // has_children. The former will return docs if the input is a @@ -2149,7 +2099,7 @@ bool Db::hasSubDocs(const Doc &idoc) // checked one day. vector docids; if (!m_ndb->subDocs(inudi, idoc.idxi, docids)) { - LOGDEB(("Db::hasSubDocs: lower level subdocs failed\n")); + LOGDEB("Db::hasSubDocs: lower level subdocs failed\n" ); return false; } if (!docids.empty()) @@ -2170,14 +2120,13 @@ bool Db::getSubDocs(const Doc &idoc, vector& subdocs) string inudi; if (!idoc.getmeta(Doc::keyudi, &inudi) || inudi.empty()) { - LOGERR(("Db::getSubDocs: no input udi or empty\n")); + LOGERR("Db::getSubDocs: no input udi or empty\n" ); return false; } string rootudi; string ipath = idoc.ipath; - LOGDEB0(("Db::getSubDocs: idxi %d inudi [%s] ipath [%s]\n", - idoc.idxi, inudi.c_str(), ipath.c_str())); + LOGDEB0("Db::getSubDocs: idxi " << (idoc.idxi) << " inudi [" << (inudi) << "] ipath [" << (ipath) << "]\n" ); if (ipath.empty()) { // File-level doc. Use it as root rootudi = inudi; @@ -2185,7 +2134,7 @@ bool Db::getSubDocs(const Doc &idoc, vector& subdocs) // See if we have a parent term Xapian::Document xdoc; if (!m_ndb->getDoc(inudi, idoc.idxi, xdoc)) { - LOGERR(("Db::getSubDocs: can't get Xapian document\n")); + LOGERR("Db::getSubDocs: can't get Xapian document\n" ); return false; } Xapian::TermIterator xit; @@ -2193,22 +2142,22 @@ bool Db::getSubDocs(const Doc &idoc, vector& subdocs) xit.skip_to(wrap_prefix(parent_prefix)), m_ndb->xrdb, m_reason); if (!m_reason.empty()) { - LOGERR(("Db::getSubDocs: xapian error: %s\n", m_reason.c_str())); + LOGERR("Db::getSubDocs: xapian error: " << (m_reason) << "\n" ); return false; } if (xit == xdoc.termlist_end()) { - LOGERR(("Db::getSubDocs: parent term not found\n")); + LOGERR("Db::getSubDocs: parent term not found\n" ); return false; } rootudi = strip_prefix(*xit); } - LOGDEB(("Db::getSubDocs: root: [%s]\n", rootudi.c_str())); + LOGDEB("Db::getSubDocs: root: [" << (rootudi) << "]\n" ); // Retrieve all subdoc xapian ids for the root vector docids; if (!m_ndb->subDocs(rootudi, idoc.idxi, docids)) { - LOGDEB(("Db::getSubDocs: lower level subdocs failed\n")); + LOGDEB("Db::getSubDocs: lower level subdocs failed\n" ); return false; } @@ -2226,7 +2175,7 @@ bool Db::getSubDocs(const Doc &idoc, vector& subdocs) doc.meta[Doc::keyrr] = "100%"; doc.pc = 100; if (!m_ndb->dbDataToRclDoc(*it, data, doc)) { - LOGERR(("Db::getSubDocs: doc conversion error\n")); + LOGERR("Db::getSubDocs: doc conversion error\n" ); return false; } if (ipath.empty() || @@ -2243,8 +2192,9 @@ bool Db::getSubDocs(const Doc &idoc, vector& subdocs) break; } - LOGERR(("Db::getSubDocs: Xapian error: %s\n", m_reason.c_str())); + LOGERR("Db::getSubDocs: Xapian error: " << (m_reason) << "\n" ); return false; } } // End namespace Rcl + diff --git a/src/rcldb/rcldb_p.h b/src/rcldb/rcldb_p.h index 76a31437..3deb5a32 100644 --- a/src/rcldb/rcldb_p.h +++ b/src/rcldb/rcldb_p.h @@ -27,7 +27,6 @@ #ifdef IDX_THREADS #include "workqueue.h" #endif // IDX_THREADS -#include "debuglog.h" #include "xmacros.h" #include "ptmutex.h" @@ -82,7 +81,6 @@ class Db::Native { bool m_noversionwrite; //Set if open failed because of version mismatch! #ifdef IDX_THREADS WorkQueue m_wqueue; - int m_loglevel; PTMutexInit m_mutex; long long m_totalworkns; bool m_havewriteq; diff --git a/src/rcldb/rcldoc.cpp b/src/rcldb/rcldoc.cpp index 3858529f..09700d07 100644 --- a/src/rcldb/rcldoc.cpp +++ b/src/rcldb/rcldoc.cpp @@ -17,7 +17,7 @@ #include "autoconfig.h" #include "rcldoc.h" -#include "debuglog.h" +#include "log.h" #include "rclutil.h" namespace Rcl { @@ -50,27 +50,26 @@ namespace Rcl { void Doc::dump(bool dotext) const { - LOGDEB(("Rcl::Doc::dump: url: [%s]\n", url.c_str())); - LOGDEB(("Rcl::Doc::dump: idxurl: [%s]\n", idxurl.c_str())); - LOGDEB(("Rcl::Doc::dump: ipath: [%s]\n", ipath.c_str())); - LOGDEB(("Rcl::Doc::dump: mimetype: [%s]\n", mimetype.c_str())); - LOGDEB(("Rcl::Doc::dump: fmtime: [%s]\n", fmtime.c_str())); - LOGDEB(("Rcl::Doc::dump: dmtime: [%s]\n", dmtime.c_str())); - LOGDEB(("Rcl::Doc::dump: origcharset: [%s]\n", origcharset.c_str())); - LOGDEB(("Rcl::Doc::dump: syntabs: [%d]\n", syntabs)); - LOGDEB(("Rcl::Doc::dump: pcbytes: [%s]\n", pcbytes.c_str())); - LOGDEB(("Rcl::Doc::dump: fbytes: [%s]\n", fbytes.c_str())); - LOGDEB(("Rcl::Doc::dump: dbytes: [%s]\n", dbytes.c_str())); - LOGDEB(("Rcl::Doc::dump: sig: [%s]\n", sig.c_str())); - LOGDEB(("Rcl::Doc::dump: pc: [%d]\n", pc)); - LOGDEB(("Rcl::Doc::dump: xdocid: [%lu]\n", (unsigned long)xdocid)); + LOGDEB("Rcl::Doc::dump: url: [" << (url) << "]\n" ); + LOGDEB("Rcl::Doc::dump: idxurl: [" << (idxurl) << "]\n" ); + LOGDEB("Rcl::Doc::dump: ipath: [" << (ipath) << "]\n" ); + LOGDEB("Rcl::Doc::dump: mimetype: [" << (mimetype) << "]\n" ); + LOGDEB("Rcl::Doc::dump: fmtime: [" << (fmtime) << "]\n" ); + LOGDEB("Rcl::Doc::dump: dmtime: [" << (dmtime) << "]\n" ); + LOGDEB("Rcl::Doc::dump: origcharset: [" << (origcharset) << "]\n" ); + LOGDEB("Rcl::Doc::dump: syntabs: [" << (syntabs) << "]\n" ); + LOGDEB("Rcl::Doc::dump: pcbytes: [" << (pcbytes) << "]\n" ); + LOGDEB("Rcl::Doc::dump: fbytes: [" << (fbytes) << "]\n" ); + LOGDEB("Rcl::Doc::dump: dbytes: [" << (dbytes) << "]\n" ); + LOGDEB("Rcl::Doc::dump: sig: [" << (sig) << "]\n" ); + LOGDEB("Rcl::Doc::dump: pc: [" << (pc) << "]\n" ); + LOGDEB("Rcl::Doc::dump: xdocid: [" << ((unsigned long)xdocid) << "]\n" ); for (map::const_iterator it = meta.begin(); it != meta.end(); it++) { - LOGDEB(("Rcl::Doc::dump: meta[%s]: [%s]\n", - (*it).first.c_str(), (*it).second.c_str())); + LOGDEB("Rcl::Doc::dump: meta[" << ((*it).first) << "]: [" << ((*it).second) << "]\n" ); } 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. @@ -100,3 +99,4 @@ namespace Rcl { } } + diff --git a/src/rcldb/rcldups.cpp b/src/rcldb/rcldups.cpp index a36a7905..cbed6f82 100644 --- a/src/rcldb/rcldups.cpp +++ b/src/rcldb/rcldups.cpp @@ -24,7 +24,7 @@ using namespace std; #include -#include "debuglog.h" +#include "log.h" #include "rcldb.h" #include "rcldb_p.h" #include "xmacros.h" @@ -39,11 +39,11 @@ namespace Rcl { bool Db::docDups(const Doc& idoc, vector& odocs) { if (m_ndb == 0) { - LOGERR(("Db::docDups: no db\n")); + LOGERR("Db::docDups: no db\n" ); return false; } if (idoc.xdocid == 0) { - LOGERR(("Db::docDups: null xdocid in input doc\n")); + LOGERR("Db::docDups: null xdocid in input doc\n" ); return false; } // Get the xapian doc @@ -51,7 +51,7 @@ bool Db::docDups(const Doc& idoc, vector& odocs) XAPTRY(xdoc = m_ndb->xrdb.get_document(Xapian::docid(idoc.xdocid)), m_ndb->xrdb, m_reason); 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; } @@ -59,11 +59,11 @@ bool Db::docDups(const Doc& idoc, vector& odocs) string digest; XAPTRY(digest = xdoc.get_value(VALUE_MD5), m_ndb->xrdb, m_reason); 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; } if (digest.empty()) { - LOGDEB(("Db::docDups: doc has no md5\n")); + LOGDEB("Db::docDups: doc has no md5\n" ); return false; } string md5; @@ -79,14 +79,14 @@ bool Db::docDups(const Doc& idoc, vector& odocs) Query query(this); query.setCollapseDuplicates(0); if (!query.setQuery(sd)) { - LOGERR(("Db::docDups: setQuery failed\n")); + LOGERR("Db::docDups: setQuery failed\n" ); return false; } int cnt = query.getResCnt(); for (int i = 0; i < cnt; i++) { Doc 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; } odocs.push_back(doc); @@ -98,18 +98,19 @@ bool Db::docDups(const Doc& idoc, vector& odocs) { vector dups; bool ret; - LOGDEB(("DOCDUPS\n")); + LOGDEB("DOCDUPS\n" ); ret = m_db->docDups(doc, dups); if (!ret) { - LOGDEB(("docDups failed\n")); + LOGDEB("docDups failed\n" ); } else if (dups.size() == 1) { - LOGDEB(("No dups\n")); + LOGDEB("No dups\n" ); } else { 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 } + diff --git a/src/rcldb/rclquery.cpp b/src/rcldb/rclquery.cpp index 7d662573..95bc26ac 100644 --- a/src/rcldb/rclquery.cpp +++ b/src/rcldb/rclquery.cpp @@ -27,7 +27,7 @@ #include "cstr.h" #include "rclconfig.h" -#include "debuglog.h" +#include "log.h" #include "rcldb.h" #include "rcldb_p.h" #include "rclquery.h" @@ -132,7 +132,7 @@ public: 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; } @@ -166,8 +166,7 @@ void Query::setSortBy(const string& fld, bool ascending) { m_sortField = m_db->getConf()->fieldQCanon(fld); m_sortAscending = ascending; } - LOGDEB0(("RclQuery::setSortBy: [%s] %s\n", m_sortField.c_str(), - m_sortAscending ? "ascending" : "descending")); + LOGDEB0("RclQuery::setSortBy: [" << (m_sortField) << "] " << (m_sortAscending ? "ascending" : "descending") << "\n" ); } //#define ISNULL(X) (X).isNull() @@ -176,10 +175,10 @@ void Query::setSortBy(const string& fld, bool ascending) { // Prepare query out of user search data bool Query::setQuery(STD_SHARED_PTR sdata) { - LOGDEB(("Query::setQuery:\n")); + LOGDEB("Query::setQuery:\n" ); if (!m_db || ISNULL(m_nq)) { - LOGERR(("Query::setQuery: not initialised!\n")); + LOGERR("Query::setQuery: not initialised!\n" ); return false; } m_resCnt = -1; @@ -233,7 +232,7 @@ bool Query::setQuery(STD_SHARED_PTR sdata) } 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; } @@ -242,7 +241,7 @@ bool Query::setQuery(STD_SHARED_PTR sdata) sdata->setDescription(d); m_sd = sdata; - LOGDEB(("Query::SetQuery: Q: %s\n", sdata->getDescription().c_str())); + LOGDEB("Query::SetQuery: Q: " << (sdata->getDescription()) << "\n" ); return true; } @@ -261,7 +260,7 @@ bool Query::getQueryTerms(vector& terms) } } XCATCHERROR(ermsg); if (!ermsg.empty()) { - LOGERR(("getQueryTerms: xapian error: %s\n", ermsg.c_str())); + LOGERR("getQueryTerms: xapian error: " << (ermsg) << "\n" ); return false; } return true; @@ -271,17 +270,16 @@ int Query::makeDocAbstract(const Doc &doc, vector& abstract, 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) { - LOGERR(("Query::makeDocAbstract: no db or no nq\n")); + LOGERR("Query::makeDocAbstract: no db or no nq\n" ); return ABSRES_ERROR; } int ret = ABSRES_ERROR; XAPTRY(ret = m_nq->makeAbstract(doc.xdocid, abstract, maxoccs, ctxwords), m_db->m_ndb->xrdb, m_reason); if (!m_reason.empty()) { - LOGDEB(("makeDocAbstract: makeAbstract error, reason: %s\n", - m_reason.c_str())); + LOGDEB("makeDocAbstract: makeAbstract error, reason: " << (m_reason) << "\n" ); return ABSRES_ERROR; } return ret; @@ -321,9 +319,9 @@ bool Query::makeDocAbstract(const Doc &doc, string& abstract) int Query::getFirstMatchPage(const Doc &doc, string& term) { - LOGDEB1(("Db::getFirstMatchPage\n"));; + LOGDEB1("Db::getFirstMatchPage\n" );; if (!m_nq) { - LOGERR(("Query::getFirstMatchPage: no nq\n")); + LOGERR("Query::getFirstMatchPage: no nq\n" ); return false; } int pagenum = -1; @@ -341,7 +339,7 @@ static const int qquantum = 50; int Query::getResCnt() { if (ISNULL(m_nq) || !m_nq->xenquire) { - LOGERR(("Query::getResCnt: no query opened\n")); + LOGERR("Query::getResCnt: no query opened\n" ); return -1; } if (m_resCnt >= 0) @@ -356,9 +354,9 @@ int Query::getResCnt() m_resCnt = m_nq->xmset.get_matches_lower_bound(), 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()) - LOGERR(("xenquire->get_mset: exception: %s\n", m_reason.c_str())); + LOGERR("xenquire->get_mset: exception: " << (m_reason) << "\n" ); } else { 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. 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) { - LOGERR(("Query::getDoc: no query opened\n")); + LOGERR("Query::getDoc: no query opened\n" ); return false; } @@ -385,28 +383,24 @@ bool Query::getDoc(int xapi, Doc &doc) int last = first + m_nq->xmset.size() -1; 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, (const Xapian::RSet *)0), m_db->m_ndb->xrdb, m_reason); 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; } if (m_nq->xmset.empty()) { - LOGDEB(("enquire->get_mset: got empty result\n")); + LOGDEB("enquire->get_mset: got empty result\n" ); return false; } first = m_nq->xmset.get_firstitem(); 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::docid docid = 0; int pc = 0; @@ -424,8 +418,7 @@ bool Query::getDoc(int xapi, Doc &doc) m_reason.erase(); Chrono chron; m_db->m_ndb->xdocToUdi(xdoc, udi); - LOGDEB2(("Query::getDoc: %d ms for udi [%s], collapse count %d\n", - chron.millis(), udi.c_str(), collapsecount)); + LOGDEB2("Query::getDoc: " << (chron.millis()) << " ms for udi [" << (udi) << "], collapse count " << (collapsecount) << "\n" ); break; } catch (Xapian::DatabaseModifiedError &error) { // retry or end of loop @@ -436,7 +429,7 @@ bool Query::getDoc(int xapi, Doc &doc) break; } if (!m_reason.empty()) { - LOGERR(("Query::getDoc: %s\n", m_reason.c_str())); + LOGERR("Query::getDoc: " << (m_reason) << "\n" ); return false; } doc.meta[Rcl::Doc::keyudi] = udi; @@ -461,10 +454,10 @@ bool Query::getDoc(int xapi, Doc &doc) vector Query::expand(const Doc &doc) { - LOGDEB(("Rcl::Query::expand()\n")); + LOGDEB("Rcl::Query::expand()\n" ); vector res; if (ISNULL(m_nq) || !m_nq->xenquire) { - LOGERR(("Query::expand: no query opened\n")); + LOGERR("Query::expand: no query opened\n" ); return res; } @@ -474,11 +467,11 @@ vector Query::expand(const Doc &doc) rset.add_document(Xapian::docid(doc.xdocid)); // We don't exclude the original query terms. 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 for (Xapian::ESetIterator it = eset.begin(); it != eset.end(); it++) { - LOGDEB((" [%s]\n", (*it).c_str())); + LOGDEB(" [" << ((*it)) << "]\n" ); if ((*it).empty() || has_prefix(*it)) continue; res.push_back(*it); @@ -496,7 +489,7 @@ vector Query::expand(const Doc &doc) } 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(); } @@ -504,3 +497,4 @@ vector Query::expand(const Doc &doc) } } + diff --git a/src/rcldb/rclterms.cpp b/src/rcldb/rclterms.cpp index 5631fde2..c8f77230 100644 --- a/src/rcldb/rclterms.cpp +++ b/src/rcldb/rclterms.cpp @@ -22,7 +22,7 @@ #include -#include "debuglog.h" +#include "log.h" #include "rcldb.h" #include "rcldb_p.h" #include "stemdb.h" @@ -49,7 +49,7 @@ bool Db::filenameWildExp(const string& fnexp, vector& names, int max) pattern = "*" + pattern + "*"; } // 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 // during indexing. This seems to be the only sane possible @@ -79,12 +79,12 @@ bool Db::filenameWildExp(const string& fnexp, vector& names, int max) // Walk the Y terms and return min/max bool Db::maxYearSpan(int *minyear, int *maxyear) { - LOGDEB(("Rcl::Db:maxYearSpan\n")); + LOGDEB("Rcl::Db:maxYearSpan\n" ); *minyear = 1000000; *maxyear = -1000000; TermMatchResult result; if (!idxTermMatch(ET_WILD, string(), "*", result, -1, "xapyear")) { - LOGINFO(("Rcl::Db:maxYearSpan: termMatch failed\n")); + LOGINFO("Rcl::Db:maxYearSpan: termMatch failed\n" ); return false; } for (vector::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 case_sensitive = (typ_sens & ET_CASESENS) != 0; - LOGDEB0(("Db::TermMatch: typ %s diacsens %d casesens %d lang [%s] term [%s]" - " 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())); + 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" ); // If index is stripped, no case or diac expansion can be needed: // 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) { diac_sensitive = case_sensitive = true; 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; } } @@ -270,19 +266,17 @@ bool Db::termMatch(int typ_sens, const string &lang, const string &_term, exp1.swap(lexp); sort(lexp.begin(), lexp.end()); lexp.erase(unique(lexp.begin(), lexp.end()), lexp.end()); - LOGDEB(("ExpTerm: stemexp: %s\n", - stringsToString(lexp).c_str())); + LOGDEB("ExpTerm: stemexp: " << (stringsToString(lexp)) << "\n" ); } if (m_syngroups.ok() && (typ_sens & ET_SYNEXP)) { - LOGDEB(("ExpTerm: got syngroups\n")); + LOGDEB("ExpTerm: got syngroups\n" ); vector exp1(lexp); for (vector::const_iterator it = lexp.begin(); it != lexp.end(); it++) { vector sg = m_syngroups.getgroup(*it); if (!sg.empty()) { - LOGDEB(("ExpTerm: syns: %s -> %s\n", - it->c_str(), stringsToString(sg).c_str())); + LOGDEB("ExpTerm: syns: " << *it << " -> " << (stringsToString(sg)) << "\n" ); for (vector::const_iterator it1 = sg.begin(); it1 != sg.end(); it1++) { 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. - LOGDEB(("ExpandTerm:TM: lexp: %s\n", stringsToString(lexp).c_str())); + LOGDEB("ExpandTerm:TM: lexp: " << (stringsToString(lexp)) << "\n" ); for (vector::const_iterator it = lexp.begin(); it != lexp.end(); it++) { 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) { int typ = matchTypeTp(typ_sens); - LOGDEB1(("Db::idxTermMatch: typ %s lang [%s] term [%s] " - "max %d field [%s] init res.size %u\n", - tmtptostr(typ), lang.c_str(), root.c_str(), - max, field.c_str(), res.entries.size())); + LOGDEB1("Db::idxTermMatch: typ " << (tmtptostr(typ)) << " lang [" << (lang) << "] term [" << (root) << "] max " << (max) << " field [" << (field) << "] init res.size " << (res.entries.size()) << "\n" ); 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(); } @@ -357,8 +348,7 @@ bool Db::idxTermMatch(int typ_sens, const string &lang, const string &root, if (!field.empty()) { const FieldTraits *ftp = 0; if (!fieldToTraits(field, &ftp, true) || ftp->pfx.empty()) { - LOGDEB(("Db::termMatch: field is not indexed (no prefix): [%s]\n", - field.c_str())); + LOGDEB("Db::termMatch: field is not indexed (no prefix): [" << (field) << "]\n" ); } else { 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) { matcher = STD_SHARED_PTR(new StrRegexpMatcher(root)); if (!matcher->ok()) { - LOGERR(("termMatch: regcomp failed: %s\n", - matcher->getreason().c_str())) + LOGERR("termMatch: regcomp failed: " << (matcher->getreason())); return false; } } else if (typ == ET_WILD) { @@ -394,7 +383,7 @@ bool Db::idxTermMatch(int typ_sens, const string &lang, const string &root, } else { 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++) { try { @@ -446,7 +435,7 @@ bool Db::idxTermMatch(int typ_sens, const string &lang, const string &root, break; } if (!m_reason.empty()) { - LOGERR(("termMatch: %s\n", m_reason.c_str())); + LOGERR("termMatch: " << (m_reason) << "\n" ); return false; } @@ -468,7 +457,7 @@ TermIter *Db::termWalkOpen() tit->db = m_ndb->xrdb; XAPTRY(tit->it = tit->db.allterms_begin(), tit->db, m_reason); 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; } } @@ -484,7 +473,7 @@ bool Db::termWalkNext(TermIter *tit, string &term) , tit->db, m_reason); 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; } @@ -504,7 +493,7 @@ bool Db::termExists(const string& word) m_ndb->xrdb, m_reason); 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 true; @@ -515,8 +504,7 @@ bool Db::stemDiffers(const string& lang, const string& word, { Xapian::Stem stemmer(lang); if (!stemmer(word).compare(stemmer(base))) { - LOGDEB2(("Rcl::Db::stemDiffers: same for %s and %s\n", - word.c_str(), base.c_str())); + LOGDEB2("Rcl::Db::stemDiffers: same for " << (word) << " and " << (base) << "\n" ); return false; } return true; diff --git a/src/rcldb/searchdata.cpp b/src/rcldb/searchdata.cpp index b192787d..4cfcbf76 100644 --- a/src/rcldb/searchdata.cpp +++ b/src/rcldb/searchdata.cpp @@ -34,7 +34,7 @@ using namespace std; #include "rcldb.h" #include "rcldb_p.h" #include "searchdata.h" -#include "debuglog.h" +#include "log.h" #include "smallut.h" #include "textsplit.h" #include "unacpp.h" @@ -68,7 +68,7 @@ void SearchData::commoninit() SearchData::~SearchData() { - LOGDEB0(("SearchData::~SearchData\n")); + LOGDEB0("SearchData::~SearchData\n" ); for (qlist_it_t it = m_query.begin(); it != m_query.end(); it++) delete *it; } @@ -79,13 +79,13 @@ SearchData::~SearchData() // We remove very common terms from the query to avoid performance issues. bool SearchData::maybeAddAutoPhrase(Rcl::Db& db, double freqThreshold) { - LOGDEB0(("SearchData::maybeAddAutoPhrase()\n")); + LOGDEB0("SearchData::maybeAddAutoPhrase()\n" ); // cerr << "BEFORE SIMPLIFY\n"; dump(cerr); simplify(); // cerr << "AFTER SIMPLIFY\n"; dump(cerr); if (!m_query.size()) { - LOGDEB2(("SearchData::maybeAddAutoPhrase: empty query\n")); + LOGDEB2("SearchData::maybeAddAutoPhrase: empty query\n" ); 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++) { SClType tp = (*it)->m_tp; if (tp != SCLT_AND) { - LOGDEB2(("SearchData::maybeAddAutoPhrase: wrong tp %d\n", tp)); + LOGDEB2("SearchData::maybeAddAutoPhrase: wrong tp " << (tp) << "\n" ); return false; } SearchDataClauseSimple *clp = dynamic_cast(*it); if (clp == 0) { - LOGDEB2(("SearchData::maybeAddAutoPhrase: dyncast failed\n")); + LOGDEB2("SearchData::maybeAddAutoPhrase: dyncast failed\n" ); return false; } if (it == m_query.begin()) { field = clp->getfield(); } else { if (clp->getfield().compare(field)) { - LOGDEB2(("SearchData::maybeAddAutoPhrase: diff. fields\n")); + LOGDEB2("SearchData::maybeAddAutoPhrase: diff. fields\n" ); return false; } } // If there are wildcards or quotes in there, bail out if (clp->gettext().find_first_of("\"*[?") != string::npos) { - LOGDEB2(("SearchData::maybeAddAutoPhrase: wildcards\n")); + LOGDEB2("SearchData::maybeAddAutoPhrase: wildcards\n" ); return false; } @@ -145,8 +145,8 @@ bool SearchData::maybeAddAutoPhrase(Rcl::Db& db, double freqThreshold) swords.append(1, ' '); swords += *it; } else { - LOGDEB0(("SearchData::Autophrase: [%s] too frequent (%.2f %%)\n", - it->c_str(), 100 * freq)); + LOGDEB0("SearchData::Autophrase: [" << *it << "] too frequent (" + << (100 * freq) << " %" << ")\n" ); slack++; } } @@ -154,7 +154,7 @@ bool SearchData::maybeAddAutoPhrase(Rcl::Db& db, double freqThreshold) // We can't make a phrase with a single word :) int nwords = TextSplit::countWords(swords); if (nwords <= 1) { - LOGDEB2(("SearchData::maybeAddAutoPhrase: ended with 1 word\n")); + LOGDEB2("SearchData::maybeAddAutoPhrase: ended with 1 word\n" ); return false; } @@ -171,7 +171,7 @@ bool SearchData::maybeAddAutoPhrase(Rcl::Db& db, double freqThreshold) bool SearchData::addClause(SearchDataClause* cl) { 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"; return false; } @@ -373,3 +373,4 @@ void SearchDataClauseSub::dump(ostream& o) const } } // Namespace Rcl + diff --git a/src/rcldb/searchdatatox.cpp b/src/rcldb/searchdatatox.cpp index ffc3fc1c..1da37cbb 100644 --- a/src/rcldb/searchdatatox.cpp +++ b/src/rcldb/searchdatatox.cpp @@ -34,7 +34,7 @@ using namespace std; #include "rcldb.h" #include "rcldb_p.h" #include "searchdata.h" -#include "debuglog.h" +#include "log.h" #include "smallut.h" #include "textsplit.h" #include "unacpp.h" @@ -62,7 +62,7 @@ bool SearchData::expandFileTypes(Db &db, vector& tps) { const RclConfig *cfg = db.getConf(); if (!cfg) { - LOGFATAL(("Db::expandFileTypes: null configuration!!\n")); + LOGFATAL("Db::expandFileTypes: null configuration!!\n" ); return false; } vector exptps; @@ -113,13 +113,12 @@ bool SearchData::clausesToQuery(Rcl::Db &db, SClType tp, for (qlist_it_t it = query.begin(); it != query.end(); it++) { Xapian::Query nq; if (!(*it)->toNativeQuery(db, &nq)) { - LOGERR(("SearchData::clausesToQuery: toNativeQuery failed: %s\n", - (*it)->getReason().c_str())); + LOGERR("SearchData::clausesToQuery: toNativeQuery failed: " << ((*it)->getReason()) << "\n" ); reason += (*it)->getReason() + " "; return false; } if (nq.empty()) { - LOGDEB(("SearchData::clausesToQuery: skipping empty clause\n")); + LOGDEB("SearchData::clausesToQuery: skipping empty clause\n" ); continue; } // 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); } if (int(xq.get_length()) >= getMaxCl()) { - LOGERR(("%s\n", maxXapClauseMsg)); + LOGERR("" << (maxXapClauseMsg) << "\n" ); m_reason += maxXapClauseMsg; if (!o_index_stripchars) 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()) xq = Xapian::Query::MatchAll; @@ -163,7 +162,7 @@ bool SearchData::clausesToQuery(Rcl::Db &db, SClType tp, 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(); db.getConf()->getConfParam("maxTermExpand", &m_maxexp); @@ -175,8 +174,7 @@ bool SearchData::toNativeQuery(Rcl::Db &db, void *d) // Xapian query tree Xapian::Query xq; if (!clausesToQuery(db, m_tp, m_query, m_reason, &xq)) { - LOGERR(("SearchData::toNativeQuery: clausesToQuery failed. reason: %s\n", - m_reason.c_str())); + LOGERR("SearchData::toNativeQuery: clausesToQuery failed. reason: " << (m_reason) << "\n" ); return false; } @@ -185,7 +183,7 @@ bool SearchData::toNativeQuery(Rcl::Db &db, void *d) if (m_dates.y1 == 0 || m_dates.y2 == 0) { int minyear = 1970, maxyear = 2100; 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. } @@ -200,18 +198,16 @@ bool SearchData::toNativeQuery(Rcl::Db &db, void *d) m_dates.d2 = 31; } } - LOGDEB(("Db::toNativeQuery: date interval: %d-%d-%d/%d-%d-%d\n", - m_dates.y1, m_dates.m1, m_dates.d1, - m_dates.y2, m_dates.m2, m_dates.d2)); + LOGDEB("Db::toNativeQuery: date interval: " << (m_dates.y1) << "-" << (m_dates.m1) << "-" << (m_dates.d1) << "/" << (m_dates.y2) << "-" << (m_dates.m2) << "-" << (m_dates.d2) << "\n" ); Xapian::Query dq = date_range_filter(m_dates.y1, m_dates.m1, m_dates.d1, m_dates.y2, m_dates.m2, m_dates.d2); 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 // filter to be THE query instead of filtering an empty query. if (xq.empty()) { - LOGINFO(("Db::toNativeQuery: proba query is empty\n")); + LOGINFO("Db::toNativeQuery: proba query is empty\n" ); xq = dq; } else { 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 // filter to be THE query instead of filtering an empty query. if (xq.empty()) { - LOGINFO(("Db::toNativeQuery: proba query is empty\n")); + LOGINFO("Db::toNativeQuery: proba query is empty\n" ); xq = sq; } else { xq = Xapian::Query(Xapian::Query::OP_FILTER, xq, sq); @@ -267,7 +263,7 @@ bool SearchData::toNativeQuery(Rcl::Db &db, void *d) for (vector::iterator it = m_filetypes.begin(); it != m_filetypes.end(); 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) : Xapian::Query(Xapian::Query::OP_OR, tq, Xapian::Query(term)); } @@ -282,7 +278,7 @@ bool SearchData::toNativeQuery(Rcl::Db &db, void *d) for (vector::iterator it = m_nfiletypes.begin(); it != m_nfiletypes.end(); 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) : Xapian::Query(Xapian::Query::OP_OR, tq, Xapian::Query(term)); } @@ -337,8 +333,7 @@ public: if (m_lastpos < pos) m_lastpos = pos; bool noexpand = be ? m_ts->nostemexp() : true; - LOGDEB1(("TermProcQ::takeword: pushing [%s] pos %d noexp %d\n", - term.c_str(), pos, noexpand)); + LOGDEB1("TermProcQ::takeword: pushing [" << (term) << "] pos " << (pos) << " noexp " << (noexpand) << "\n" ); if (m_terms[pos].size() < term.size()) { m_terms[pos] = term; m_nste[pos] = noexpand; @@ -401,8 +396,7 @@ bool SearchDataClauseSimple::expandTerm(Rcl::Db &db, vector* multiwords ) { - LOGDEB0(("expandTerm: mods 0x%x fld [%s] trm [%s] lang [%s]\n", - mods, m_field.c_str(), term.c_str(), getStemLang().c_str())); + LOGDEB0("expandTerm: mods 0x" << (mods) << " fld [" << (m_field) << "] trm [" << (term) << "] lang [" << (getStemLang()) << "]\n" ); sterm.clear(); oexp.clear(); 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 bool nostemexp = (mods & SDCM_NOSTEMMING) != 0; 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; } @@ -448,7 +442,7 @@ bool SearchDataClauseSimple::expandTerm(Rcl::Db &db, // performed (conversion+comparison) will automatically ignore // accented characters which are actually a separate letter if (getAutoDiac() && unachasaccents(term)) { - LOGDEB0(("expandTerm: term has accents -> diac-sensitive\n")); + LOGDEB0("expandTerm: term has accents -> diac-sensitive\n" ); diac_sensitive = true; } @@ -459,14 +453,13 @@ bool SearchDataClauseSimple::expandTerm(Rcl::Db &db, Utf8Iter it(term); it++; 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; } // If we are sensitive to case or diacritics turn stemming off if (diac_sensitive || case_sensitive) { - LOGDEB0(("expandTerm: diac or case sens set -> " - "stemexpand and synonyms off\n")); + LOGDEB0("expandTerm: diac or case sens set -> stemexpand and synonyms off\n" ); nostemexp = true; synonyms = false; } @@ -479,8 +472,7 @@ bool SearchDataClauseSimple::expandTerm(Rcl::Db &db, if (noexpansion) { oexp.push_back(prefix + term); m_hldata.terms[term] = term; - LOGDEB(("ExpandTerm: noexpansion: final: %s\n", - stringsToString(oexp).c_str())); + LOGDEB("ExpandTerm: noexpansion: final: " << (stringsToString(oexp)) << "\n" ); return true; } @@ -521,7 +513,7 @@ bool SearchDataClauseSimple::expandTerm(Rcl::Db &db, it != oexp.end(); it++) { m_hldata.terms[strip_prefix(*it)] = term; } - LOGDEB(("ExpandTerm: final: %s\n", stringsToString(oexp).c_str())); + LOGDEB("ExpandTerm: final: " << (stringsToString(oexp)) << "\n" ); return true; } @@ -572,8 +564,7 @@ processSimpleSpan(Rcl::Db &db, string& ermsg, int mods, void * pq) { vector& pqueries(*(vector*)pq); - LOGDEB0(("StringToXapianQ::processSimpleSpan: [%s] mods 0x%x\n", - span.c_str(), (unsigned int)mods)); + LOGDEB0("StringToXapianQ::processSimpleSpan: [" << (span) << "] mods 0x" << ((unsigned int)mods) << "\n" ); vector exp; string sterm; // dumb version of user term @@ -669,7 +660,7 @@ void SearchDataClauseSimple::processPhraseOrNear(Rcl::Db &db, string& ermsg, vector::const_iterator nxit = splitData->nostemexps().begin(); for (vector::const_iterator it = splitData->terms().begin(); 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 // caller, not inside phrases, and some versions of xapian // will accept only one OR clause inside NEAR. @@ -685,8 +676,7 @@ void SearchDataClauseSimple::processPhraseOrNear(Rcl::Db &db, string& ermsg, vector exp; if (!expandTerm(db, ermsg, lmods, *it, exp, sterm, prefix)) return; - LOGDEB0(("ProcessPhraseOrNear: exp size %d, exp: %s\n", exp.size(), - stringsToString(exp).c_str())); + LOGDEB0("ProcessPhraseOrNear: exp size " << (exp.size()) << ", exp: " << (stringsToString(exp)) << "\n" ); // groups is used for highlighting, we don't want prefixes in there. vector noprefs; for (vector::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 // For phrases, give a relevance boost like we do for original terms - LOGDEB2(("PHRASE/NEAR: alltermcount %d lastpos %d\n", - splitData->alltermcount(), splitData->lastpos())); + LOGDEB2("PHRASE/NEAR: alltermcount " << (splitData->alltermcount()) << " lastpos " << (splitData->lastpos()) << "\n" ); Xapian::Query xq(op, orqueries.begin(), orqueries.end(), splitData->lastpos() + 1 + slack); if (op == Xapian::Query::OP_PHRASE) @@ -783,9 +772,7 @@ bool SearchDataClauseSimple::processUserString(Rcl::Db &db, const string &iq, vector &pqueries(*(vector*)pq); int mods = m_modifiers; - LOGDEB(("StringToXapianQ:pUS:: qstr [%s] fld [%s] mods 0x%x " - "slack %d near %d\n", - iq.c_str(), m_field.c_str(), mods, slack, useNear)); + LOGDEB("StringToXapianQ:pUS:: qstr [" << (iq) << "] fld [" << (m_field) << "] mods 0x" << (mods) << " slack " << (slack) << " near " << (useNear) << "\n" ); ermsg.erase(); m_curcl = 0; const StopList stops = db.getStopList(); @@ -805,7 +792,7 @@ bool SearchDataClauseSimple::processUserString(Rcl::Db &db, const string &iq, try { for (vector::iterator it = phrases.begin(); it != phrases.end(); it++) { - LOGDEB0(("strToXapianQ: phrase/word: [%s]\n", it->c_str())); + LOGDEB0("strToXapianQ: phrase/word: [" << *it << "]\n" ); // Anchoring modifiers int amods = stringToMods(*it); 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; - LOGDEB0(("strToXapianQ: termcount: %d\n", tpq.terms().size())); + LOGDEB0("strToXapianQ: termcount: " << (tpq.terms().size()) << "\n" ); switch (tpq.terms().size() + terminc) { case 0: continue;// ?? @@ -878,7 +865,7 @@ bool SearchDataClauseSimple::processUserString(Rcl::Db &db, const string &iq, ermsg = "Caught unknown exception"; } if (!ermsg.empty()) { - LOGERR(("stringToXapianQueries: %s\n", ermsg.c_str())); + LOGERR("stringToXapianQueries: " << (ermsg) << "\n" ); return false; } return true; @@ -887,9 +874,7 @@ bool SearchDataClauseSimple::processUserString(Rcl::Db &db, const string &iq, // Translate a simple OR or AND search clause. bool SearchDataClauseSimple::toNativeQuery(Rcl::Db &db, void *p) { - LOGDEB(("SearchDataClauseSimple::toNativeQuery: fld [%s] val [%s] " - "stemlang [%s]\n", m_field.c_str(), m_text.c_str(), - getStemLang().c_str())); + LOGDEB("SearchDataClauseSimple::toNativeQuery: fld [" << (m_field) << "] val [" << (m_text) << "] stemlang [" << (getStemLang()) << "]\n" ); Xapian::Query *qp = (Xapian::Query *)p; *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_OR: op = Xapian::Query::OP_OR; break; default: - LOGERR(("SearchDataClauseSimple: bad m_tp %d\n", m_tp)); + LOGERR("SearchDataClauseSimple: bad m_tp " << (m_tp) << "\n" ); m_reason = "Internal error"; return false; } @@ -908,7 +893,7 @@ bool SearchDataClauseSimple::toNativeQuery(Rcl::Db &db, void *p) if (!processUserString(db, m_text, m_reason, &pqueries)) return false; 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_text + string("]")); return false; @@ -952,12 +937,12 @@ bool SearchDataClauseFilename::toNativeQuery(Rcl::Db &db, void *p) // Translate a dir: path filtering clause. See comments in .h 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; *qp = Xapian::Query(); if (m_text.empty()) { - LOGERR(("SearchDataClausePath: empty path??\n")); + LOGERR("SearchDataClausePath: empty path??\n" ); m_reason = "Empty path ?"; return false; } @@ -982,8 +967,7 @@ bool SearchDataClausePath::toNativeQuery(Rcl::Db &db, void *p) *pit, exp, sterm, wrap_prefix(pathelt_prefix))) { return false; } - LOGDEB0(("SDataPath::toNative: exp size %d. Exp: %s\n", exp.size(), - stringsToString(exp).c_str())); + LOGDEB0("SDataPath::toNative: exp size " << (exp.size()) << ". Exp: " << (stringsToString(exp)) << "\n" ); if (exp.size() == 1) orqueries.push_back(Xapian::Query(exp[0])); else @@ -1006,7 +990,7 @@ bool SearchDataClausePath::toNativeQuery(Rcl::Db &db, void *p) // Translate NEAR or PHRASE clause. bool SearchDataClauseDist::toNativeQuery(Rcl::Db &db, void *p) { - LOGDEB(("SearchDataClauseDist::toNativeQuery\n")); + LOGDEB("SearchDataClauseDist::toNativeQuery\n" ); Xapian::Query *qp = (Xapian::Query *)p; *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)) return false; 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_text + string("]")); return false; @@ -1039,3 +1023,4 @@ bool SearchDataClauseDist::toNativeQuery(Rcl::Db &db, void *p) } } // Namespace Rcl + diff --git a/src/rcldb/searchdataxml.cpp b/src/rcldb/searchdataxml.cpp index 72b3b9e5..409d319e 100644 --- a/src/rcldb/searchdataxml.cpp +++ b/src/rcldb/searchdataxml.cpp @@ -25,12 +25,13 @@ #include #include #include -using namespace std; #include "searchdata.h" -#include "debuglog.h" +#include "log.h" #include "base64.h" +using namespace std; + namespace Rcl { static string tpToString(SClType tp) @@ -48,7 +49,7 @@ static string tpToString(SClType tp) string SearchData::asXML() { - LOGDEB(("SearchData::asXML\n")); + LOGDEB("SearchData::asXML\n" ); ostringstream os; // Searchdata @@ -64,7 +65,7 @@ string SearchData::asXML() for (unsigned int i = 0; i < m_query.size(); i++) { SearchDataClause *c = m_query[i]; if (c->getTp() == SCLT_SUB) { - LOGERR(("SearchData::asXML: can't do subclauses !\n")); + LOGERR("SearchData::asXML: can't do subclauses !\n" ); continue; } if (c->getTp() == SCLT_PATH) { @@ -159,3 +160,4 @@ string SearchData::asXML() } + diff --git a/src/rcldb/stemdb.cpp b/src/rcldb/stemdb.cpp index 2481c9bf..f2611dc9 100644 --- a/src/rcldb/stemdb.cpp +++ b/src/rcldb/stemdb.cpp @@ -33,7 +33,7 @@ using namespace std; #include #include "stemdb.h" -#include "debuglog.h" +#include "log.h" #include "smallut.h" #include "synfamily.h" #include "unacpp.h" @@ -85,10 +85,10 @@ bool StemDb::stemExpand(const std::string& langs, const std::string& _term, sort(result.begin(), result.end()); vector::iterator uit = unique(result.begin(), result.end()); result.resize(uit - result.begin()); - LOGDEB1(("stemExpand:%s: %s -> %s\n", langs.c_str(), term.c_str(), - stringsToString(result).c_str())); + LOGDEB1("stemExpand:" << (langs) << ": " << (term) << " -> " << (stringsToString(result)) << "\n" ); return true; } } + diff --git a/src/rcldb/stemdb.h b/src/rcldb/stemdb.h index 43153605..c84a4ba5 100644 --- a/src/rcldb/stemdb.h +++ b/src/rcldb/stemdb.h @@ -73,8 +73,7 @@ public: virtual std::string operator()(const std::string& in) { string out = m_stemmer(in); - LOGDEB2(("SynTermTransStem(%s): in [%s] out [%s]\n", m_lang.c_str(), - in.c_str(), out.c_str())); + LOGDEB2("SynTermTransStem(" << (m_lang) << "): in [" << (in) << "] out [" << (out) << "]\n" ); return out; } Xapian::Stem m_stemmer; @@ -102,3 +101,4 @@ public: } #endif /* _STEMDB_H_INCLUDED_ */ + diff --git a/src/rcldb/stoplist.cpp b/src/rcldb/stoplist.cpp index c0c1d177..6e2ed0ec 100644 --- a/src/rcldb/stoplist.cpp +++ b/src/rcldb/stoplist.cpp @@ -16,7 +16,7 @@ */ #ifndef TEST_STOPLIST -#include "debuglog.h" +#include "log.h" #include "readfile.h" #include "unacpp.h" #include "smallut.h" @@ -32,8 +32,7 @@ bool StopList::setFile(const string &filename) m_stops.clear(); string stoptext, reason; if (!file_to_string(filename, stoptext, &reason)) { - LOGDEB0(("StopList::StopList: file_to_string(%s) failed: %s\n", - filename.c_str(), reason.c_str())); + LOGDEB0("StopList::StopList: file_to_string(" << (filename) << ") failed: " << (reason) << "\n" ); return false; } set stops; @@ -116,3 +115,4 @@ int main(int argc, char **argv) } #endif // TEST_STOPLIST + diff --git a/src/rcldb/synfamily.cpp b/src/rcldb/synfamily.cpp index cf726839..03ece295 100644 --- a/src/rcldb/synfamily.cpp +++ b/src/rcldb/synfamily.cpp @@ -22,7 +22,7 @@ #include #include MEMORY_INCLUDE -#include "debuglog.h" +#include "log.h" #include "cstr.h" #include "xmacros.h" #include "synfamily.h" @@ -39,7 +39,7 @@ bool XapWritableSynFamily::createMember(const string& membername) m_wdb.add_synonym(memberskey(), membername); } XCATCHERROR(ermsg); if (!ermsg.empty()) { - LOGERR(("XapSynFamily::createMember: error: %s\n", ermsg.c_str())); + LOGERR("XapSynFamily::createMember: error: " << (ermsg) << "\n" ); return false; } return true; @@ -68,7 +68,7 @@ bool XapSynFamily::getMembers(vector& members) } } XCATCHERROR(ermsg); if (!ermsg.empty()) { - LOGERR(("XapSynFamily::getMembers: xapian error %s\n", ermsg.c_str())); + LOGERR("XapSynFamily::getMembers: xapian error " << (ermsg) << "\n" ); return false; } return true; @@ -90,7 +90,7 @@ bool XapSynFamily::listMap(const string& membername) } } XCATCHERROR(ermsg); if (!ermsg.empty()) { - LOGERR(("XapSynFamily::listMap: xapian error %s\n", ermsg.c_str())); + LOGERR("XapSynFamily::listMap: xapian error " << (ermsg) << "\n" ); return false; } vectormembers; @@ -107,21 +107,19 @@ bool XapSynFamily::listMap(const string& membername) bool XapSynFamily::synExpand(const string& member, const string& term, vector& result) { - LOGDEB(("XapSynFamily::synExpand:(%s) %s for %s\n", - m_prefix1.c_str(), term.c_str(), member.c_str())); + LOGDEB("XapSynFamily::synExpand:(" << (m_prefix1) << ") " << (term) << " for " << (member) << "\n" ); string key = entryprefix(member) + term; string ermsg; try { for (Xapian::TermIterator xit = m_rdb.synonyms_begin(key); xit != m_rdb.synonyms_end(key); xit++) { - LOGDEB2((" Pushing %s\n", (*xit).c_str())); + LOGDEB2(" Pushing " << ((*xit)) << "\n" ); result.push_back(*xit); } } XCATCHERROR(ermsg); if (!ermsg.empty()) { - LOGERR(("synFamily::synExpand: error for member [%s] term [%s]\n", - member.c_str(), term.c_str())); + LOGERR("synFamily::synExpand: error for member [" << (member) << "] term [" << (term) << "]\n" ); result.push_back(term); return false; } @@ -144,43 +142,37 @@ bool XapComputableSynFamMember::synExpand(const string& term, string key = m_prefix + root; - LOGDEB(("XapCompSynFamMbr::synExpand([%s]): term [%s] root [%s] " - "m_trans: %s filter: %s\n", - m_prefix.c_str(), term.c_str(), root.c_str(), - m_trans->name().c_str(), - filtertrans ? filtertrans->name().c_str() : "none")); + LOGDEB("XapCompSynFamMbr::synExpand([" << (m_prefix) << "]): term [" << (term) << "] root [" << (root) << "] m_trans: " << (m_trans->name()) << " filter: " << (filtertrans ? filtertrans->name() : "none") << "\n" ); string ermsg; try { for (Xapian::TermIterator xit = m_family.getdb().synonyms_begin(key); xit != m_family.getdb().synonyms_end(key); xit++) { if (!filtertrans || (*filtertrans)(*xit) == filter_root) { - LOGDEB2((" Pushing %s\n", (*xit).c_str())); + LOGDEB2(" Pushing " << ((*xit)) << "\n" ); result.push_back(*xit); } } } XCATCHERROR(ermsg); if (!ermsg.empty()) { - LOGERR(("XapSynDb::synExpand: error for term [%s] (key %s)\n", - term.c_str(), key.c_str())); + LOGERR("XapSynDb::synExpand: error for term [" << (term) << "] (key " << (key) << ")\n" ); result.push_back(term); return false; } // If the input term and root are not in the list, add them if (find(result.begin(), result.end(), term) == result.end()) { - LOGDEB2((" Pushing %s\n", term.c_str())); + LOGDEB2(" Pushing " << (term) << "\n" ); result.push_back(term); } if (root != term && find(result.begin(), result.end(), root) == result.end()) { if (!filtertrans || (*filtertrans)(root) == filter_root) { - LOGDEB2((" Pushing %s\n", root.c_str())); + LOGDEB2(" Pushing " << (root) << "\n" ); result.push_back(root); } } - LOGDEB(("XapCompSynFamMbr::synExpand([%s]): term [%s] -> [%s]\n", - m_prefix.c_str(), term.c_str(), stringsToString(result).c_str())); + LOGDEB("XapCompSynFamMbr::synExpand([" << (m_prefix) << "]): term [" << (term) << "] -> [" << (stringsToString(result)) << "]\n" ); return true; } @@ -188,7 +180,7 @@ bool XapComputableSynFamMember::synKeyExpand(StrMatcher* inexp, vector& result, SynTermTrans *filtertrans) { - LOGDEB(("XapCompSynFam::synKeyExpand: [%s]\n", inexp->exp().c_str())); + LOGDEB("XapCompSynFam::synKeyExpand: [" << (inexp->exp()) << "]\n" ); // If set, compute filtering term (e.g.: only case-folded) STD_SHARED_PTR filter_exp; @@ -204,14 +196,13 @@ bool XapComputableSynFamMember::synKeyExpand(StrMatcher* inexp, string::size_type es = inexp->baseprefixlen(); string is = inexp->exp().substr(0, es); string::size_type preflen = m_prefix.size(); - LOGDEB2(("XapCompSynFam::synKeyExpand: init section: [%s]\n", is.c_str())); + LOGDEB2("XapCompSynFam::synKeyExpand: init section: [" << (is) << "]\n" ); string ermsg; try { for (Xapian::TermIterator xit = m_family.getdb().synonym_keys_begin(is); xit != m_family.getdb().synonym_keys_end(is); xit++) { - LOGDEB2((" Checking1 [%s] against [%s]\n", (*xit).c_str(), - inexp->exp().c_str())); + LOGDEB2(" Checking1 [" << ((*xit)) << "] against [" << (inexp->exp()) << "]\n" ); if (!inexp->match(*xit)) continue; @@ -222,36 +213,32 @@ bool XapComputableSynFamMember::synKeyExpand(StrMatcher* inexp, string term = *xit1; if (filter_exp) { string term1 = (*filtertrans)(term); - LOGDEB2((" Testing [%s] against [%s]\n", - term1.c_str(), filter_exp->exp().c_str())); + LOGDEB2(" Testing [" << (term1) << "] against [" << (filter_exp->exp()) << "]\n" ); if (!filter_exp->match(term1)) { continue; } } - LOGDEB2(("XapCompSynFam::keyWildExpand: [%s]\n", - (*xit1).c_str())); + LOGDEB2("XapCompSynFam::keyWildExpand: [" << ((*xit1)) << "]\n" ); result.push_back(*xit1); } // Same with key itself string term = (*xit).substr(preflen); if (filter_exp) { string term1 = (*filtertrans)(term); - LOGDEB2((" Testing [%s] against [%s]\n", - term1.c_str(), filter_exp->exp().c_str())); + LOGDEB2(" Testing [" << (term1) << "] against [" << (filter_exp->exp()) << "]\n" ); if (!filter_exp->match(term1)) { continue; } } - LOGDEB2(("XapCompSynFam::keyWildExpand: [%s]\n", term.c_str())); + LOGDEB2("XapCompSynFam::keyWildExpand: [" << (term) << "]\n" ); result.push_back(term); } } XCATCHERROR(ermsg); if (!ermsg.empty()) { - LOGERR(("XapCompSynFam::synKeyExpand: xapian: [%s]\n", ermsg.c_str())); + LOGERR("XapCompSynFam::synKeyExpand: xapian: [" << (ermsg) << "]\n" ); return false; } - LOGDEB1(("XapCompSynFam::synKeyExpand: final: [%s]\n", - stringsToString(result).c_str())); + LOGDEB1("XapCompSynFam::synKeyExpand: final: [" << (stringsToString(result)) << "]\n" ); return true; } @@ -401,3 +388,4 @@ int main(int argc, char **argv) } #endif // TEST_SYNFAMILY + diff --git a/src/rcldb/synfamily.h b/src/rcldb/synfamily.h index 5253a052..01ade5df 100644 --- a/src/rcldb/synfamily.h +++ b/src/rcldb/synfamily.h @@ -37,7 +37,7 @@ #include -#include "debuglog.h" +#include "log.h" #include "xmacros.h" #include "strmatcher.h" @@ -168,10 +168,9 @@ public: virtual bool addSynonym(const std::string& term) { - LOGDEB2(("addSynonym:me %p term [%s] m_trans %p\n", this, - term.c_str(), m_trans)); + LOGDEB2("addSynonym:me " << (this) << " term [" << (term) << "] m_trans " << (m_trans) << "\n" ); std::string transformed = (*m_trans)(term); - LOGDEB2(("addSynonym: transformed [%s]\n", transformed.c_str())); + LOGDEB2("addSynonym: transformed [" << (transformed) << "]\n" ); if (transformed == term) return true; @@ -180,8 +179,7 @@ public: m_family.getdb().add_synonym(m_prefix + transformed, term); } XCATCHERROR(ermsg); if (!ermsg.empty()) { - LOGERR(("XapWritableComputableSynFamMember::addSynonym: " - "xapian error %s\n", ermsg.c_str())); + LOGERR("XapWritableComputableSynFamMember::addSynonym: xapian error " << (ermsg) << "\n" ); return false; } return true; @@ -224,3 +222,4 @@ static const std::string synFamDiCa("DCa"); } // end namespace Rcl #endif /* _SYNFAMILY_H_INCLUDED_ */ + diff --git a/src/utils/circache.cpp b/src/utils/circache.cpp index 08b148a5..ae00849b 100644 --- a/src/utils/circache.cpp +++ b/src/utils/circache.cpp @@ -65,7 +65,7 @@ static ssize_t writev(int fd, const struct iovec *iov, int iovcnt) #include "cstr.h" #include "circache.h" #include "conftree.h" -#include "debuglog.h" +#include "log.h" #include "smallut.h" #include "md5.h" @@ -237,32 +237,28 @@ public: bool khEnter(const string& udi, off_t ofs) { UdiH h(udi); - LOGDEB2(("Circache::khEnter: h %s offs %lu udi [%s]\n", - h.asHexString().c_str(), (ULONG)ofs, udi.c_str())); + LOGDEB2("Circache::khEnter: h " << (h.asHexString()) << " offs " << ((ULONG)ofs) << " udi [" << (udi) << "]\n" ); pair p = m_ofskh.equal_range(h); if (p.first != m_ofskh.end() && p.first->first == h) { for (kh_type::iterator it = p.first; it != p.second; it++) { - LOGDEB2(("Circache::khEnter: col h %s, ofs %lu\n", - it->first.asHexString().c_str(), - (ULONG)it->second)); + LOGDEB2("Circache::khEnter: col h " << (it->first.asHexString()) << ", ofs " << ((ULONG)it->second) << "\n" ); if (it->second == ofs) { // (h,offs) already there. Happens - LOGDEB2(("Circache::khEnter: already there\n")); + LOGDEB2("Circache::khEnter: already there\n" ); return true; } } } m_ofskh.insert(kh_value_type(h, ofs)); - LOGDEB2(("Circache::khEnter: inserted\n")); + LOGDEB2("Circache::khEnter: inserted\n" ); return true; } void khDump() { for (kh_type::const_iterator it = m_ofskh.begin(); it != m_ofskh.end(); it++) { - LOGDEB(("Circache::KHDUMP: %s %d\n", - it->first.asHexString().c_str(), (ULONG)it->second)); + LOGDEB("Circache::KHDUMP: " << (it->first.asHexString()) << " " << ((ULONG)it->second) << "\n" ); } } @@ -274,22 +270,19 @@ public: UdiH h(udi); - LOGDEB2(("Circache::khFind: h %s udi [%s]\n", - h.asHexString().c_str(), udi.c_str())); + LOGDEB2("Circache::khFind: h " << (h.asHexString()) << " udi [" << (udi) << "]\n" ); pair p = m_ofskh.equal_range(h); #if 0 if (p.first == m_ofskh.end()) { - LOGDEB(("KHFIND: FIRST END()\n")); + LOGDEB("KHFIND: FIRST END()\n" ); } if (p.second == m_ofskh.end()) { - LOGDEB(("KHFIND: SECOND END()\n")); + LOGDEB("KHFIND: SECOND END()\n" ); } if (!(p.first->first == h)) - LOGDEB(("KHFIND: NOKEY: %s %s\n", - p.first->first.asHexString().c_str(), - p.second->first.asHexString().c_str())); + LOGDEB("KHFIND: NOKEY: " << (p.first->first.asHexString()) << " " << (p.second->first.asHexString()) << "\n" ); #endif if (p.first == m_ofskh.end() || !(p.first->first == h)) { @@ -503,8 +496,7 @@ public: offset << " [" << bf << "]"; return CCScanHook::Error; } - LOGDEB2(("Circache:readEntryHeader: dcsz %u dtsz %u pdsz %u flgs %hu\n", - d.dicsize, d.datasize, d.padsize, d.flags)); + LOGDEB2("Circache:readEntryHeader: dcsz " << (d.dicsize) << " dtsz " << (d.datasize) << " pdsz " << (d.padsize) << " flgs " << (d.flags) << "\n" ); return CCScanHook::Continue; } @@ -638,7 +630,7 @@ public: } if (hd.flags & EFDataCompressed) { - LOGDEB1(("Circache:readdicdata: data compressed\n")); + LOGDEB1("Circache:readdicdata: data compressed\n" ); void *uncomp; unsigned int uncompsize; if (!inflateToDynBuf(bf, hd.datasize, &uncomp, &uncompsize)) { @@ -648,7 +640,7 @@ public: data->assign((char *)uncomp, uncompsize); free(uncomp); } else { - LOGDEB1(("Circache:readdicdata: data NOT compressed\n")); + LOGDEB1("Circache:readdicdata: data NOT compressed\n" ); data->assign(bf, hd.datasize); } } else { @@ -663,7 +655,7 @@ CirCache::CirCache(const string& dir) : m_dir(dir) { m_d = new CirCacheInternal; - LOGDEB0(("CirCache: [%s]\n", m_dir.c_str())); + LOGDEB0("CirCache: [" << (m_dir) << "]\n" ); } CirCache::~CirCache() @@ -691,8 +683,7 @@ public: const EntryHeaderData& d) { headoffs = offs; padsize = d.padsize; - LOGDEB2(("CCScanHookRecord::takeone: offs %s padsize %s\n", - lltodecstr(headoffs).c_str(), lltodecstr(padsize).c_str())); + LOGDEB2("CCScanHookRecord::takeone: offs " << (lltodecstr(headoffs)) << " padsize " << (lltodecstr(padsize)) << "\n" ); return Continue; } }; @@ -704,10 +695,9 @@ string CirCache::getpath() bool CirCache::create(off_t maxsize, int flags) { - LOGDEB(("CirCache::create: [%s] maxsz %s flags 0x%x\n", - m_dir.c_str(), lltodecstr((long long)maxsize).c_str(), flags)); + LOGDEB("CirCache::create: [" << (m_dir) << "] maxsz " << (lltodecstr((long long)maxsize)) << " flags 0x" << (flags) << "\n" ); if (m_d == 0) { - LOGERR(("CirCache::create: null data\n")); + LOGERR("CirCache::create: null data\n" ); return false; } @@ -729,7 +719,7 @@ bool CirCache::create(off_t maxsize, int flags) } if (maxsize == m_d->m_maxsize && ((flags & CC_CRUNIQUE) != 0) == m_d->m_uniquentries) { - LOGDEB(("Header unchanged, no rewrite\n")); + LOGDEB("Header unchanged, no rewrite\n" ); return true; } // If the new maxsize is bigger than current size, we need @@ -746,13 +736,7 @@ bool CirCache::create(off_t maxsize, int flags) } m_d->m_maxsize = maxsize; m_d->m_uniquentries = ((flags & CC_CRUNIQUE) != 0); - LOGDEB2(("CirCache::create: rewriting header with " - "maxsize %s oheadoffs %s nheadoffs %s " - "npadsize %d unient %d\n", - lltodecstr(m_d->m_maxsize).c_str(), - lltodecstr(m_d->m_oheadoffs).c_str(), - lltodecstr(m_d->m_nheadoffs).c_str(), - m_d->m_npadsize, int(m_d->m_uniquentries))); + LOGDEB2("CirCache::create: rewriting header with maxsize " << (lltodecstr(m_d->m_maxsize)) << " oheadoffs " << (lltodecstr(m_d->m_oheadoffs)) << " nheadoffs " << (lltodecstr(m_d->m_nheadoffs)) << " npadsize " << (m_d->m_npadsize) << " unient " << (int(m_d->m_uniquentries)) << "\n" ); return m_d->writefirstblock(); } // Else fallthrough to create file @@ -783,7 +767,7 @@ bool CirCache::create(off_t maxsize, int flags) bool CirCache::open(OpMode mode) { if (m_d == 0) { - LOGERR(("CirCache::open: null data\n")); + LOGERR("CirCache::open: null data\n" ); return false; } @@ -854,10 +838,7 @@ public: virtual status takeone(off_t offs, const string& udi, const EntryHeaderData& d) { - LOGDEB2(("Circache:Scan: off %ld udi [%s] dcsz %u dtsz %u pdsz %u " - " flgs %hu\n", - long(offs), udi.c_str(), (UINT)d.dicsize, - (UINT)d.datasize, (UINT)d.padsize, d.flags)); + LOGDEB2("Circache:Scan: off " << (long(offs)) << " udi [" << (udi) << "] dcsz " << ((UINT)d.dicsize) << " dtsz " << ((UINT)d.datasize) << " pdsz " << ((UINT)d.padsize) << " flgs " << (d.flags) << "\n" ); if (!m_udi.compare(udi)) { m_instance++; m_offs = offs; @@ -879,21 +860,21 @@ bool CirCache::get(const string& udi, string& dic, string *data, int instance) return false; } - LOGDEB0(("CirCache::get: udi [%s], instance %d\n", udi.c_str(), instance)); + LOGDEB0("CirCache::get: udi [" << (udi) << "], instance " << (instance) << "\n" ); // If memory map is up to date, use it: if (m_d->m_ofskhcplt) { - LOGDEB1(("CirCache::get: using ofskh\n")); + LOGDEB1("CirCache::get: using ofskh\n" ); //m_d->khDump(); vector ofss; if (m_d->khFind(udi, ofss)) { - LOGDEB1(("Circache::get: h found, colls %d\n", ofss.size())); + LOGDEB1("Circache::get: h found, colls " << (ofss.size()) << "\n" ); int finst = 1; EntryHeaderData d_good; off_t o_good = 0; for (vector::iterator it = ofss.begin(); it != ofss.end(); it++) { - LOGDEB1(("Circache::get: trying offs %lu\n", (ULONG)*it)); + LOGDEB1("Circache::get: trying offs " << ((ULONG)*it) << "\n" ); EntryHeaderData d; string fudi; if (!m_d->readHUdi(*it, d, fudi)) { @@ -915,8 +896,7 @@ bool CirCache::get(const string& udi, string& dic, string *data, int instance) // Did we read an appropriate entry ? if (o_good != 0 && (instance == -1 || instance == finst)) { bool ret = m_d->readDicData(o_good, d_good, dic, data); - LOGDEB0(("Circache::get: hfound, %d mS\n", - chron.millis())); + LOGDEB0("Circache::get: hfound, " << (chron.millis()) << " mS\n" ); return ret; } // Else try to scan anyway. @@ -935,7 +915,7 @@ bool CirCache::get(const string& udi, string& dic, string *data, int instance) return false; } bool bret = m_d->readDicData(getter.m_offs, getter.m_hd, dic, data); - LOGDEB0(("Circache::get: scanfound, %d mS\n", chron.millis())); + LOGDEB0("Circache::get: scanfound, " << (chron.millis()) << " mS\n" ); return bret; } @@ -943,7 +923,7 @@ bool CirCache::get(const string& udi, string& dic, string *data, int instance) bool CirCache::erase(const string& udi, bool reallyclear) { if (m_d == 0) { - LOGERR(("CirCache::erase: null data\n")); + LOGERR("CirCache::erase: null data\n" ); return false; } if (m_d->m_fd < 0) { @@ -951,7 +931,7 @@ bool CirCache::erase(const string& udi, bool reallyclear) return false; } - LOGDEB0(("CirCache::erase: udi [%s]\n", udi.c_str())); + LOGDEB0("CirCache::erase: udi [" << (udi) << "]\n" ); // If the mem cache is not up to date, update it, we're too lazy // to do a scan @@ -959,7 +939,7 @@ bool CirCache::erase(const string& udi, bool reallyclear) string dic; get("nosuchudi probably exists", dic); if (!m_d->m_ofskhcplt) { - LOGERR(("CirCache::erase : cache not updated after get\n")); + LOGERR("CirCache::erase : cache not updated after get\n" ); return false; } } @@ -967,27 +947,27 @@ bool CirCache::erase(const string& udi, bool reallyclear) vector ofss; if (!m_d->khFind(udi, ofss)) { // Udi not in there, erase ok - LOGDEB(("CirCache::erase: khFind returns none\n")); + LOGDEB("CirCache::erase: khFind returns none\n" ); return true; } for (vector::iterator it = ofss.begin(); it != ofss.end(); it++) { - LOGDEB2(("CirCache::erase: reading at %lu\n", (unsigned long)*it)); + LOGDEB2("CirCache::erase: reading at " << ((unsigned long)*it) << "\n" ); EntryHeaderData d; string fudi; if (!m_d->readHUdi(*it, d, fudi)) { return false; } - LOGDEB2(("CirCache::erase: found fudi [%s]\n", fudi.c_str())); + LOGDEB2("CirCache::erase: found fudi [" << (fudi) << "]\n" ); if (!fudi.compare(udi)) { EntryHeaderData nd; nd.padsize = d.dicsize + d.datasize + d.padsize; - LOGDEB2(("CirCache::erase: rewrite at %lu\n", (unsigned long)*it)); + LOGDEB2("CirCache::erase: rewrite at " << ((unsigned long)*it) << "\n" ); if (*it == m_d->m_nheadoffs) { m_d->m_npadsize = nd.padsize; } if (!m_d->writeEntryHeader(*it, nd, reallyclear)) { - LOGERR(("CirCache::erase: write header failed\n")); + LOGERR("CirCache::erase: write header failed\n" ); return false; } } @@ -1010,8 +990,7 @@ public: virtual status takeone(off_t offs, const string& udi, const EntryHeaderData& d) { - LOGDEB2(("Circache:ScanSpacer:off %u dcsz %u dtsz %u pdsz %u udi[%s]\n", - (UINT)offs, d.dicsize, d.datasize, d.padsize, udi.c_str())); + LOGDEB2("Circache:ScanSpacer:off " << ((UINT)offs) << " dcsz " << (d.dicsize) << " dtsz " << (d.datasize) << " pdsz " << (d.padsize) << " udi[" << (udi) << "]\n" ); sizeseen += CIRCACHE_HEADER_SIZE + d.dicsize + d.datasize + d.padsize; squashed_udis.push_back(make_pair(udi, offs)); if (sizeseen >= sizewanted) { @@ -1025,7 +1004,7 @@ bool CirCache::put(const string& udi, const ConfSimple *iconf, const string& data, unsigned int iflags) { if (m_d == 0) { - LOGERR(("CirCache::put: null data\n")); + LOGERR("CirCache::put: null data\n" ); return false; } if (m_d->m_fd < 0) { @@ -1037,15 +1016,14 @@ bool CirCache::put(const string& udi, const ConfSimple *iconf, string dic; if (!iconf || !iconf->get("udi", dic) || dic.empty() || dic.compare(udi)) { m_d->m_reason << "No/bad 'udi' entry in input dic"; - LOGERR(("Circache::put: no/bad udi: DIC:[%s] UDI [%s]\n", - dic.c_str(), udi.c_str())); + LOGERR("Circache::put: no/bad udi: DIC:[" << (dic) << "] UDI [" << (udi) << "]\n" ); return false; } // Possibly erase older entries. Need to do this first because we may be // able to reuse the space if the same udi was last written if (m_d->m_uniquentries && !erase(udi)) { - LOGERR(("CirCache::put: can't erase older entries\n")); + LOGERR("CirCache::put: can't erase older entries\n" ); return false; } @@ -1085,7 +1063,7 @@ bool CirCache::put(const string& udi, const ConfSimple *iconf, off_t npadsize = 0; bool extending = false; - LOGDEB(("CirCache::put: nsz %d oheadoffs %d\n", nsize, m_d->m_oheadoffs)); + LOGDEB("CirCache::put: nsz " << (nsize) << " oheadoffs " << (m_d->m_oheadoffs) << "\n" ); // Check if we can recover some pad space from the (physically) previous // entry. @@ -1107,7 +1085,7 @@ bool CirCache::put(const string& udi, const ConfSimple *iconf, // the header, we're going to write on it. recovpadsize += CIRCACHE_HEADER_SIZE; } else { - LOGDEB(("CirCache::put: recov. prev. padsize %d\n", pd.padsize)); + LOGDEB("CirCache::put: recov. prev. padsize " << (pd.padsize) << "\n" ); pd.padsize = 0; if (!m_d->writeEntryHeader(m_d->m_nheadoffs, pd)) { return false; @@ -1120,7 +1098,7 @@ bool CirCache::put(const string& udi, const ConfSimple *iconf, if (nsize <= recovpadsize) { // If the new entry fits entirely in the pad area from the // latest one, no need to recycle stuff - LOGDEB(("CirCache::put: new fits in old padsize %d\n", recovpadsize)); + LOGDEB("CirCache::put: new fits in old padsize " << (recovpadsize) << "\n" ); npadsize = recovpadsize - nsize; } else if (st.st_size < m_d->m_maxsize) { // Still growing the file. @@ -1130,13 +1108,11 @@ bool CirCache::put(const string& udi, const ConfSimple *iconf, // Scan the file until we have enough space for the new entry, // and determine the pad size up to the 1st preserved entry off_t scansize = nsize - recovpadsize; - LOGDEB(("CirCache::put: scanning for size %d from offs %u\n", - scansize, (UINT)m_d->m_oheadoffs)); + LOGDEB("CirCache::put: scanning for size " << (scansize) << " from offs " << ((UINT)m_d->m_oheadoffs) << "\n" ); CCScanHookSpacer spacer(scansize); switch (m_d->scan(m_d->m_oheadoffs, &spacer)) { case CCScanHook::Stop: - LOGDEB(("CirCache::put: Scan ok, sizeseen %d\n", - spacer.sizeseen)); + LOGDEB("CirCache::put: Scan ok, sizeseen " << (spacer.sizeseen) << "\n" ); npadsize = spacer.sizeseen - scansize; break; case CCScanHook::Eof: @@ -1151,8 +1127,7 @@ bool CirCache::put(const string& udi, const ConfSimple *iconf, m_d->khClear(spacer.squashed_udis); } - LOGDEB(("CirCache::put: writing %d at %d padsize %d\n", - nsize, nwriteoffs, npadsize)); + LOGDEB("CirCache::put: writing " << (nsize) << " at " << (nwriteoffs) << " padsize " << (npadsize) << "\n" ); if (lseek(m_d->m_fd, nwriteoffs, 0) != nwriteoffs) { m_d->m_reason << "CirCache::put: lseek failed: " << errno; @@ -1196,7 +1171,7 @@ bool CirCache::put(const string& udi, const ConfSimple *iconf, bool CirCache::rewind(bool& eof) { if (m_d == 0) { - LOGERR(("CirCache::rewind: null data\n")); + LOGERR("CirCache::rewind: null data\n" ); return false; } @@ -1204,7 +1179,7 @@ bool CirCache::rewind(bool& eof) off_t fsize = lseek(m_d->m_fd, 0, SEEK_END); if (fsize == (off_t) - 1) { - LOGERR(("CirCache::rewind: seek to EOF failed\n")); + LOGERR("CirCache::rewind: seek to EOF failed\n" ); return false; } // Read oldest header. This is either at the position pointed to @@ -1231,7 +1206,7 @@ bool CirCache::rewind(bool& eof) bool CirCache::next(bool& eof) { if (m_d == 0) { - LOGERR(("CirCache::next: null data\n")); + LOGERR("CirCache::next: null data\n" ); return false; } @@ -1268,7 +1243,7 @@ bool CirCache::next(bool& eof) bool CirCache::getCurrentUdi(string& udi) { if (m_d == 0) { - LOGERR(("CirCache::getCurrentUdi: null data\n")); + LOGERR("CirCache::getCurrentUdi: null data\n" ); return false; } @@ -1281,7 +1256,7 @@ bool CirCache::getCurrentUdi(string& udi) bool CirCache::getCurrent(string& udi, string& dic, string *data) { if (m_d == 0) { - LOGERR(("CirCache::getCurrent: null data\n")); + LOGERR("CirCache::getCurrent: null data\n" ); return false; } if (!m_d->readDicData(m_d->m_itoffs, m_d->m_ithd, dic, data)) { @@ -1317,7 +1292,7 @@ static bool inflateToDynBuf(void* inp, UINT inlen, void **outpp, UINT *outlenp) { z_stream d_stream; /* decompression stream */ - LOGDEB0(("inflateToDynBuf: inlen %u\n", inlen)); + LOGDEB0("inflateToDynBuf: inlen " << (inlen) << "\n" ); d_stream.zalloc = (alloc_func)0; d_stream.zfree = (free_func)0; @@ -1336,24 +1311,21 @@ static bool inflateToDynBuf(void* inp, UINT inlen, void **outpp, UINT *outlenp) int err; if ((err = inflateInit(&d_stream)) != Z_OK) { - LOGERR(("Inflate: inflateInit: err %d msg %s\n", err, d_stream.msg)); + LOGERR("Inflate: inflateInit: err " << (err) << " msg " << (d_stream.msg) << "\n" ); free(outp); return false; } for (;;) { - LOGDEB2(("InflateToDynBuf: avail_in %d total_in %d avail_out %d " - "total_out %d\n", d_stream.avail_in, d_stream.total_in, - d_stream.avail_out, d_stream.total_out)); + LOGDEB2("InflateToDynBuf: avail_in " << (d_stream.avail_in) << " total_in " << (d_stream.total_in) << " avail_out " << (d_stream.avail_out) << " total_out " << (d_stream.total_out) << "\n" ); if (d_stream.avail_out == 0) { if ((outp = (char*)allocmem(outp, inlen, &alloc, imul, mxinc)) == 0) { - LOGERR(("Inflate: out of memory, current alloc %d\n", - alloc * inlen)); + LOGERR("Inflate: out of memory, current alloc " << (alloc * inlen) << "\n" ); inflateEnd(&d_stream); return false; } else { - LOGDEB2(("inflateToDynBuf: realloc(%d) ok\n", alloc * inlen)); + LOGDEB2("inflateToDynBuf: realloc(" << (alloc * inlen) << ") ok\n" ); } d_stream.avail_out = alloc * inlen - d_stream.total_out; d_stream.next_out = (Bytef*)(outp + d_stream.total_out); @@ -1363,7 +1335,7 @@ static bool inflateToDynBuf(void* inp, UINT inlen, void **outpp, UINT *outlenp) break; } if (err != Z_OK) { - LOGERR(("Inflate: error %d msg %s\n", err, d_stream.msg)); + LOGERR("Inflate: error " << (err) << " msg " << (d_stream.msg) << "\n" ); inflateEnd(&d_stream); free(outp); return false; @@ -1373,10 +1345,10 @@ static bool inflateToDynBuf(void* inp, UINT inlen, void **outpp, UINT *outlenp) *outpp = (Bytef *)outp; if ((err = inflateEnd(&d_stream)) != Z_OK) { - LOGERR(("Inflate: inflateEnd error %d msg %s\n", err, d_stream.msg)); + LOGERR("Inflate: inflateEnd error " << (err) << " msg " << (d_stream.msg) << "\n" ); return false; } - LOGDEB0(("inflateToDynBuf: ok, output size %d\n", d_stream.total_out)); + LOGDEB0("inflateToDynBuf: ok, output size " << (d_stream.total_out) << "\n" ); return true; } @@ -1478,7 +1450,8 @@ int CirCache::append(const string ddir, const string& sdir, string *reason) #include "fileudi.h" #include "conftree.h" #include "readfile.h" -#include "debuglog.h" +#include "log.h" + #include "smallut.h" using namespace std; @@ -1706,3 +1679,4 @@ b1: } #endif + diff --git a/src/utils/copyfile.cpp b/src/utils/copyfile.cpp index 12bcd44d..5d3807d3 100644 --- a/src/utils/copyfile.cpp +++ b/src/utils/copyfile.cpp @@ -32,7 +32,7 @@ #include #include "copyfile.h" -#include "debuglog.h" +#include "log.h" using namespace std; @@ -46,7 +46,7 @@ bool copyfile(const char *src, const char *dst, string &reason, int flags) char buf[CPBSIZ]; int oflags = O_WRONLY|O_CREAT|O_TRUNC|O_BINARY; - LOGDEB(("copyfile: %s to %s\n", src, dst)); + LOGDEB("copyfile: " << (src) << " to " << (dst) << "\n" ); if ((sfd = ::open(src, O_RDONLY, 0)) < 0) { reason += string("open ") + src + ": " + strerror(errno); @@ -94,12 +94,12 @@ out: bool stringtofile(const string& dt, const char *dst, string& reason, int flags) { - LOGDEB(("stringtofile:\n")); + LOGDEB("stringtofile:\n" ); int dfd = -1; bool ret = false; int oflags = O_WRONLY|O_CREAT|O_TRUNC|O_BINARY; - LOGDEB(("stringtofile: %u bytes to %s\n", (unsigned int)dt.size(), dst)); + LOGDEB("stringtofile: " << ((unsigned int)dt.size()) << " bytes to " << (dst) << "\n" ); if (flags & COPYFILE_EXCL) { oflags |= O_EXCL; @@ -262,3 +262,4 @@ int main(int argc, const char **argv) } #endif + diff --git a/src/utils/debuglog.cpp b/src/utils/debuglog.cpp deleted file mode 100644 index b1c5083d..00000000 --- a/src/utils/debuglog.cpp +++ /dev/null @@ -1,484 +0,0 @@ -/* Copyright (C) 2006 J.F.Dockes - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the - * Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef TEST_DEBUGLOG - -#define __USE_GNU -#include -#include -#include -#include -#include -#include // in case O_APPEND is in there -#ifdef INCLUDE_NEW_H -#include -#endif - -#include -#include -using std::set; -using std::string; - -#include "debuglog.h" -#include "pathut.h" -#include "smallut.h" -#include "ptmutex.h" - -#ifndef freeZ -#define freeZ(X) {if (X) {free(X);X=0;}} -#endif - -using namespace std; -namespace DebugLog { - -bool DebugLog::isspecialname(const char *logname) -{ - return !strcmp(logname, "stdout") || !strcmp(logname, "stderr"); -} - -class DebugLogWriter { - public: - virtual ~DebugLogWriter() {} - virtual int put(const char *s) = 0; -}; - -class DLFWImpl { - char *filename; - FILE *fp; - int truncate; - public: - // Open output file if needed, return 0 if ok - void maybeopenfp() { - if (fp) - return; - if (filename == 0) - return; - if (!strcmp(filename, "stdout")) { - fp = stdout; - } else if (!strcmp(filename, "stderr")) { - fp = stderr; - } else { - fp = fopen(filename, (truncate) ? "w" : "a"); - if (fp) { - setvbuf(fp, 0, _IOLBF, BUFSIZ); -#if defined(O_APPEND) && !defined(_WIN32) - { - int flgs = 0; - fcntl(fileno(fp), F_GETFL, &flgs); - fcntl(fileno(fp), F_SETFL, flgs|O_APPEND); - } -#endif - } else { - fprintf(stderr, "Debuglog: could not open [%s] errno %d\n", - filename, errno); - } - } - return; - } - - void maybeclosefp() { -#ifdef DEBUGDEBUG - fprintf(stderr, "DebugLogImpl::maybeclosefp: filename %p, fp %p\n", - filename, fp); -#endif - // Close current file if open, and not stdout/stderr - if (fp && (filename == 0 || - (strcmp(filename, "stdout") && - strcmp(filename, "stderr")))) { - fclose(fp); - } - fp = 0; - freeZ(filename); - } - - public: - - DLFWImpl() - : filename(0), fp(0), truncate(1) - { - setfilename("stderr", 0); - } - ~DLFWImpl() { - maybeclosefp(); - } - int setfilename(const char *fn, int trnc) { - maybeclosefp(); - filename = strdup(fn); - truncate = trnc; - maybeopenfp(); - return 0; - } - const char *getfilename() { - return filename; - } - int put(const char *s) { - maybeopenfp(); - if (fp) - return fputs(s, fp); - return -1; - } -}; - -class DebugLogFileWriter : public DebugLogWriter { - DLFWImpl *impl; - PTMutexInit loglock; - public: - DebugLogFileWriter() - { - impl = new DLFWImpl; - } - - virtual ~DebugLogFileWriter() - { - delete impl; - } - - virtual int setfilename(const char *fn, int trnc) - { - PTMutexLocker lock(loglock); - return impl ? impl->setfilename(fn, trnc) : -1; - } - virtual const char *getfilename() - { - PTMutexLocker lock(loglock); - return impl ? impl->getfilename() : 0; - } - virtual int reopen() - { - PTMutexLocker lock(loglock); - if (!impl) - return -1; - string fn = impl->getfilename(); - return impl->setfilename(fn.c_str(), 1); - } - virtual int put(const char *s) - { - PTMutexLocker lock(loglock); - return impl ? impl->put(s) : -1; - }; -}; - - -static set yesfiles; -static void initfiles() -{ - const char *cp = getenv("DEBUGLOG_FILES"); - if (!cp) - return; - vector files; - stringToTokens(cp, files, ","); - yesfiles.insert(files.begin(), files.end()); -} -static bool fileInFiles(const string& file) -{ - string sf = path_getsimple(file); - if (yesfiles.find(sf) != yesfiles.end()) { - //fprintf(stderr, "Debug ON: %s \n", file.c_str()); - return true; - } - //fprintf(stderr, "Debug OFF: %s \n", file.c_str()); - return false; -} - -#ifdef _WIN32 -#include -static void datestring(char *d, int sz) { - SYSTEMTIME buf; - GetLocalTime(&buf); - int year = buf.wYear % 100; - - snprintf(d, sz, "%02d%02d%02d%02d%02d%02d", year, int(buf.wMonth), - int(buf.wDay), int(buf.wHour), int(buf.wMinute), int(buf.wSecond)); -} -#define vsnprintf _vsnprintf - -#else // !WINDOWS -> - -#include -static void datestring(char *d, int sz) -{ - struct tm *tmp; - time_t tim = time((time_t*)0); - tmp = localtime(&tim); - int year = tmp->tm_year % 100; - snprintf(d, sz, "%02d%02d%02d%02d%02d%02d", year, tmp->tm_mon+1, - tmp->tm_mday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec); -} - -#endif // !WINDOWS - -void -DebugLog::prolog(int lev, const char *f, int line) -{ - if (!writer) - return; - if (!yesfiles.empty() && !fileInFiles(f)) { - fileyes = false; - return; - } else { - fileyes = true; - } - if (dodate) { - char dts[100]; - datestring(dts, 100); - writer->put(dts); - } - char buf[100]; - sprintf(buf, ":%d:", lev); - writer->put(buf); -#if DEBUGLOG_SHOW_PID - sprintf(buf, "%d:", getpid()); - writer->put(buf); -#endif -#if DEBUGLOG_SHOW_THREAD - sprintf(buf, "%lx:", (unsigned long)pthread_self()); - writer->put(buf); -#endif - writer->put(f); - sprintf(buf, ":%d:", line); - writer->put(buf); -} - -void -DebugLog::log(const char *s ...) -{ - if (!writer || !fileyes) - return; - va_list ap; - va_start(ap,s); - -#ifdef HAVE_VASPRINTF_nono // not sure vasprintf is really such a great idea - char *buf; - vasprintf(&buf, s, ap); - if (buf) { -#else - char buf[4096]; - // It's possible that they also wouldn't have vsnprintf but what then ? - vsnprintf(buf, 4096, s, ap); - { -#endif - writer->put(buf); - } - -#ifdef HAVE_VASPRINTF_nono - if (buf) - free(buf); -#endif -} - -void -DebugLog::setloglevel(int lev) -{ - debuglevel = lev; - while (!levels.empty()) - levels.pop(); - pushlevel(lev); -} - -void DebugLog::pushlevel(int lev) -{ - debuglevel = lev; - levels.push(lev); -} - -void DebugLog::poplevel() -{ - if (levels.empty()) - debuglevel = 0; - if (levels.size() > 1) - levels.pop(); - debuglevel = levels.top(); -} - - -//////////////////////////////////////////////////////////// -// Global functions -////////////////////////////////////// -static DebugLogFileWriter lwriter; -static DebugLogFileWriter *theWriter = &lwriter; - -const char *getfilename() -{ - return theWriter ? theWriter->getfilename() : 0; -} - -int setfilename(const char *fname, int trnc) -{ - return theWriter ? theWriter->setfilename(fname, trnc) : -1; -} - -int reopen() -{ - return theWriter ? theWriter->reopen() : -1; - -} - -#if DEBUGLOG_USE_THREADS -#include -static pthread_key_t dbl_key; -static pthread_once_t key_once = PTHREAD_ONCE_INIT; - -static void thrdatadel(void *data) -{ - // fprintf(stderr, "DebugLog:: thrdatadel: %p\n", data); - DebugLog *dbl = (DebugLog *)data; - delete dbl; - pthread_setspecific(dbl_key, 0); -} -static void once_routine(void) -{ - int status; - status = pthread_key_create(&dbl_key, thrdatadel); - if (status != 0) { - fprintf(stderr, "debuglog: cant initialize pthread " - "thread private storage key\n"); - abort(); - } -} - -DebugLog *getdbl() -{ - int status = pthread_once(&key_once, once_routine); - if (status != 0) { - fprintf(stderr, "debuglog: cant initialize pthread " - "thread private storage key (pthread_once)\n"); - abort(); - } - DebugLog *dbl; - if (!(dbl = (DebugLog *)pthread_getspecific(dbl_key))) { - if ((dbl = new DebugLog) == 0) { - fprintf(stderr, "debuglog: new DebugLog returned 0! "); - abort(); - } - - dbl->setwriter(theWriter); - initfiles(); - status = pthread_setspecific(dbl_key, dbl); - if (status) { - fprintf(stderr, "debuglog: cant initialize pthread " - "thread private storage key (pthread_setspecific)\n"); - abort(); - } - } - return dbl; -} - -#else // No threads -> - -static DebugLog *dbl; -DebugLog *getdbl() -{ - if (!dbl) { - dbl = new DebugLog; - dbl->setwriter(theWriter); - initfiles(); - } - return dbl; -} -#endif - -} - -////////////////////////////////////////// TEST DRIVER ////////////////// -#else /* TEST_DEBUGLOG */ - -#include -#include -#ifdef _WIN32 -#include -static inline unsigned int sleep(unsigned int s) {Sleep(s * 1000); return 0;} -#else -#include -#endif -#include - -#include "debuglog.h" - -#if DEBUGLOG_USE_THREADS -//#define TEST_THREADS -#endif - -#ifdef TEST_THREADS -#include -#endif - -const int iloop = 5; -void *thread_test(void *data) -{ - const char *s = (const char *)data; - int lev = atoi(s); - DebugLog::getdbl()->setloglevel(DEBDEB); - for (int i = 1; i < iloop;i++) { - switch (lev) { - case 1: LOGFATAL(("Thread: %s count: %d\n", s, i));break; - case 2: LOGERR(("Thread: %s count: %d\n", s, i));break; - default: - case 3: LOGINFO(("Thread: %s count: %d\n", s, i));break; - } - sleep(1); - } - return 0; -} - - -int -main(int argc, char **argv) -{ -#ifdef TEST_THREADS - pthread_t t1, t2, t3; - - char name1[20]; - strcpy(name1, "1"); - pthread_create(&t1, 0, thread_test, name1); - - char name2[20]; - strcpy(name2, "2"); - pthread_create(&t2, 0, thread_test, name2); - - char name3[20]; - strcpy(name3, "3"); - pthread_create(&t3, 0, thread_test, name3); - - DebugLog::getdbl()->setloglevel(DEBDEB); - for (int i = 1; i < iloop;i++) { - LOGINFO(("LOGGING FROM MAIN\n")); - sleep(1); - } - sleep(2); - exit(0); -#else - LOGFATAL(("FATAL\n","Val")); - DebugLog::getdbl()->logdate(1); - LOGERR(("ERR\n","Val")); - LOGINFO(("INFO\n","Val")); - LOGDEB0(("DEBUG %s\n","valeur")); - - int lev; - printf("Testing push. Initial level: %d\n", DebugLog::getdbl()->getlevel()); - for (lev = 0; lev < 4;lev++) { - DebugLog::getdbl()->pushlevel(lev); - printf("Lev now %d\n", DebugLog::getdbl()->getlevel()); - } - printf("Testing pop\n"); - for (lev = 0; lev < 7;lev++) { - DebugLog::getdbl()->poplevel(); - printf("Lev now %d\n", DebugLog::getdbl()->getlevel()); - } -#endif -} - - -#endif /* TEST_DEBUGLOG */ diff --git a/src/utils/debuglog.h b/src/utils/debuglog.h deleted file mode 100644 index 04921bc6..00000000 --- a/src/utils/debuglog.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the - * Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef _DEBUGLOG_H_ -#define _DEBUGLOG_H_ -/* Macros for log and debug messages */ -#include - -namespace DebugLog { - -#ifndef DEBUGLOG_USE_THREADS -#define DEBUGLOG_USE_THREADS 1 -#endif - -#define DEBFATAL 1 -#define DEBERR 2 -#define DEBINFO 3 -#define DEBDEB 4 -#define DEBDEB0 5 -#define DEBDEB1 6 -#define DEBDEB2 7 -#define DEBDEB3 8 - -#ifndef STATICVERBOSITY -#define STATICVERBOSITY DEBDEB0 -#endif - -class DebugLogWriter; - -class DebugLog { - std::stack levels; - int debuglevel; - int dodate; - DebugLogWriter *writer; - bool fileyes; - public: - DebugLog() : debuglevel(10), dodate(0), writer(0), fileyes(true) {} - DebugLog(DebugLogWriter *w) : debuglevel(-1), dodate(0), writer(w), - fileyes(true) {} - virtual ~DebugLog() {} - virtual void setwriter(DebugLogWriter *w) {writer = w;} - virtual DebugLogWriter *getwriter() {return writer;} - virtual void prolog(int lev, const char *srcfname, int line); - virtual void log(const char *s ...); - virtual void setloglevel(int lev); - inline int getlevel() {return debuglevel;} - virtual void pushlevel(int lev); - virtual void poplevel(); - virtual void logdate(int onoff) {dodate = onoff;} - static bool isspecialname(const char *logname); -}; - -extern DebugLog *getdbl(); -extern const char *getfilename(); -extern int setfilename(const char *fname, int trnc = 1); -extern int reopen(); - -#if STATICVERBOSITY >= DEBFATAL -#define LOGFATAL(X) {if (DebugLog::getdbl()->getlevel()>=DEBFATAL){DebugLog::getdbl()->prolog(DEBFATAL,__FILE__,__LINE__) ;DebugLog::getdbl()->log X;}} -#else -#define LOGFATAL(X) -#endif -#if STATICVERBOSITY >= DEBERR -#define LOGERR(X) {if (DebugLog::getdbl()->getlevel()>=DEBERR){DebugLog::getdbl()->prolog(DEBERR,__FILE__,__LINE__) ;DebugLog::getdbl()->log X;}} -#else -#define LOGERR(X) -#endif -#if STATICVERBOSITY >= DEBINFO -#define LOGINFO(X) {if (DebugLog::getdbl()->getlevel()>=DEBINFO){DebugLog::getdbl()->prolog(DEBINFO,__FILE__,__LINE__) ;DebugLog::getdbl()->log X;}} -#else -#define LOGINFO(X) -#endif -#if STATICVERBOSITY >= DEBDEB -#define LOGDEB(X) {if (DebugLog::getdbl()->getlevel()>=DEBDEB){DebugLog::getdbl()->prolog(DEBDEB,__FILE__,__LINE__) ;DebugLog::getdbl()->log X;}} -#else -#define LOGDEB(X) -#endif -#if STATICVERBOSITY >= DEBDEB0 -#define LOGDEB0(X) {if (DebugLog::getdbl()->getlevel()>=DEBDEB0){DebugLog::getdbl()->prolog(DEBDEB0,__FILE__,__LINE__) ;DebugLog::getdbl()->log X;}} -#else -#define LOGDEB0(X) -#endif -#if STATICVERBOSITY >= DEBDEB1 -#define LOGDEB1(X) {if (DebugLog::getdbl()->getlevel()>=DEBDEB1){DebugLog::getdbl()->prolog(DEBDEB1,__FILE__,__LINE__) ;DebugLog::getdbl()->log X;}} -#else -#define LOGDEB1(X) -#endif -#if STATICVERBOSITY >= DEBDEB2 -#define LOGDEB2(X) {if (DebugLog::getdbl()->getlevel()>=DEBDEB2){DebugLog::getdbl()->prolog(DEBDEB2,__FILE__,__LINE__) ;DebugLog::getdbl()->log X;}} -#else -#define LOGDEB2(X) -#endif -#if STATICVERBOSITY >= DEBDEB3 -#define LOGDEB3(X) {if (DebugLog::getdbl()->getlevel()>=DEBDEB3){DebugLog::getdbl()->prolog(DEBDEB3,__FILE__,__LINE__) ;DebugLog::getdbl()->log X;}} -#else -#define LOGDEB3(X) -#endif -} -#endif /* _DEBUGLOG_H_ */ diff --git a/src/utils/ecrontab.cpp b/src/utils/ecrontab.cpp index 1b147ed2..17416f86 100644 --- a/src/utils/ecrontab.cpp +++ b/src/utils/ecrontab.cpp @@ -22,7 +22,7 @@ #include "ecrontab.h" #include "execmd.h" #include "smallut.h" -#include "debuglog.h" +#include "log.h" // Read crontab file and split it into lines. static bool eCrontabGetLines(vector& lines) @@ -128,8 +128,7 @@ bool checkCrontabUnmanaged(const string& marker, const string& data) bool getCrontabSched(const string& marker, const string& id, vector& sched) { - LOGDEB0(("getCrontabSched: marker[%s], id[%s]\n", - marker.c_str(), id.c_str())); + LOGDEB0("getCrontabSched: marker[" << (marker) << "], id[" << (id) << "]\n" ); vector lines; if (!eCrontabGetLines(lines)) { // No crontab, answer is no @@ -270,3 +269,4 @@ int main(int argc, char **argv) exit(0); } #endif // TEST + diff --git a/src/utils/execmd.cpp b/src/utils/execmd.cpp index d5df94cc..feba4945 100644 --- a/src/utils/execmd.cpp +++ b/src/utils/execmd.cpp @@ -50,33 +50,15 @@ #endif #include "execmd.h" - #include "netcon.h" #include "closefrom.h" #include "smallut.h" +#include "log.h" using namespace std; extern char **environ; -#ifdef BUILDING_RECOLL -#include "debuglog.h" - -#else -// If compiling outside of recoll, make the file as standalone as reasonable. - -#define LOGFATAL(X) -#define LOGERR(X) -#define LOGINFO(X) -#define LOGDEB(X) -#define LOGDEB0(X) -#define LOGDEB1(X) -#define LOGDEB2(X) -#define LOGDEB3(X) -#define LOGDEB4(X) - -#endif // BUILDING_RECOLL - class ExecCmd::Internal { public: Internal() @@ -267,7 +249,7 @@ public: if (!m_active || !m_parent) { return; } - LOGDEB1(("~ExecCmdRsrc: working. mypid: %d\n", (int)getpid())); + LOGDEB1("~ExecCmdRsrc: working. mypid: " << getpid() << "\n"); // Better to close the descs first in case the child is waiting in read if (m_parent->m_pipein[0] >= 0) { @@ -289,7 +271,7 @@ public: // definitely tried to call killpg(-1,) from time to time. pid_t grp; if (m_parent->m_pid > 0 && (grp = getpgid(m_parent->m_pid)) > 0) { - LOGDEB(("ExecCmd: killpg(%d, SIGTERM)\n", grp)); + LOGDEB("ExecCmd: killpg(" << (grp) << ", SIGTERM)\n"); int ret = killpg(grp, SIGTERM); if (ret == 0) { for (int i = 0; i < 3; i++) { @@ -300,14 +282,14 @@ public: break; } if (i == 2) { - LOGDEB(("ExecCmd: killpg(%d, SIGKILL)\n", grp)); + LOGDEB("ExecCmd: killpg(" << (grp) << ", SIGKILL)\n"); killpg(grp, SIGKILL); (void)waitpid(m_parent->m_pid, &status, WNOHANG); } } } else { - LOGERR(("ExecCmd: error killing process group %d: %d\n", - grp, errno)); + LOGERR("ExecCmd: error killing process group " << (grp) << + ": " << errno << "\n"); } } m_parent->m_tocmd.reset(); @@ -347,8 +329,8 @@ inline void ExecCmd::Internal::dochild(const string& cmd, const char **argv, { // Start our own process group if (setpgid(0, getpid())) { - LOGINFO(("ExecCmd::DOCHILD: setpgid(0, %d) failed: errno %d\n", - getpid(), errno)); + LOGINFO("ExecCmd::DOCHILD: setpgid(0, " << getpid() << + ") failed: errno " << errno << "\n"); } // Restore SIGTERM to default. Really, signal handling should be @@ -364,7 +346,7 @@ inline void ExecCmd::Internal::dochild(const string& cmd, const char **argv, // to mess with the global process signal disposition. if (signal(SIGTERM, SIG_DFL) == SIG_ERR) { - //LOGERR(("ExecCmd::DOCHILD: signal() failed, errno %d\n", errno)); + //LOGERR("ExecCmd::DOCHILD: signal() failed, errno " << errno << "\n"); } sigset_t sset; sigfillset(&sset); @@ -415,10 +397,12 @@ inline void ExecCmd::Internal::dochild(const string& cmd, const char **argv, close(m_pipeout[0]); if (m_pipeout[1] != 1) { if (dup2(m_pipeout[1], 1) < 0) { - LOGERR(("ExecCmd::DOCHILD: dup2() failed. errno %d\n", errno)); + LOGERR("ExecCmd::DOCHILD: dup2() failed. errno " << + errno << "\n"); } if (close(m_pipeout[1]) < 0) { - LOGERR(("ExecCmd::DOCHILD: close() failed. errno %d\n", errno)); + LOGERR("ExecCmd::DOCHILD: close() failed. errno " << + errno << "\n"); } } } @@ -446,8 +430,8 @@ inline void ExecCmd::Internal::dochild(const string& cmd, const char **argv, // Hu ho. This should never have happened as we checked the // existence of the executable before calling dochild... Until we // did this check, this was the chief cause of LOG mutex deadlock - LOGERR(("ExecCmd::DOCHILD: execve(%s) failed. errno %d\n", cmd.c_str(), - errno)); + LOGERR("ExecCmd::DOCHILD: execve(" << cmd << ") failed. errno " << + errno << "\n"); _exit(127); } @@ -466,19 +450,19 @@ int ExecCmd::startExec(const string& cmd, const vector& args, it != args.end(); it++) { command += "{" + *it + "} "; } - LOGDEB(("ExecCmd::startExec: (%d|%d) %s\n", - has_input, has_output, command.c_str())); + LOGDEB("ExecCmd::startExec: (" << has_input << "|" << has_output << + ") " << command << "\n"); } // The resource manager ensures resources are freed if we return early ExecCmdRsrc e(this->m); if (has_input && pipe(m->m_pipein) < 0) { - LOGERR(("ExecCmd::startExec: pipe(2) failed. errno %d\n", errno)); + LOGERR("ExecCmd::startExec: pipe(2) failed. errno " << errno << "\n" ); return -1; } if (has_output && pipe(m->m_pipeout) < 0) { - LOGERR(("ExecCmd::startExec: pipe(2) failed. errno %d\n", errno)); + LOGERR("ExecCmd::startExec: pipe(2) failed. errno " << errno << "\n"); return -1; } @@ -494,7 +478,7 @@ int ExecCmd::startExec(const string& cmd, const vector& args, Ccharp *argv; argv = (Ccharp *)malloc((args.size() + 2) * sizeof(char *)); if (argv == 0) { - LOGERR(("ExecCmd::doexec: malloc() failed. errno %d\n", errno)); + LOGERR("ExecCmd::doexec: malloc() failed. errno " << errno << "\n"); return -1; } // Fill up argv @@ -514,7 +498,7 @@ int ExecCmd::startExec(const string& cmd, const vector& args, } envv = (Ccharp *)malloc((envsize + m->m_env.size() + 2) * sizeof(char *)); if (envv == 0) { - LOGERR(("ExecCmd::doexec: malloc() failed. errno %d\n", errno)); + LOGERR("ExecCmd::doexec: malloc() failed. errno " << errno << "\n"); free(argv); return -1; } @@ -531,7 +515,7 @@ int ExecCmd::startExec(const string& cmd, const vector& args, // As we are going to use execve, not execvp, do the PATH thing. string exe; if (!which(cmd, exe)) { - LOGERR(("ExecCmd::startExec: %s not found\n", cmd.c_str())); + LOGERR("ExecCmd::startExec: " << (cmd) << " not found\n"); free(argv); free(envv); return -1; @@ -590,7 +574,7 @@ int ExecCmd::startExec(const string& cmd, const vector& args, posix_spawn_file_actions_addopen(&facts, 2, m->m_stderrFile.c_str(), oflags, 0600); } - LOGDEB1(("using SPAWN\n")); + LOGDEB1("using SPAWN\n"); // posix_spawn() does not have any standard way to ask for // calling closefrom(). Afaik there is a solaris extension for this, @@ -604,22 +588,22 @@ int ExecCmd::startExec(const string& cmd, const vector& args, posix_spawnattr_destroy(&attrs); posix_spawn_file_actions_destroy(&facts); if (ret) { - LOGERR(("ExecCmd::startExec: posix_spawn() failed. errno %d\n", - ret)); + LOGERR("ExecCmd::startExec: posix_spawn() failed. errno " << ret << + "\n"); return -1; } } #else if (Internal::o_useVfork) { - LOGDEB1(("using VFORK\n")); + LOGDEB1("using VFORK\n"); m->m_pid = vfork(); } else { - LOGDEB1(("using FORK\n")); + LOGDEB1("using FORK\n"); m->m_pid = fork(); } if (m->m_pid < 0) { - LOGERR(("ExecCmd::startExec: fork(2) failed. errno %d\n", errno)); + LOGERR("ExecCmd::startExec: fork(2) failed. errno " << errno << "\n"); return -1; } if (m->m_pid == 0) { @@ -645,8 +629,8 @@ int ExecCmd::startExec(const string& cmd, const vector& args, if (setpgid(m->m_pid, m->m_pid)) { // This can fail with EACCES if the son has already done execve // (linux at least) - LOGDEB2(("ExecCmd: father setpgid(son)(%d,%d) errno %d (ok)\n", - m->m_pid, m->m_pid, errno)); + LOGDEB2("ExecCmd: father setpgid(son)(" << m->m_pid << "," << + m->m_pid << ") errno " << errno << " (ok)\n"); } sigemptyset(&m->m_blkcld); @@ -690,8 +674,8 @@ public: if (!m_input) { return -1; } - LOGDEB1(("ExecWriter: input m_cnt %d input length %d\n", m_cnt, - m_input->length())); + LOGDEB1("ExecWriter: input m_cnt " << m_cnt << " input length " << + m_input->length() << "\n"); if (m_cnt >= m_input->length()) { // Fd ready for more but we got none. Try to get data, else // shutdown; @@ -707,14 +691,14 @@ public: // Ready with new buffer, reset use count m_cnt = 0; } - LOGDEB2(("ExecWriter: provide m_cnt %d input length %d\n", - m_cnt, m_input->length())); + LOGDEB2("ExecWriter: provide m_cnt " << m_cnt << + " input length " << m_input->length() << "\n"); } int ret = con->send(m_input->c_str() + m_cnt, m_input->length() - m_cnt); - LOGDEB2(("ExecWriter: wrote %d to command\n", ret)); + LOGDEB2("ExecWriter: wrote " << (ret) << " to command\n"); if (ret <= 0) { - LOGERR(("ExecWriter: data: can't write\n")); + LOGERR("ExecWriter: data: can't write\n"); return -1; } m_cnt += ret; @@ -736,9 +720,9 @@ public: virtual int data(NetconData *con, Netcon::Event reason) { char buf[8192]; int n = con->receive(buf, 8192); - LOGDEB1(("ExecReader: got %d from command\n", n)); + LOGDEB1("ExecReader: got " << (n) << " from command\n"); if (n < 0) { - LOGERR(("ExecCmd::doexec: receive failed. errno %d\n", errno)); + LOGERR("ExecCmd::doexec: receive failed. errno " << errno << "\n"); } else if (n > 0) { m_output->append(buf, n); if (m_advise) { @@ -770,7 +754,7 @@ int ExecCmd::doexec(const string& cmd, const vector& args, if (output) { NetconCli *oclicon = m->m_fromcmd.get(); if (!oclicon) { - LOGERR(("ExecCmd::doexec: no connection from command\n")); + LOGERR("ExecCmd::doexec: no connection from command\n"); return -1; } oclicon->setcallback(STD_SHARED_PTR @@ -783,7 +767,7 @@ int ExecCmd::doexec(const string& cmd, const vector& args, if (input) { NetconCli *iclicon = m->m_tocmd.get(); if (!iclicon) { - LOGERR(("ExecCmd::doexec: no connection from command\n")); + LOGERR("ExecCmd::doexec: no connection from command\n"); return -1; } iclicon->setcallback(STD_SHARED_PTR @@ -796,16 +780,16 @@ int ExecCmd::doexec(const string& cmd, const vector& args, // Do the actual reading/writing/waiting myloop.setperiodichandler(0, 0, m->m_timeoutMs); while ((ret = myloop.doLoop()) > 0) { - LOGDEB(("ExecCmd::doexec: selectloop returned %d\n", ret)); + LOGDEB("ExecCmd::doexec: selectloop returned " << (ret) << "\n"); if (m->m_advise) { m->m_advise->newData(0); } if (m->m_killRequest) { - LOGINFO(("ExecCmd::doexec: cancel request\n")); + LOGINFO("ExecCmd::doexec: cancel request\n"); break; } } - LOGDEB0(("ExecCmd::doexec: selectloop returned %d\n", ret)); + LOGDEB0("ExecCmd::doexec: selectloop returned " << (ret) << "\n"); // Check for interrupt request: we won't want to waitpid() if (m->m_advise) { m->m_advise->newData(0); @@ -838,7 +822,7 @@ int ExecCmd::send(const string& data) { NetconCli *con = m->m_tocmd.get(); if (con == 0) { - LOGERR(("ExecCmd::send: outpipe is closed\n")); + LOGERR("ExecCmd::send: outpipe is closed\n"); return -1; } unsigned int nwritten = 0; @@ -848,7 +832,7 @@ int ExecCmd::send(const string& data) } int n = con->send(data.c_str() + nwritten, data.length() - nwritten); if (n < 0) { - LOGERR(("ExecCmd::send: send failed\n")); + LOGERR("ExecCmd::send: send failed\n"); return -1; } nwritten += n; @@ -860,7 +844,7 @@ int ExecCmd::receive(string& data, int cnt) { NetconCli *con = m->m_fromcmd.get(); if (con == 0) { - LOGERR(("ExecCmd::receive: inpipe is closed\n")); + LOGERR("ExecCmd::receive: inpipe is closed\n"); return -1; } const int BS = 4096; @@ -870,13 +854,13 @@ int ExecCmd::receive(string& data, int cnt) int toread = cnt > 0 ? MIN(cnt - ntot, BS) : BS; int n = con->receive(buf, toread); if (n < 0) { - LOGERR(("ExecCmd::receive: error\n")); + LOGERR("ExecCmd::receive: error\n"); return -1; } else if (n > 0) { ntot += n; data.append(buf, n); } else { - LOGDEB(("ExecCmd::receive: got 0\n")); + LOGDEB("ExecCmd::receive: got 0\n"); break; } } while (cnt > 0 && ntot < cnt); @@ -887,7 +871,7 @@ int ExecCmd::getline(string& data) { NetconCli *con = m->m_fromcmd.get(); if (con == 0) { - LOGERR(("ExecCmd::receive: inpipe is closed\n")); + LOGERR("ExecCmd::receive: inpipe is closed\n"); return -1; } const int BS = 1024; @@ -904,17 +888,17 @@ again: int n = con->getline(buf, BS, timeosecs); if (n < 0) { if (con->timedout()) { - LOGDEB(("ExecCmd::getline: timeout\n")); + LOGDEB("ExecCmd::getline: timeout\n"); if (m->m_advise) { m->m_advise->newData(0); } goto again; } - LOGERR(("ExecCmd::getline: error\n")); + LOGERR("ExecCmd::getline: error\n"); } else if (n > 0) { data.append(buf, n); } else { - LOGDEB(("ExecCmd::getline: got 0\n")); + LOGDEB("ExecCmd::getline: got 0\n"); } return n; } @@ -968,10 +952,10 @@ int ExecCmd::wait() int status = -1; if (!m->m_killRequest && m->m_pid > 0) { if (waitpid(m->m_pid, &status, 0) < 0) { - LOGERR(("ExecCmd::waitpid: returned -1 errno %d\n", errno)); + LOGERR("ExecCmd::waitpid: returned -1 errno " << errno << "\n"); status = -1; } - LOGDEB(("ExecCmd::wait: got status 0x%x\n", status)); + LOGDEB("ExecCmd::wait: got status 0x" << (status) << "\n"); m->m_pid = -1; } // Let the ExecCmdRsrc cleanup, it will do the killing/waiting if needed @@ -990,15 +974,15 @@ bool ExecCmd::maybereap(int *status) pid_t pid = waitpid(m->m_pid, status, WNOHANG); if (pid < 0) { - LOGERR(("ExecCmd::maybereap: returned -1 errno %d\n", errno)); + LOGERR("ExecCmd::maybereap: returned -1 errno " << errno << "\n"); m->m_pid = -1; return true; } else if (pid == 0) { - LOGDEB1(("ExecCmd::maybereap: not exited yet\n")); + LOGDEB1("ExecCmd::maybereap: not exited yet\n"); e.inactivate(); return false; } else { - LOGDEB(("ExecCmd::maybereap: got status 0x%x\n", status)); + LOGDEB("ExecCmd::maybereap: got status 0x" << (status) << "\n"); m->m_pid = -1; return true; } @@ -1008,7 +992,7 @@ bool ExecCmd::maybereap(int *status) bool ExecCmd::backtick(const vector cmd, string& out) { if (cmd.empty()) { - LOGERR(("ExecCmd::backtick: empty command\n")); + LOGERR("ExecCmd::backtick: empty command\n"); return false; } vector::const_iterator it = cmd.begin(); @@ -1108,9 +1092,9 @@ void ReExec::reexec() // Try to get back to the initial working directory if (m_cfd < 0 || fchdir(m_cfd) < 0) { - LOGINFO(("ReExec::reexec: fchdir failed, trying chdir\n")); + LOGINFO("ReExec::reexec: fchdir failed, trying chdir\n"); if (!m_curdir.empty() && chdir(m_curdir.c_str())) { - LOGERR(("ReExec::reexec: chdir failed\n")); + LOGERR("ReExec::reexec: chdir failed\n"); } } @@ -1122,7 +1106,7 @@ void ReExec::reexec() Ccharp *argv; argv = (Ccharp *)malloc((m_argv.size() + 1) * sizeof(char *)); if (argv == 0) { - LOGERR(("ExecCmd::doexec: malloc() failed. errno %d\n", errno)); + LOGERR("ExecCmd::doexec: malloc() failed. errno " << errno << "\n"); return; } @@ -1151,7 +1135,8 @@ void ReExec::reexec() #include #include -#include "debuglog.h" +#include "log.h" + #include "execmd.h" #ifdef BUILDING_RECOLL #include "smallut.h" @@ -1505,3 +1490,4 @@ int main(int argc, char *argv[]) } } #endif // TEST + diff --git a/src/utils/fstreewalk.cpp b/src/utils/fstreewalk.cpp index 5ffa7ba5..532f3ae6 100644 --- a/src/utils/fstreewalk.cpp +++ b/src/utils/fstreewalk.cpp @@ -33,7 +33,7 @@ #include #include "cstr.h" -#include "debuglog.h" +#include "log.h" #include "pathut.h" #include "fstreewalk.h" @@ -335,7 +335,7 @@ FsTreeWalker::Status FsTreeWalker::iwalk(const string &top, int curdepth = slashcount(top) - data->basedepth; if (data->maxdepth >= 0 && curdepth >= data->maxdepth) { - LOGDEB1(("FsTreeWalker::iwalk: Maxdepth reached: [%s]\n", top.c_str())); + LOGDEB1("FsTreeWalker::iwalk: Maxdepth reached: [" << (top) << "]\n" ); return status; } @@ -351,8 +351,7 @@ FsTreeWalker::Status FsTreeWalker::iwalk(const string &top, if (data->options & FtwFollow) { DirId dirid(stp->st_dev, stp->st_ino); if (data->donedirs.find(dirid) != data->donedirs.end()) { - LOGINFO(("Not processing [%s] (already seen as other path)\n", - top.c_str())); + LOGINFO("Not processing [" << (top) << "] (already seen as other path)\n" ); return status; } data->donedirs.insert(dirid); @@ -634,3 +633,4 @@ int main(int argc, const char **argv) } #endif // TEST_FSTREEWALK + diff --git a/src/utils/idfile.cpp b/src/utils/idfile.cpp index 4c13683b..291b2c44 100644 --- a/src/utils/idfile.cpp +++ b/src/utils/idfile.cpp @@ -25,7 +25,7 @@ #include #include "idfile.h" -#include "debuglog.h" +#include "log.h" using namespace std; @@ -76,7 +76,7 @@ static string idFileInternal(istream& input, const char *fn) input.getline(cline, LL-1); if (input.fail()) { if (input.bad()) { - LOGERR(("idfile: error while reading [%s]\n", fn)); + LOGERR("idfile: error while reading [" << (fn) << "]\n" ); return string(); } // Must be eof ? @@ -88,7 +88,7 @@ static string idFileInternal(istream& input, const char *fn) if (ll > 0) gotnonempty = true; - LOGDEB2(("idfile: lnum %d ll %u: [%s]\n", lnum, (unsigned int)ll, cline)); + LOGDEB2("idfile: lnum " << (lnum) << " ll " << ((unsigned int)ll) << ": [" << (cline) << "]\n" ); // Check for a few things that can't be found in a mail file, // (optimization to get a quick negative) @@ -98,7 +98,7 @@ static string idFileInternal(istream& input, const char *fn) // Accept a few empty lines at the beginning of the file, // otherwise this is the end of headers if (gotnonempty || lnum > 10) { - LOGDEB2(("Got empty line\n")); + LOGDEB2("Got empty line\n" ); break; } else { // Don't increment the line counter for initial empty lines. @@ -109,7 +109,7 @@ static string idFileInternal(istream& input, const char *fn) // emacs vm can insert VERY long header lines. if (ll > LL - 20) { - LOGDEB2(("idFile: Line too long\n")); + LOGDEB2("idFile: Line too long\n" ); return string(); } @@ -117,7 +117,7 @@ static string idFileInternal(istream& input, const char *fn) if (lnum == 1 && !strncmp("From ", cline, 5)) { if (treat_mbox_as_rfc822 == -1) { line1HasFrom = true; - LOGDEB2(("idfile: line 1 has From_\n")); + LOGDEB2("idfile: line 1 has From_\n" ); } continue; } @@ -130,7 +130,7 @@ static string idFileInternal(istream& input, const char *fn) if (!isspace((unsigned char)cline[0])) { char *cp = strchr(cline, ':'); if (cp == 0 || (cp - cline) > 70) { - LOGDEB2(("idfile: can't be mail header line: [%s]\n", cline)); + LOGDEB2("idfile: can't be mail header line: [" << (cline) << "]\n" ); break; } } @@ -160,7 +160,7 @@ string idFile(const char *fn) ifstream input; input.open(fn, ios::in); if (!input.is_open()) { - LOGERR(("idFile: could not open [%s]\n", fn)); + LOGERR("idFile: could not open [" << (fn) << "]\n" ); return string(); } return idFileInternal(input, fn); @@ -184,7 +184,8 @@ string idFileMem(const string& data) using namespace std; -#include "debuglog.h" +#include "log.h" + #include "idfile.h" int main(int argc, char **argv) @@ -203,3 +204,4 @@ int main(int argc, char **argv) } #endif + diff --git a/src/utils/log.cpp b/src/utils/log.cpp new file mode 100644 index 00000000..1b57d2a5 --- /dev/null +++ b/src/utils/log.cpp @@ -0,0 +1,65 @@ +/* Copyright (C) 2014 J.F.Dockes + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "log.h" + +#include +#include + +using namespace std; + +Logger::Logger(const std::string& fn) + : m_tocerr(false), m_loglevel(LLDEB), m_fn(fn) +{ + reopen(fn); +} + +bool Logger::reopen(const std::string& fn) +{ +#if LOGGER_THREADSAFE + std::unique_lock lock(m_mutex); +#endif + if (!fn.empty()) { + m_fn = fn; + } + if (!m_tocerr && m_stream.is_open()) { + m_stream.close(); + } + if (!m_fn.empty() && m_fn.compare("stderr")) { + m_stream.open(m_fn, std::fstream::out | std::ofstream::trunc); + if (!m_stream.is_open()) { + cerr << "Logger::Logger: log open failed: for [" << + fn << "] errno " << errno << endl; + m_tocerr = true; + } else { + m_tocerr = false; + } + } else { + m_tocerr = true; + } + return true; +} + +static Logger *theLog; + +Logger *Logger::getTheLog(const string& fn) +{ + if (theLog == 0) + theLog = new Logger(fn); + return theLog; +} + diff --git a/src/utils/log.h b/src/utils/log.h new file mode 100644 index 00000000..d7b59fb5 --- /dev/null +++ b/src/utils/log.h @@ -0,0 +1,180 @@ +/* Copyright (C) 2014 J.F.Dockes + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#ifndef _LOG_H_X_INCLUDED_ +#define _LOG_H_X_INCLUDED_ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#ifndef LOGGER_THREADSAFE +#define LOGGER_THREADSAFE 1 +#endif + +#if LOGGER_THREADSAFE +#include +#endif + +// Can't use the symbolic Logger::LLXX names in preproc. 6 is LLDEB1 +#ifndef LOGGER_STATICVERBOSITY +#define LOGGER_STATICVERBOSITY 5 +#endif + +class Logger { +public: + /** Initialize logging to file name. Use "stderr" for stderr + output. Creates the singleton logger object */ + static Logger *getTheLog(const std::string& fn); + + bool reopen(const std::string& fn); + + std::ostream& getstream() { + return m_tocerr ? std::cerr : m_stream; + } + enum LogLevel {LLNON=0, LLFAT=1, LLERR=2, LLINF=3, LLDEB=4, + LLDEB0=5, LLDEB1=6, LLDEB2=7}; + void setLogLevel(LogLevel level) { + m_loglevel = level; + } + int getloglevel() { + return m_loglevel; + } + +#if LOGGER_THREADSAFE + std::mutex& getmutex() { + return m_mutex; + } +#endif + +private: + bool m_tocerr; + int m_loglevel; + std::string m_fn; + std::ofstream m_stream; +#if LOGGER_THREADSAFE + std::mutex m_mutex; +#endif + + Logger(const std::string& fn); + Logger(const Logger &); + Logger& operator=(const Logger &); +}; + +#define LOGGER_PRT (Logger::getTheLog("")->getstream()) + +#if LOGGER_THREADSAFE +#define LOGGER_LOCK \ + std::unique_lock lock(Logger::getTheLog("")->getmutex()) +#else +#define LOGGER_LOCK +#endif + +#ifndef LOGGER_LOCAL_LOGINC +#define LOGGER_LOCAL_LOGINC 0 +#endif + +#define LOGGER_LEVEL (Logger::getTheLog("")->getloglevel() + \ + LOGGER_LOCAL_LOGINC) + +#define LOGGER_DOLOG(L,X) LOGGER_PRT << ":" << L << ":" << \ + __FILE__ << ":" << __LINE__ << "::" << X + +#if LOGGER_STATICVERBOSITY >= 7 +#define LOGDEB2(X) { \ + if (LOGGER_LEVEL >= Logger::LLDEB2) { \ + LOGGER_LOCK; \ + LOGGER_DOLOG(Logger::LLDEB2, X); \ + } \ + } +#else +#define LOGDEB2(X) +#endif + +#if LOGGER_STATICVERBOSITY >= 6 +#define LOGDEB1(X) { \ + if (LOGGER_LEVEL >= Logger::LLDEB1) { \ + LOGGER_LOCK; \ + LOGGER_DOLOG(Logger::LLDEB1, X); \ + } \ + } +#else +#define LOGDEB1(X) +#endif + +#if LOGGER_STATICVERBOSITY >= 5 +#define LOGDEB0(X) { \ + if (LOGGER_LEVEL >= Logger::LLDEB0) { \ + LOGGER_LOCK; \ + LOGGER_DOLOG(Logger::LLDEB0, X); \ + } \ + } +#else +#define LOGDEB0(X) +#endif + +#if LOGGER_STATICVERBOSITY >= 4 +#define LOGDEB(X) { \ + if (LOGGER_LEVEL >= Logger::LLDEB) { \ + LOGGER_LOCK; \ + LOGGER_DOLOG(Logger::LLDEB, X); \ + } \ + } +#else +#define LOGDEB(X) +#endif + +#if LOGGER_STATICVERBOSITY >= 3 +#define LOGINF(X) { \ + if (LOGGER_LEVEL >= Logger::LLINF) { \ + LOGGER_LOCK; \ + LOGGER_DOLOG(Logger::LLINF, X); \ + } \ + } +#else +#define LOGINF(X) +#endif +#define LOGINFO LOGINF + +#if LOGGER_STATICVERBOSITY >= 2 +#define LOGERR(X) { \ + if (LOGGER_LEVEL >= Logger::LLERR) { \ + LOGGER_LOCK; \ + LOGGER_DOLOG(Logger::LLERR, X); \ + } \ + } +#else +#define LOGERR(X) +#endif + +#if LOGGER_STATICVERBOSITY >= 1 +#define LOGFAT(X) { \ + if (LOGGER_LEVEL >= Logger::LLFAT) { \ + LOGGER_LOCK; \ + LOGGER_DOLOG(Logger::LLFAT, X); \ + } \ + } +#else +#define LOGFAT(X) +#endif +#define LOGFATAL LOGFAT + +#endif /* _LOG_H_X_INCLUDED_ */ diff --git a/src/utils/netcon.cpp b/src/utils/netcon.cpp index 151130ea..a420fe96 100644 --- a/src/utils/netcon.cpp +++ b/src/utils/netcon.cpp @@ -17,7 +17,6 @@ // Wrapper classes for the socket interface - #ifndef TEST_NETCON #ifdef BUILDING_RECOLL #include "autoconfig.h" @@ -25,6 +24,8 @@ #include "config.h" #endif +#include "netcon.h" + #include #include #include @@ -46,24 +47,7 @@ #include - -#ifdef BUILDING_RECOLL -#include "debuglog.h" - -#else - -#define LOGFATAL(X) -#define LOGERR(X) -#define LOGINFO(X) -#define LOGDEB(X) -#define LOGDEB0(X) -#define LOGDEB1(X) -#define LOGDEB2(X) -#define LOGDEB3(X) -#define LOGDEB4(X) -#endif - -#include "netcon.h" +#include "log.h" using namespace std; @@ -84,15 +68,15 @@ using namespace std; static const int one = 1; static const int zero = 0; -#define LOGSYSERR(who, call, spar) \ - LOGERR(("%s: %s(%s) errno %d (%s)\n", who, call, \ - spar, errno, strerror(errno))) +#define LOGSYSERR(who, call, spar) \ + LOGERR((who) << ": " << (call) << "(" << (spar) << ") errno " << \ + (errno) << " (" << (strerror(errno)) << ")\n") #ifndef MIN -#define MIN(a,b) (ab?a:b) +#define MAX(a,b) ((a)>(b)?(a):(b)) #endif #ifndef freeZ #define freeZ(X) if (X) {free(X);X=0;} @@ -121,7 +105,7 @@ int Netcon::select1(int fd, int timeo, int write) ret = select(fd + 1, &rd, 0, 0, &tv); } if (!FD_ISSET(fd, &rd)) { - LOGDEB2(("Netcon::select1: fd %d timeout\n", fd)); + LOGDEB2("Netcon::select1: fd " << (fd) << " timeout\n" ); } return ret; } @@ -188,7 +172,7 @@ int SelectLoop::doLoop() for (;;) { if (m_selectloopDoReturn) { m_selectloopDoReturn = false; - LOGDEB(("Netcon::selectloop: returning on request\n")); + LOGDEB("Netcon::selectloop: returning on request\n" ); return m_selectloopReturnValue; } int nfds; @@ -203,7 +187,7 @@ int SelectLoop::doLoop() it != m_polldata.end(); it++) { NetconP& pll = it->second; int fd = it->first; - LOGDEB2(("Selectloop: fd %d flags 0x%x\n", fd, pll->m_wantedEvents)); + LOGDEB2("Selectloop: fd " << (fd) << " flags 0x" << (pll->m_wantedEvents) << "\n" ); if (pll->m_wantedEvents & Netcon::NETCONPOLL_READ) { FD_SET(fd, &rd); nfds = MAX(nfds, fd + 1); @@ -223,11 +207,11 @@ int SelectLoop::doLoop() // Just in case there would still be open fds in there // (with no r/w flags set). Should not be needed, but safer m_polldata.clear(); - LOGDEB1(("Netcon::selectloop: no fds\n")); + LOGDEB1("Netcon::selectloop: no fds\n" ); return 0; } - LOGDEB2(("Netcon::selectloop: selecting, nfds = %d\n", nfds)); + LOGDEB2("Netcon::selectloop: selecting, nfds = " << (nfds) << "\n" ); // Compute the next timeout according to what might need to be // done apart from waiting for data @@ -235,7 +219,7 @@ int SelectLoop::doLoop() periodictimeout(&tv); // Wait for something to happen int ret = select(nfds, &rd, &wd, 0, &tv); - LOGDEB2(("Netcon::selectloop: select returns %d\n", ret)); + LOGDEB2("Netcon::selectloop: select returns " << (ret) << "\n" ); if (ret < 0) { LOGSYSERR("Netcon::selectloop", "select", ""); return -1; @@ -268,9 +252,7 @@ int SelectLoop::doLoop() int canread = FD_ISSET(fd, &rd); int canwrite = FD_ISSET(fd, &wd); bool none = !canread && !canwrite; - LOGDEB2(("Netcon::selectloop: fd %d %s %s %s\n", fd, - none ? "blocked" : "can" , canread ? "read" : "", - canwrite ? "write" : "")); + LOGDEB2("Netcon::selectloop: fd " << (fd) << " " << (none ? "blocked" : "can") << " " << (canread ? "read" : "") << " " << (canwrite ? "write" : "") << "\n" ); if (none) { continue; } @@ -278,7 +260,7 @@ int SelectLoop::doLoop() map::iterator it = m_polldata.find(fd); if (it == m_polldata.end()) { /// This should not happen actually - LOGDEB2(("Netcon::selectloop: fd %d not found\n", fd)); + LOGDEB2("Netcon::selectloop: fd " << (fd) << " not found\n" ); continue; } @@ -292,14 +274,13 @@ int SelectLoop::doLoop() pll->m_wantedEvents &= ~Netcon::NETCONPOLL_WRITE; } if (!(pll->m_wantedEvents & (Netcon::NETCONPOLL_WRITE | Netcon::NETCONPOLL_READ))) { - LOGDEB0(("Netcon::selectloop: fd %d has 0x%x mask, erasing\n", - it->first, it->second->m_wantedEvents)); + LOGDEB0("Netcon::selectloop: fd " << (it->first) << " has 0x" << (it->second->m_wantedEvents) << " mask, erasing\n" ); m_polldata.erase(it); } } // fd sweep } // forever loop - LOGERR(("SelectLoop::doLoop: got out of loop !\n")); + LOGERR("SelectLoop::doLoop: got out of loop !\n" ); return -1; } @@ -309,7 +290,7 @@ int SelectLoop::addselcon(NetconP con, int events) if (!con) { return -1; } - LOGDEB1(("Netcon::addselcon: fd %d\n", con->m_fd)); + LOGDEB1("Netcon::addselcon: fd " << (con->m_fd) << "\n" ); con->set_nonblock(1); con->setselevents(events); m_polldata[con->m_fd] = con; @@ -323,10 +304,10 @@ int SelectLoop::remselcon(NetconP con) if (!con) { return -1; } - LOGDEB1(("Netcon::remselcon: fd %d\n", con->m_fd)); + LOGDEB1("Netcon::remselcon: fd " << (con->m_fd) << "\n" ); map::iterator it = m_polldata.find(con->m_fd); if (it == m_polldata.end()) { - LOGDEB1(("Netcon::remselcon: con not found for fd %d\n", con->m_fd)); + LOGDEB1("Netcon::remselcon: con not found for fd " << (con->m_fd) << "\n" ); return -1; } con->setloop(0); @@ -369,9 +350,9 @@ void Netcon::setpeer(const char *hostname) int Netcon::settcpnodelay(int on) { - LOGDEB2(("Netcon::settcpnodelay\n")); + LOGDEB2("Netcon::settcpnodelay\n" ); if (m_fd < 0) { - LOGERR(("Netcon::settcpnodelay: connection not opened\n")); + LOGERR("Netcon::settcpnodelay: connection not opened\n" ); return -1; } char *cp = on ? (char *)&one : (char *)&zero; @@ -408,14 +389,14 @@ NetconData::~NetconData() int NetconData::send(const char *buf, int cnt, int expedited) { - LOGDEB2(("NetconData::send: fd %d cnt %d expe %d\n", m_fd, cnt, expedited)); + LOGDEB2("NetconData::send: fd " << (m_fd) << " cnt " << (cnt) << " expe " << (expedited) << "\n" ); int flag = 0; if (m_fd < 0) { - LOGERR(("NetconData::send: connection not opened\n")); + LOGERR("NetconData::send: connection not opened\n" ); return -1; } if (expedited) { - LOGDEB2(("NetconData::send: expedited data, count %d bytes\n", cnt)); + LOGDEB2("NetconData::send: expedited data, count " << (cnt) << " bytes\n" ); flag = MSG_OOB; } int ret; @@ -439,9 +420,9 @@ int NetconData::send(const char *buf, int cnt, int expedited) // Test for data available int NetconData::readready() { - LOGDEB2(("NetconData::readready\n")); + LOGDEB2("NetconData::readready\n" ); if (m_fd < 0) { - LOGERR(("NetconData::readready: connection not opened\n")); + LOGERR("NetconData::readready: connection not opened\n" ); return -1; } return select1(m_fd, 0); @@ -450,9 +431,9 @@ int NetconData::readready() // Test for writable int NetconData::writeready() { - LOGDEB2(("NetconData::writeready\n")); + LOGDEB2("NetconData::writeready\n" ); if (m_fd < 0) { - LOGERR(("NetconData::writeready: connection not opened\n")); + LOGERR("NetconData::writeready: connection not opened\n" ); return -1; } return select1(m_fd, 0, 1); @@ -461,10 +442,9 @@ int NetconData::writeready() // Receive at most cnt bytes (maybe less) int NetconData::receive(char *buf, int cnt, int timeo) { - LOGDEB2(("NetconData::receive: cnt %d timeo %d m_buf 0x%x m_bufbytes %d\n", - cnt, timeo, m_buf, m_bufbytes)); + LOGDEB2("NetconData::receive: cnt " << (cnt) << " timeo " << (timeo) << " m_buf 0x" << (m_buf) << " m_bufbytes " << (m_bufbytes) << "\n" ); if (m_fd < 0) { - LOGERR(("NetconData::receive: connection not opened\n")); + LOGERR("NetconData::receive: connection not opened\n" ); return -1; } int fromibuf = 0; @@ -476,7 +456,7 @@ int NetconData::receive(char *buf, int cnt, int timeo) m_bufbytes -= fromibuf; m_bufbase += fromibuf; cnt -= fromibuf; - LOGDEB2(("NetconData::receive: transferred %d from mbuf\n", fromibuf)); + LOGDEB2("NetconData::receive: transferred " << (fromibuf) << " from mbuf\n" ); if (cnt <= 0) { return fromibuf; } @@ -484,7 +464,7 @@ int NetconData::receive(char *buf, int cnt, int timeo) if (timeo > 0) { int ret = select1(m_fd, timeo); if (ret == 0) { - LOGDEB2(("NetconData::receive timed out\n")); + LOGDEB2("NetconData::receive timed out\n" ); m_didtimo = 1; return -1; } @@ -500,7 +480,7 @@ int NetconData::receive(char *buf, int cnt, int timeo) LOGSYSERR("NetconData::receive", "read", fdcbuf); return -1; } - LOGDEB2(("NetconData::receive: normal return, cnt %d\n", cnt)); + LOGDEB2("NetconData::receive: normal return, cnt " << (cnt) << "\n" ); return fromibuf + cnt; } @@ -508,11 +488,11 @@ int NetconData::receive(char *buf, int cnt, int timeo) int NetconData::doreceive(char *buf, int cnt, int timeo) { int got, cur; - LOGDEB2(("Netcon::doreceive: cnt %d, timeo %d\n", cnt, timeo)); + LOGDEB2("Netcon::doreceive: cnt " << (cnt) << ", timeo " << (timeo) << "\n" ); cur = 0; while (cnt > cur) { got = receive(buf, cnt - cur, timeo); - LOGDEB2(("Netcon::doreceive: got %d\n", got)); + LOGDEB2("Netcon::doreceive: got " << (got) << "\n" ); if (got < 0) { return -1; } @@ -536,7 +516,7 @@ int NetconData::doreceive(char *buf, int cnt, int timeo) static const int defbufsize = 200; int NetconData::getline(char *buf, int cnt, int timeo) { - LOGDEB2(("NetconData::getline: cnt %d, timeo %d\n", cnt, timeo)); + LOGDEB2("NetconData::getline: cnt " << (cnt) << ", timeo " << (timeo) << "\n" ); if (m_buf == 0) { if ((m_buf = (char *)malloc(defbufsize)) == 0) { LOGSYSERR("NetconData::getline: Out of mem", "malloc", ""); @@ -553,8 +533,7 @@ int NetconData::getline(char *buf, int cnt, int timeo) // pointers consistant in all end cases int maxtransf = MIN(m_bufbytes, cnt - 1); int nn = maxtransf; - LOGDEB2(("Before loop, bufbytes %d, maxtransf %d, nn: %d\n", - m_bufbytes, maxtransf, nn)); + LOGDEB2("Before loop, bufbytes " << (m_bufbytes) << ", maxtransf " << (maxtransf) << ", nn: " << (nn) << "\n" ); for (nn = maxtransf; nn > 0;) { // This is not pretty but we want nn to be decremented for // each byte copied (even newline), and not become -1 if @@ -568,8 +547,7 @@ int NetconData::getline(char *buf, int cnt, int timeo) maxtransf -= nn; // Actual count transferred m_bufbytes -= maxtransf; cnt -= maxtransf; - LOGDEB2(("After transfer: actual transf %d cnt %d, m_bufbytes %d\n", - maxtransf, cnt, m_bufbytes)); + LOGDEB2("After transfer: actual transf " << (maxtransf) << " cnt " << (cnt) << ", m_bufbytes " << (m_bufbytes) << "\n" ); // Finished ? if (cnt <= 1 || (cp > buf && cp[-1] == '\n')) { @@ -599,7 +577,7 @@ int NetconData::getline(char *buf, int cnt, int timeo) // and discard. int NetconData::cando(Netcon::Event reason) { - LOGDEB2(("NetconData::cando\n")); + LOGDEB2("NetconData::cando\n" ); if (m_user) { return m_user->data(this, reason); } @@ -627,7 +605,7 @@ int NetconData::cando(Netcon::Event reason) int NetconCli::openconn(const char *host, unsigned int port, int timeo) { int ret = -1; - LOGDEB2(("Netconcli::openconn: host %s, port %d\n", host, port)); + LOGDEB2("Netconcli::openconn: host " << (host) << ", port " << (port) << "\n" ); closeconn(); @@ -648,8 +626,7 @@ int NetconCli::openconn(const char *host, unsigned int port, int timeo) } else { struct hostent *hp; if ((hp = gethostbyname(host)) == 0) { - LOGERR(("NetconCli::openconn: gethostbyname(%s) failed\n", - host)); + LOGERR("NetconCli::openconn: gethostbyname(" << (host) << ") failed\n" ); return -1; } memcpy(&ip_addr.sin_addr, hp->h_addr, hp->h_length); @@ -665,7 +642,7 @@ int NetconCli::openconn(const char *host, unsigned int port, int timeo) memset(&unix_addr, 0, sizeof(unix_addr)); unix_addr.sun_family = AF_UNIX; if (strlen(host) > UNIX_PATH_MAX - 1) { - LOGERR(("NetconCli::openconn: name too long: %s\n", host)); + LOGERR("NetconCli::openconn: name too long: " << (host) << "\n" ); return -1; } strcpy(unix_addr.sun_path, host); @@ -700,13 +677,13 @@ connectok: set_nonblock(0); } - LOGDEB2(("NetconCli::connect: setting keepalive\n")); + LOGDEB2("NetconCli::connect: setting keepalive\n" ); if (setsockopt(m_fd, SOL_SOCKET, SO_KEEPALIVE, (char *)&one, sizeof(one)) < 0) { LOGSYSERR("NetconCli::connect", "setsockopt", "KEEPALIVE"); } setpeer(host); - LOGDEB2(("NetconCli::openconn: connection opened ok\n")); + LOGDEB2("NetconCli::openconn: connection opened ok\n" ); ret = 0; out: if (ret < 0) { @@ -718,12 +695,12 @@ out: // Same as previous, but get the port number from services int NetconCli::openconn(const char *host, const char *serv, int timeo) { - LOGDEB2(("Netconcli::openconn: host %s, serv %s\n", host, serv)); + LOGDEB2("Netconcli::openconn: host " << (host) << ", serv " << (serv) << "\n" ); if (host[0] != '/') { struct servent *sp; if ((sp = getservbyname(serv, "tcp")) == 0) { - LOGERR(("NetconCli::openconn: getservbyname failed for %s\n", serv)); + LOGERR("NetconCli::openconn: getservbyname failed for " << (serv) << "\n" ); return -1; } // Callee expects the port number in host byte order @@ -736,7 +713,7 @@ int NetconCli::openconn(const char *host, const char *serv, int timeo) int NetconCli::setconn(int fd) { - LOGDEB2(("Netconcli::setconn: fd %d\n", fd)); + LOGDEB2("Netconcli::setconn: fd " << (fd) << "\n" ); closeconn(); m_fd = fd; @@ -776,10 +753,10 @@ int NetconServLis::openservice(const char *serv, int backlog) int port; struct servent *servp; if (!serv) { - LOGERR(("NetconServLis::openservice: null serv??\n")); + LOGERR("NetconServLis::openservice: null serv??\n" ); return -1; } - LOGDEB1(("NetconServLis::openservice: serv %s\n", serv)); + LOGDEB1("NetconServLis::openservice: serv " << (serv) << "\n" ); #ifdef NETCON_ACCESSCONTROL if (initperms(serv) < 0) { return -1; @@ -789,16 +766,14 @@ int NetconServLis::openservice(const char *serv, int backlog) m_serv = serv; if (serv[0] != '/') { if ((servp = getservbyname(serv, "tcp")) == 0) { - LOGERR(("NetconServLis::openservice: getservbyname failed for %s\n", - serv)); + LOGERR("NetconServLis::openservice: getservbyname failed for " << (serv) << "\n" ); return -1; } port = (int)ntohs((short)servp->s_port); return openservice(port, backlog); } else { if (strlen(serv) > UNIX_PATH_MAX - 1) { - LOGERR(("NetconServLis::openservice: too long for AF_UNIX: %s\n", - serv)); + LOGERR("NetconServLis::openservice: too long for AF_UNIX: " << (serv) << "\n" ); return -1; } int ret = -1; @@ -820,7 +795,7 @@ int NetconServLis::openservice(const char *serv, int backlog) goto out; } - LOGDEB1(("NetconServLis::openservice: service opened ok\n")); + LOGDEB1("NetconServLis::openservice: service opened ok\n" ); ret = 0; out: if (ret < 0 && m_fd >= 0) { @@ -834,7 +809,7 @@ out: // Port is a natural host integer value int NetconServLis::openservice(int port, int backlog) { - LOGDEB1(("NetconServLis::openservice: port %d\n", port)); + LOGDEB1("NetconServLis::openservice: port " << (port) << "\n" ); #ifdef NETCON_ACCESSCONTROL if (initperms(port) < 0) { return -1; @@ -863,7 +838,7 @@ int NetconServLis::openservice(int port, int backlog) goto out; } - LOGDEB1(("NetconServLis::openservice: service opened ok\n")); + LOGDEB1("NetconServLis::openservice: service opened ok\n" ); ret = 0; out: if (ret < 0 && m_fd >= 0) { @@ -893,7 +868,7 @@ int NetconServLis::initperms(const char *serv) } if (serv == 0 || *serv == 0 || strlen(serv) > 80) { - LOGERR(("NetconServLis::initperms: bad service name %s\n", serv)); + LOGERR("NetconServLis::initperms: bad service name " << (serv) << "\n" ); return -1; } @@ -903,17 +878,17 @@ int NetconServLis::initperms(const char *serv) serv = "default"; sprintf(keyname, "%s_okaddrs", serv); if (genparams->getparam(keyname, &okaddrs) < 0) { - LOGERR(("NetconServLis::initperms: no okaddrs found in config file\n")); + LOGERR("NetconServLis::initperms: no okaddrs found in config file\n" ); return -1; } } sprintf(keyname, "%s_okmasks", serv); if (genparams->getparam(keyname, &okmasks)) { - LOGERR(("NetconServLis::initperms: okmasks not found\n")); + LOGERR("NetconServLis::initperms: okmasks not found\n" ); return -1; } if (okaddrs.len == 0 || okmasks.len == 0) { - LOGERR(("NetconServLis::initperms: len 0 for okmasks or okaddrs\n")); + LOGERR("NetconServLis::initperms: len 0 for okmasks or okaddrs\n" ); return -1; } @@ -935,12 +910,12 @@ int NetconServLis::cando(Netcon::Event reason) NetconServCon * NetconServLis::accept(int timeo) { - LOGDEB(("NetconServLis::accept\n")); + LOGDEB("NetconServLis::accept\n" ); if (timeo > 0) { int ret = select1(m_fd, timeo); if (ret == 0) { - LOGDEB2(("NetconServLis::accept timed out\n")); + LOGDEB2("NetconServLis::accept timed out\n" ); m_didtimo = 1; return 0; } @@ -976,7 +951,7 @@ NetconServLis::accept(int timeo) con = new NetconServCon(newfd); if (con == 0) { - LOGERR(("NetconServLis::accept: new NetconServCon failed\n")); + LOGERR("NetconServLis::accept: new NetconServCon failed\n" ); goto out; } @@ -985,8 +960,7 @@ NetconServLis::accept(int timeo) struct hostent *hp; if ((hp = gethostbyaddr((char *) & (who.sin_addr), sizeof(struct in_addr), AF_INET)) == 0) { - LOGERR(("NetconServLis::accept: gethostbyaddr failed for addr 0x%lx\n", - who.sin_addr.s_addr)); + LOGERR("NetconServLis::accept: gethostbyaddr failed for addr 0x" << (who.sin_addr.s_addr) << "\n" ); con->setpeer(inet_ntoa(who.sin_addr)); } else { con->setpeer(hp->h_name); @@ -995,12 +969,12 @@ NetconServLis::accept(int timeo) con->setpeer(m_serv.c_str()); } - LOGDEB2(("NetconServLis::accept: setting keepalive\n")); + LOGDEB2("NetconServLis::accept: setting keepalive\n" ); if (setsockopt(newfd, SOL_SOCKET, SO_KEEPALIVE, (char *)&one, sizeof(one)) < 0) { LOGSYSERR("NetconServLis::accept", "setsockopt", "KEEPALIVE"); } - LOGDEB2(("NetconServLis::accept: got connect from %s\n", con->getpeer())); + LOGDEB2("NetconServLis::accept: got connect from " << (con->getpeer()) << "\n" ); out: if (con == 0 && newfd >= 0) { @@ -1022,12 +996,12 @@ NetconServLis::checkperms(void *cl, int) unsigned long ip_addr; if (addr->sa_family != AF_INET) { - LOGERR(("NetconServLis::checkperms: connection from non-INET addr !\n")); + LOGERR("NetconServLis::checkperms: connection from non-INET addr !\n" ); return -1; } ip_addr = ntohl(((struct sockaddr_in *)addr)->sin_addr.s_addr); - LOGDEB2(("checkperms: ip_addr: 0x%x\n", ip_addr)); + LOGDEB2("checkperms: ip_addr: 0x" << (ip_addr) << "\n" ); for (int i = 0; i < okaddrs.len; i++) { unsigned int mask; if (i < okmasks.len) { @@ -1035,14 +1009,12 @@ NetconServLis::checkperms(void *cl, int) } else { mask = okmasks.intarray[okmasks.len - 1]; } - LOGDEB2(("checkperms: trying okaddr 0x%x, mask 0x%x\n", - okaddrs.intarray[i], mask)); + LOGDEB2("checkperms: trying okaddr 0x" << (okaddrs.intarray[i]) << ", mask 0x" << (mask) << "\n" ); if ((ip_addr & mask) == (okaddrs.intarray[i] & mask)) { return (0); } } - LOGERR(("NetconServLis::checkperm: connection from bad address 0x%x\n", - ip_addr)); + LOGERR("NetconServLis::checkperm: connection from bad address 0x" << (ip_addr) << "\n" ); return -1; } #endif /* NETCON_ACCESSCONTROL */ @@ -1059,7 +1031,8 @@ NetconServLis::checkperms(void *cl, int) #include #include -#include "debuglog.h" +#include "log.h" + #include "netcon.h" using namespace std; @@ -1122,8 +1095,8 @@ int main(int argc, char **argv) argc--; argv++; } - DebugLog::setfilename("stderr"); - DebugLog::getdbl()->setloglevel(DEBDEB2); + + Logger::getTheLog("")->setLogLevel(Logger::LLDEB2); if (op_flags & OPT_c) { if (argc != 2) { @@ -1155,7 +1128,7 @@ class CliNetconWorker : public NetconWorker { public: CliNetconWorker() : m_count(0) {} int data(NetconData *con, Netcon::Event reason) { - LOGDEB(("clientdata\n")); + LOGDEB("clientdata\n" ); if (reason & Netcon::NETCONPOLL_WRITE) { sprintf(fromcli, "Bonjour Bonjour client %d, count %d", getpid(), m_count); @@ -1257,7 +1230,7 @@ class ServNetconWorker : public NetconWorker { public: ServNetconWorker() : m_count(0) {} int data(NetconData *con, Netcon::Event reason) { - LOGDEB(("serverdata\n")); + LOGDEB("serverdata\n" ); if (reason & Netcon::NETCONPOLL_WRITE) { con->setselevents(Netcon::NETCONPOLL_READ); char fromserv[200]; @@ -1360,3 +1333,4 @@ int tryserv(char *serv) } #endif /* TEST_NETCON */ + diff --git a/src/utils/rclionice.cpp b/src/utils/rclionice.cpp index 82a5ded3..baab1b88 100644 --- a/src/utils/rclionice.cpp +++ b/src/utils/rclionice.cpp @@ -21,7 +21,7 @@ #include "rclionice.h" #include "execmd.h" -#include "debuglog.h" +#include "log.h" using namespace std; @@ -30,7 +30,7 @@ bool rclionice(const string& clss, const string& cdata) string ionicexe; if (!ExecCmd::which("ionice", ionicexe)) { // ionice not found, bail out - LOGDEB0(("rclionice: ionice not found\n")); + LOGDEB0("rclionice: ionice not found\n" ); return false; } vector args; @@ -51,8 +51,9 @@ bool rclionice(const string& clss, const string& cdata) int status = cmd.doexec(ionicexe, args); if (status) { - LOGERR(("rclionice: failed, status 0x%x\n", status)); + LOGERR("rclionice: failed, status 0x" << (status) << "\n" ); return false; } return true; } + diff --git a/src/utils/strmatcher.cpp b/src/utils/strmatcher.cpp index a287c4b4..7f33704a 100644 --- a/src/utils/strmatcher.cpp +++ b/src/utils/strmatcher.cpp @@ -29,7 +29,7 @@ #include #include "cstr.h" -#include "debuglog.h" +#include "log.h" #include "pathut.h" #include "strmatcher.h" @@ -37,16 +37,13 @@ using namespace std; bool StrWildMatcher::match(const string& val) const { - LOGDEB2(("StrWildMatcher::match: [%s] against [%s]\n", - m_sexp.c_str(), val.c_str())); + LOGDEB2("StrWildMatcher::match: [" << (m_sexp) << "] against [" << (val) << "]\n" ); int ret = fnmatch(m_sexp.c_str(), val.c_str(), FNM_NOESCAPE); switch (ret) { case 0: return true; case FNM_NOMATCH: return false; default: - LOGINFO(("StrWildMatcher::match:err: e [%s] s [%s] (%s) ret %d\n", - m_sexp.c_str(), val.c_str(), - url_encode(val).c_str(), ret)); + LOGINFO("StrWildMatcher::match:err: e [" << (m_sexp) << "] s [" << (val) << "] (" << (url_encode(val)) << ") ret " << (ret) << "\n" ); return false; } } @@ -130,3 +127,4 @@ bool StrRegexpMatcher::ok() const { return !m_errcode; } + diff --git a/src/utils/transcode.cpp b/src/utils/transcode.cpp index 498e6629..3213ca1b 100644 --- a/src/utils/transcode.cpp +++ b/src/utils/transcode.cpp @@ -27,7 +27,7 @@ using std::string; #include #include "transcode.h" -#include "debuglog.h" +#include "log.h" #include "ptmutex.h" #ifdef RCL_ICONV_INBUF_CONST #define ICV_P2_TYPE const char** @@ -48,7 +48,7 @@ using std::string; bool transcode(const string &in, string &out, const string &icode, const string &ocode, int *ecnt) { - LOGDEB2(("Transcode: %s -> %s\n", icode.c_str(), ocode.c_str())); + LOGDEB2("Transcode: " << (icode) << " -> " << (ocode) << "\n" ); #ifdef ICONV_CACHE_OPEN static iconv_t ic = (iconv_t)-1; static string cachedicode; @@ -106,9 +106,8 @@ bool transcode(const string &in, string &out, const string &icode, " : " + strerror(errno); #endif if (errno == EILSEQ) { - LOGDEB1(("transcode:iconv: bad input seq.: shift, retry\n")); - LOGDEB1((" Input consumed %d output produced %d\n", - ip - in.c_str(), out.length() + OBSIZ - osiz)); + LOGDEB1("transcode:iconv: bad input seq.: shift, retry\n" ); + LOGDEB1(" Input consumed " << (ip - in) << " output produced " << (out.length() + OBSIZ - osiz) << "\n" ); out.append(obuf, OBSIZ - osiz); out += "?"; mecnt++; @@ -151,8 +150,7 @@ error: } if (mecnt) - LOGDEB(("transcode: [%s]->[%s] %d errors\n", - icode.c_str(), ocode.c_str(), mecnt)); + LOGDEB("transcode: [" << (icode) << "]->[" << (ocode) << "] " << (mecnt) << " errors\n" ); if (ecnt) *ecnt = mecnt; return ret; @@ -230,3 +228,4 @@ int main(int argc, char **argv) exit(0); } #endif + diff --git a/src/utils/trexecmd.cpp b/src/utils/trexecmd.cpp index 5f7e9d4b..94813d38 100644 --- a/src/utils/trexecmd.cpp +++ b/src/utils/trexecmd.cpp @@ -15,7 +15,7 @@ #include #include -#include "debuglog.h" +#include "log.h" #include "cancelcheck.h" #include "execmd.h" #include "smallut.h" @@ -381,3 +381,4 @@ int main(int argc, char *argv[]) return status >> 8; } } + diff --git a/src/utils/utf8iter.cpp b/src/utils/utf8iter.cpp index 1133f37c..68f5132b 100644 --- a/src/utils/utf8iter.cpp +++ b/src/utils/utf8iter.cpp @@ -22,7 +22,7 @@ #include -#include "debuglog.h" +#include "log.h" #include "transcode.h" #ifndef NO_NAMESPACES @@ -182,3 +182,4 @@ int main(int argc, char **argv) } exit(0); } + diff --git a/src/utils/wipedir.cpp b/src/utils/wipedir.cpp index 1e7103be..d5196d9e 100644 --- a/src/utils/wipedir.cpp +++ b/src/utils/wipedir.cpp @@ -29,7 +29,7 @@ #include #include -#include "debuglog.h" +#include "log.h" #include "pathut.h" #include "wipedir.h" @@ -43,22 +43,22 @@ int wipedir(const string& dir, bool selfalso, bool recurse) statret = lstat(dir.c_str(), &st); if (statret == -1) { - LOGERR(("wipedir: cant stat %s, errno %d\n", dir.c_str(), errno)); + LOGERR("wipedir: cant stat " << (dir) << ", errno " << (errno) << "\n" ); return -1; } if (!S_ISDIR(st.st_mode)) { - LOGERR(("wipedir: %s not a directory\n", dir.c_str())); + LOGERR("wipedir: " << (dir) << " not a directory\n" ); return -1; } if (access(dir.c_str(), R_OK|W_OK|X_OK) < 0) { - LOGERR(("wipedir: no write access to %s\n", dir.c_str())); + LOGERR("wipedir: no write access to " << (dir) << "\n" ); return -1; } DIR *d = opendir(dir.c_str()); if (d == 0) { - LOGERR(("wipedir: cant opendir %s, errno %d\n", dir.c_str(), errno)); + LOGERR("wipedir: cant opendir " << (dir) << ", errno " << (errno) << "\n" ); return -1; } int remaining = 0; @@ -72,7 +72,7 @@ int wipedir(const string& dir, bool selfalso, bool recurse) struct stat st; int statret = lstat(fn.c_str(), &st); if (statret == -1) { - LOGERR(("wipedir: cant stat %s, errno %d\n", fn.c_str(), errno)); + LOGERR("wipedir: cant stat " << (fn) << ", errno " << (errno) << "\n" ); goto out; } if (S_ISDIR(st.st_mode)) { @@ -87,8 +87,7 @@ int wipedir(const string& dir, bool selfalso, bool recurse) } } else { if (unlink(fn.c_str()) < 0) { - LOGERR(("wipedir: cant unlink %s, errno %d\n", - fn.c_str(), errno)); + LOGERR("wipedir: cant unlink " << (fn) << ", errno " << (errno) << "\n" ); goto out; } } @@ -97,8 +96,7 @@ int wipedir(const string& dir, bool selfalso, bool recurse) ret = remaining; if (selfalso && ret == 0) { if (rmdir(dir.c_str()) < 0) { - LOGERR(("wipedir: rmdir(%s) failed, errno %d\n", - dir.c_str(), errno)); + LOGERR("wipedir: rmdir(" << (dir) << ") failed, errno " << (errno) << "\n" ); ret = -1; } } @@ -167,3 +165,4 @@ int main(int argc, const char **argv) } #endif + diff --git a/src/utils/workqueue.h b/src/utils/workqueue.h index 9a245d8a..accb0dcc 100644 --- a/src/utils/workqueue.h +++ b/src/utils/workqueue.h @@ -24,7 +24,7 @@ #include #include -#include "debuglog.h" +#include "log.h" #include "ptmutex.h" /** @@ -60,7 +60,7 @@ public: ~WorkQueue() { - LOGDEB2(("WorkQueue::~WorkQueue:%s\n", m_name.c_str())); + LOGDEB2("WorkQueue::~WorkQueue:" << (m_name) << "\n" ); if (!m_worker_threads.empty()) setTerminateAndWait(); } @@ -80,8 +80,7 @@ public: int err; pthread_t thr; if ((err = pthread_create(&thr, 0, start_routine, arg))) { - LOGERR(("WorkQueue:%s: pthread_create failed, err %d\n", - m_name.c_str(), err)); + LOGERR("WorkQueue:" << (m_name) << ": pthread_create failed, err " << (err) << "\n" ); return false; } m_worker_threads.push_back(thr); @@ -97,8 +96,7 @@ public: { PTMutexLocker lock(m_mutex); if (!lock.ok() || !ok()) { - LOGERR(("WorkQueue::put:%s: !ok or mutex_lock failed\n", - m_name.c_str())); + LOGERR("WorkQueue::put:" << (m_name) << ": !ok or mutex_lock failed\n" ); return false; } @@ -144,8 +142,7 @@ public: { PTMutexLocker lock(m_mutex); if (!lock.ok() || !ok()) { - LOGERR(("WorkQueue::waitIdle:%s: not ok or can't lock\n", - m_name.c_str())); + LOGERR("WorkQueue::waitIdle:" << (m_name) << ": not ok or can't lock\n" ); return false; } @@ -157,8 +154,7 @@ public: if (pthread_cond_wait(&m_ccond, lock.getMutex())) { m_clients_waiting--; m_ok = false; - LOGERR(("WorkQueue::waitIdle:%s: cond_wait failed\n", - m_name.c_str())); + LOGERR("WorkQueue::waitIdle:" << (m_name) << ": cond_wait failed\n" ); return false; } m_clients_waiting--; @@ -176,7 +172,7 @@ public: void* setTerminateAndWait() { PTMutexLocker lock(m_mutex); - LOGDEB(("setTerminateAndWait:%s\n", m_name.c_str())); + LOGDEB("setTerminateAndWait:" << (m_name) << "\n" ); if (m_worker_threads.empty()) { // Already called ? @@ -189,17 +185,14 @@ public: pthread_cond_broadcast(&m_wcond); m_clients_waiting++; if (pthread_cond_wait(&m_ccond, lock.getMutex())) { - LOGERR(("WorkQueue::setTerminate:%s: cond_wait failed\n", - m_name.c_str())); + LOGERR("WorkQueue::setTerminate:" << (m_name) << ": cond_wait failed\n" ); m_clients_waiting--; return (void*)0; } m_clients_waiting--; } - LOGINFO(("%s: tasks %u nowakes %u wsleeps %u csleeps %u\n", - m_name.c_str(), m_tottasks, m_nowake, m_workersleeps, - m_clientsleeps)); + LOGINFO("" << (m_name) << ": tasks " << (m_tottasks) << " nowakes " << (m_nowake) << " wsleeps " << (m_workersleeps) << " csleeps " << (m_clientsleeps) << "\n" ); // Perform the thread joins and compute overall status // Workers return (void*)1 if ok void *statusall = (void*)1; @@ -218,7 +211,7 @@ public: m_tottasks = m_nowake = m_workersleeps = m_clientsleeps = 0; m_ok = true; - LOGDEB(("setTerminateAndWait:%s done\n", m_name.c_str())); + LOGDEB("setTerminateAndWait:" << (m_name) << " done\n" ); return statusall; } @@ -231,7 +224,7 @@ public: { PTMutexLocker lock(m_mutex); if (!lock.ok() || !ok()) { - LOGDEB(("WorkQueue::take:%s: not ok\n", m_name.c_str())); + LOGDEB("WorkQueue::take:" << (m_name) << ": not ok\n" ); return false; } @@ -243,8 +236,7 @@ public: if (pthread_cond_wait(&m_wcond, lock.getMutex()) || !ok()) { // !ok is a normal condition when shutting down if (ok()) - LOGERR(("WorkQueue::take:%s: cond_wait failed or !ok\n", - m_name.c_str())); + LOGERR("WorkQueue::take:" << (m_name) << ": cond_wait failed or !ok\n" ); m_workers_waiting--; return false; } @@ -275,7 +267,7 @@ public: */ void workerExit() { - LOGDEB(("workerExit:%s\n", m_name.c_str())); + LOGDEB("workerExit:" << (m_name) << "\n" ); PTMutexLocker lock(m_mutex); m_workers_exited++; m_ok = false; @@ -294,9 +286,7 @@ private: { bool isok = m_ok && m_workers_exited == 0 && !m_worker_threads.empty(); if (!isok) { - LOGDEB(("WorkQueue:ok:%s: not ok m_ok %d m_workers_exited %d " - "m_worker_threads size %d\n", m_name.c_str(), - m_ok, m_workers_exited, int(m_worker_threads.size()))); + LOGDEB("WorkQueue:ok:" << (m_name) << ": not ok m_ok " << (m_ok) << " m_workers_exited " << (m_workers_exited) << " m_worker_threads size " << (int(m_worker_threads.size())) << "\n" ); } return isok; } @@ -339,3 +329,4 @@ private: }; #endif /* _WORKQUEUE_H_INCLUDED_ */ + diff --git a/src/windows/execmd_w.cpp b/src/windows/execmd_w.cpp index a46fd923..8c06fbb1 100644 --- a/src/windows/execmd_w.cpp +++ b/src/windows/execmd_w.cpp @@ -25,7 +25,7 @@ #include #include UNORDERED_MAP_INCLUDE -#include "debuglog.h" +#include "log.h" #include "safesysstat.h" #include "safeunistd.h" #include "safewindows.h" @@ -41,7 +41,7 @@ using namespace std; static void printError(const string& text) { DWORD err = GetLastError(); - LOGERR(("%s : err: %d\n", text.c_str(), err)); + LOGERR(text << " : err: " << err << "\n"); } /** @@ -123,7 +123,7 @@ static char *mergeEnvironment(const STD_UNORDERED_MAP& addenv) } else if (*cp1 == 0) { value = string(cp0, cp1 - cp0); envirmap[name] = value; - LOGDEB1(("mergeEnvir: [%s] = [%s]\n", name.c_str(), value.c_str())); + LOGDEB1("mergeEnvir: [" << (name) << "] = [" << (value) << "]\n" ); cp0 = cp1 + 1; if (*cp0 == 0) break; @@ -238,16 +238,16 @@ static WaitResult Wait(HANDLE hdl, int timeout) { //HANDLE hdls[2] = { hdl, eQuit }; HANDLE hdls[1] = { hdl}; - LOGDEB1(("Wait()\n")); + LOGDEB1("Wait()\n" ); DWORD res = WaitForMultipleObjects(1, hdls, FALSE, timeout); if (res == WAIT_OBJECT_0) { - LOGDEB1(("Wait: returning Ok\n")); + LOGDEB1("Wait: returning Ok\n" ); return Ok; } else if (res == (WAIT_OBJECT_0 + 1)) { - LOGDEB0(("Wait: returning Quit\n")); + LOGDEB0("Wait: returning Quit\n" ); return Quit; } else if (res == WAIT_TIMEOUT) { - LOGDEB0(("Wait: returning Timeout\n")); + LOGDEB0("Wait: returning Timeout\n" ); return Timeout; } printError("Wait: WaitForMultipleObjects: unknown, returning Timout\n"); @@ -259,9 +259,7 @@ static int getVMMBytes(HANDLE hProcess) PROCESS_MEMORY_COUNTERS pmc; const int MB = 1024 * 1024; if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc))) { - LOGDEB2(("ExecCmd: getVMMBytes paged Kbs %d non paged %d Kbs\n", - int(pmc.QuotaPagedPoolUsage/1024), - int(pmc.QuotaNonPagedPoolUsage/1024))); + LOGDEB2("ExecCmd: getVMMBytes paged Kbs " << (int(pmc.QuotaPagedPoolUsage/1024)) << " non paged " << (int(pmc.QuotaNonPagedPoolUsage/1024)) << " Kbs\n" ); return int(pmc.QuotaPagedPoolUsage /MB + pmc.QuotaNonPagedPoolUsage / MB); } @@ -322,14 +320,14 @@ public: // send the break, and restore normal break processing static bool sendIntr(int pid) { - LOGDEB(("execmd_w: sendIntr -> %d\n", pid)); + LOGDEB("execmd_w: sendIntr -> " << (pid) << "\n" ); bool needDetach = false; if (GetConsoleWindow() == NULL) { needDetach = true; - LOGDEB(("execmd_w: sendIntr attaching console\n")); + LOGDEB("execmd_w: sendIntr attaching console\n" ); if (!AttachConsole((unsigned int) pid)) { int err = GetLastError(); - LOGERR(("execmd_w: sendIntr: AttachConsole failed: %d\n", err)); + LOGERR("execmd_w: sendIntr: AttachConsole failed: " << (err) << "\n" ); return false; } } @@ -339,8 +337,7 @@ static bool sendIntr(int pid) // Disable Ctrl-C handling for our program if (!SetConsoleCtrlHandler(NULL, true)) { int err = GetLastError(); - LOGERR(("execmd_w:sendIntr:SetCons.Ctl.Hndlr.(NULL, true) failed: %d\n", - err)); + LOGERR("execmd_w:sendIntr:SetCons.Ctl.Hndlr.(NULL, true) failed: " << (err) << "\n" ); return false; } #endif @@ -350,7 +347,7 @@ static bool sendIntr(int pid) bool ret = GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, pid); if (!ret) { int err = GetLastError(); - LOGERR(("execmd_w:sendIntr:Gen.Cons.CtrlEvent failed: %d\n", err)); + LOGERR("execmd_w:sendIntr:Gen.Cons.CtrlEvent failed: " << (err) << "\n" ); } #if 0 @@ -359,10 +356,10 @@ static bool sendIntr(int pid) #endif if (needDetach) { - LOGDEB(("execmd_w: sendIntr detaching console\n")); + LOGDEB("execmd_w: sendIntr detaching console\n" ); if (!FreeConsole()) { int err = GetLastError(); - LOGERR(("execmd_w: sendIntr: FreeConsole failed: %d\n", err)); + LOGERR("execmd_w: sendIntr: FreeConsole failed: " << (err) << "\n" ); } } @@ -383,7 +380,7 @@ public: ~ExecCmdRsrc() { if (!m_active || !m_parent) return; - LOGDEB1(("~ExecCmdRsrc: working. mypid: %d\n", (int)getpid())); + LOGDEB1("~ExecCmdRsrc: working. mypid: " << ((int)getpid()) << "\n" ); if (m_parent->m_hOutputRead) CloseHandle(m_parent->m_hOutputRead); if (m_parent->m_hInputWrite) @@ -551,8 +548,7 @@ bool ExecCmd::Internal::tooBig() return false; int mbytes = getVMMBytes(m_piProcInfo.hProcess); if (mbytes > m_rlimit_as_mbytes) { - LOGINFO(("ExecCmd:: process mbytes %d > set limit %d\n", - mbytes, m_rlimit_as_mbytes)); + LOGINFO("ExecCmd:: process mbytes " << (mbytes) << " > set limit " << (m_rlimit_as_mbytes) << "\n" ); m_killRequest = true; return true; } @@ -573,14 +569,14 @@ bool ExecCmd::Internal::preparePipes(bool has_input,HANDLE *hChildInput, // manual reset event m_oOutputRead.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if (m_oOutputRead.hEvent == INVALID_HANDLE_VALUE) { - LOGERR(("ExecCmd::preparePipes: CreateEvent failed\n")); + LOGERR("ExecCmd::preparePipes: CreateEvent failed\n" ); goto errout; } // manual reset event m_oInputWrite.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if (m_oInputWrite.hEvent == INVALID_HANDLE_VALUE) { - LOGERR(("ExecCmd::preparePipes: CreateEvent failed\n")); + LOGERR("ExecCmd::preparePipes: CreateEvent failed\n" ); goto errout; } @@ -734,8 +730,7 @@ int ExecCmd::startExec(const string &cmd, const vector& args, it != args.end(); it++) { command += "{" + *it + "} "; } - LOGDEB(("ExecCmd::startExec: (%d|%d) %s\n", - has_input, has_output, command.c_str())); + LOGDEB("ExecCmd::startExec: (" << (has_input) << "|" << (has_output) << ") " << (command) << "\n" ); } // What if we're called twice ? First make sure we're clean @@ -753,7 +748,7 @@ int ExecCmd::startExec(const string &cmd, const vector& args, HANDLE hErrorWrite; if (!m->preparePipes(has_input, &hInputRead, has_output, &hOutputWrite, &hErrorWrite)) { - LOGERR(("ExecCmd::startExec: preparePipes failed\n")); + LOGERR("ExecCmd::startExec: preparePipes failed\n" ); return false; } @@ -783,7 +778,7 @@ int ExecCmd::startExec(const string &cmd, const vector& args, // Create the child process. // Need a writable buffer for the command line, for some reason. - LOGDEB1(("ExecCmd:startExec: cmdline [%s]\n", cmdline.c_str())); + LOGDEB1("ExecCmd:startExec: cmdline [" << (cmdline) << "]\n" ); LPSTR buf = (LPSTR)malloc(cmdline.size() + 1); memcpy(buf, cmdline.c_str(), cmdline.size()); buf[cmdline.size()] = 0; @@ -819,7 +814,7 @@ int ExecCmd::startExec(const string &cmd, const vector& args, // Send data to the child. int ExecCmd::send(const string& data) { - LOGDEB2(("ExecCmd::send: cnt %d\n", int(data.size()))); + LOGDEB2("ExecCmd::send: cnt " << (int(data.size())) << "\n" ); BOOL bSuccess = WriteFile(m->m_hInputWrite, data.c_str(), (DWORD)data.size(), NULL, &m->m_oInputWrite); DWORD err = GetLastError(); @@ -829,7 +824,7 @@ int ExecCmd::send(const string& data) // and ERROR_IO_PENDING // in the first case bytes read/written parameter can be used directly if (!bSuccess && err != ERROR_IO_PENDING) { - LOGERR(("ExecCmd::send: WriteFile: got err %d\n", err)); + LOGERR("ExecCmd::send: WriteFile: got err " << (err) << "\n" ); return -1; } @@ -839,7 +834,7 @@ int ExecCmd::send(const string& data) if (!GetOverlappedResult(m->m_hInputWrite, &m->m_oInputWrite, &dwWritten, TRUE)) { err = GetLastError(); - LOGERR(("ExecCmd::send: GetOverLappedResult: err %d\n", err)); + LOGERR("ExecCmd::send: GetOverLappedResult: err " << (err) << "\n" ); return -1; } } else if (waitRes == Quit) { @@ -855,7 +850,7 @@ int ExecCmd::send(const string& data) } return -1; } - LOGDEB2(("ExecCmd::send: returning %d\n", int(dwWritten))); + LOGDEB2("ExecCmd::send: returning " << (int(dwWritten)) << "\n" ); return dwWritten; } @@ -870,7 +865,7 @@ int ExecCmd::send(const string& data) // 0 means read whatever comes back on the first read; int ExecCmd::receive(string& data, int cnt) { - LOGDEB1(("ExecCmd::receive: cnt %d\n", cnt)); + LOGDEB1("ExecCmd::receive: cnt " << (cnt) << "\n" ); int totread = 0; @@ -892,11 +887,10 @@ int ExecCmd::receive(string& data, int cnt) BOOL bSuccess = ReadFile(m->m_hOutputRead, chBuf, toread, NULL, &m->m_oOutputRead); DWORD err = GetLastError(); - LOGDEB1(("receive: ReadFile: success %d err %d\n", - int(bSuccess), int(err))); + LOGDEB1("receive: ReadFile: success " << (int(bSuccess)) << " err " << (int(err)) << "\n" ); if (!bSuccess && err != ERROR_IO_PENDING) { if (err != ERROR_BROKEN_PIPE) - LOGERR(("ExecCmd::receive: ReadFile error: %d\n", int(err))); + LOGERR("ExecCmd::receive: ReadFile error: " << (int(err)) << "\n" ); break; } @@ -908,8 +902,7 @@ int ExecCmd::receive(string& data, int cnt) &dwRead, TRUE)) { err = GetLastError(); if (err && err != ERROR_BROKEN_PIPE) { - LOGERR(("ExecCmd::recv:GetOverlappedResult: err %d\n", - err)); + LOGERR("ExecCmd::recv:GetOverlappedResult: err " << (err) << "\n" ); return -1; } } @@ -918,7 +911,7 @@ int ExecCmd::receive(string& data, int cnt) data.append(chBuf, dwRead); if (m->m_advise) m->m_advise->newData(dwRead); - LOGDEB1(("ExecCmd::recv: ReadFile: %d bytes\n", int(dwRead))); + LOGDEB1("ExecCmd::recv: ReadFile: " << (int(dwRead)) << " bytes\n" ); } } else if (waitRes == Quit) { if (!CancelIo(m->m_hOutputRead)) { @@ -926,7 +919,7 @@ int ExecCmd::receive(string& data, int cnt) } break; } else if (waitRes == Timeout) { - LOGDEB0(("ExecCmd::receive: timeout (%d mS)\n", m->m_timeoutMs)); + LOGDEB0("ExecCmd::receive: timeout (" << (m->m_timeoutMs) << " mS)\n" ); if (m->tooBig()) { if (!CancelIo(m->m_hOutputRead)) { printError("CancelIo"); @@ -945,7 +938,7 @@ int ExecCmd::receive(string& data, int cnt) } } if (m->m_killRequest) { - LOGINFO(("ExecCmd::doexec: cancel request\n")); + LOGINFO("ExecCmd::doexec: cancel request\n" ); if (!CancelIo(m->m_hOutputRead)) { printError("CancelIo"); } @@ -956,13 +949,13 @@ int ExecCmd::receive(string& data, int cnt) if ((cnt == 0 && totread > 0) || (cnt > 0 && totread == cnt)) break; } - LOGDEB1(("ExecCmd::receive: returning %d bytes\n", totread)); + LOGDEB1("ExecCmd::receive: returning " << (totread) << " bytes\n" ); return totread; } int ExecCmd::getline(string& data) { - LOGDEB2(("ExecCmd::getline: cnt %d, timeo %d\n", cnt, timeo)); + LOGDEB2("ExecCmd::getline: cnt " << (cnt) << ", timeo " << (timeo) << "\n" ); data.erase(); if (m->m_buf.empty()) { m->m_buf.reserve(4096); @@ -987,7 +980,7 @@ int ExecCmd::getline(string& data) } if (foundnl) { - LOGDEB2(("ExecCmd::getline: ret: [%s]\n", data.c_str())); + LOGDEB2("ExecCmd::getline: ret: [" << (data) << "]\n" ); return int(data.size()); } @@ -997,7 +990,7 @@ int ExecCmd::getline(string& data) return -1; } if (m->m_buf.empty()) { - LOGDEB(("ExecCmd::getline: eof? ret: [%s]\n", data.c_str())); + LOGDEB("ExecCmd::getline: eof? ret: [" << (data) << "]\n" ); return int(data.size()); } m->m_bufoffs = 0; @@ -1017,7 +1010,7 @@ int ExecCmd::wait() // Wait until child process exits. while (WaitForSingleObject(m->m_piProcInfo.hProcess, m->m_timeoutMs) == WAIT_TIMEOUT) { - LOGDEB(("ExecCmd::wait: timeout (ok)\n")); + LOGDEB("ExecCmd::wait: timeout (ok)\n" ); if (m->m_advise) { m->m_advise->newData(0); } @@ -1087,7 +1080,7 @@ int ExecCmd::doexec(const string &cmd, const vector& args, const string *input, string *output) { if (input && output) { - LOGERR(("ExecCmd::doexec: can't do both input and output\n")); + LOGERR("ExecCmd::doexec: can't do both input and output\n" ); return -1; } @@ -1103,7 +1096,7 @@ int ExecCmd::doexec(const string &cmd, const vector& args, if (input) { if (!input->empty()) { if (send(*input) != (int)input->size()) { - LOGERR(("ExecCmd::doexec: send failed\n")); + LOGERR("ExecCmd::doexec: send failed\n" ); CloseHandle(m->m_hInputWrite); m->m_hInputWrite = NULL; return -1; @@ -1118,7 +1111,7 @@ int ExecCmd::doexec(const string &cmd, const vector& args, break; } if (send(*input) != (int)input->size()) { - LOGERR(("ExecCmd::doexec: send failed\n")); + LOGERR("ExecCmd::doexec: send failed\n" ); CloseHandle(m->m_hInputWrite); m->m_hInputWrite = NULL; break; @@ -1131,3 +1124,4 @@ int ExecCmd::doexec(const string &cmd, const vector& args, cleaner.inactivate(); return wait(); } +