--- 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 @@
{
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 @@
// Get top directories from config
vector<string> 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 @@
} 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 @@
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 @@
// 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 @@
terminate:
queue->setTerminate();
- LOGINFO(("rclMonRcvRun: monrcv thread routine returning\n"));
+ LOGINFO("rclMonRcvRun: monrcv thread routine returning\n" );
return 0;
}
@@ -353,7 +339,7 @@
: 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 @@
// 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 @@
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 @@
}
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 @@
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 @@
// 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 @@
: 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 @@
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 @@
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 @@
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 @@
map<int,string>::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 @@
}
} 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 @@
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
+