--- 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 @@
~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 @@
void put_offsets(RclConfig *config, const string& udi, mbhoff_type fsize,
vector<mbhoff_type>& offs)
{
- LOGDEB0(("MboxCache::put_offsets: %u offsets\n", offs.size()));
+ LOGDEB0("MboxCache::put_offsets: " << (offs.size()) << " offsets\n" );
if (!ok(config) || !maybemakedir())
return;
if (fsize < m_minfsize)
@@ -157,7 +153,7 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
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 @@
// 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 @@
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 @@
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 @@
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 @@
(!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 @@
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 @@
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 @@
((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 @@
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 @@
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 @@
#endif // TEST_MH_MBOX
+