log formats

This commit is contained in:
Jean-Francois Dockes 2017-01-28 10:00:07 +01:00
parent 4487ef723a
commit 217eb388e2

View File

@ -90,7 +90,7 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data)
return false; return false;
} }
LOGDEB1("MHEM:rde: line [" << (ibuf) << "]\n" ); LOGDEB1("MHEM:rde: line [" << ibuf << "]\n");
// Empty line (end of message) ? // Empty line (end of message) ?
if (!ibuf.compare("\n")) { if (!ibuf.compare("\n")) {
@ -112,7 +112,7 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data)
vector<string> tokens; vector<string> tokens;
stringToTokens(ibuf, tokens); stringToTokens(ibuf, tokens);
if (tokens.size() != 2) { if (tokens.size() != 2) {
LOGERR("MHExecMultiple: bad line in filter output: [" << (ibuf) << "]\n" ); LOGERR("MHExecMultiple: bad line in filter output: [" << ibuf << "]\n");
return false; return false;
} }
vector<string>::iterator it = tokens.begin(); vector<string>::iterator it = tokens.begin();
@ -120,7 +120,7 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data)
string& slen = *it; string& slen = *it;
int len; int len;
if (sscanf(slen.c_str(), "%d", &len) != 1) { if (sscanf(slen.c_str(), "%d", &len) != 1) {
LOGERR("MHExecMultiple: bad line in filter output: [" << (ibuf) << "]\n" ); LOGERR("MHExecMultiple: bad line in filter output: [" << ibuf << "]\n");
return false; return false;
} }
@ -142,7 +142,8 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data)
// Read element data // Read element data
datap->erase(); datap->erase();
if (len > 0 && m_cmd.receive(*datap, len) != len) { if (len > 0 && m_cmd.receive(*datap, len) != len) {
LOGERR("MHExecMultiple: expected " << (len) << " bytes of data, got " << (datap->length()) << "\n" ); LOGERR("MHExecMultiple: expected " << len << " bytes of data, got " <<
datap->length() << "\n");
return false; return false;
} }
LOGDEB1("MHExecMe:rdDtElt got: name [" << name << "] len " << len << LOGDEB1("MHExecMe:rdDtElt got: name [" << name << "] len " << len <<
@ -153,7 +154,7 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data)
bool MimeHandlerExecMultiple::next_document() bool MimeHandlerExecMultiple::next_document()
{ {
LOGDEB("MimeHandlerExecMultiple::next_document(): [" << (m_fn) << "]\n" ); LOGDEB("MimeHandlerExecMultiple::next_document(): [" << m_fn << "]\n");
if (m_havedoc == false) if (m_havedoc == false)
return false; return false;
@ -173,7 +174,7 @@ bool MimeHandlerExecMultiple::next_document()
// empty file name in the latter case. // empty file name in the latter case.
// We also compute the file md5 before starting the extraction: // We also compute the file md5 before starting the extraction:
// under Windows, we may not be able to do it while the file // under Windows, we may not be able to do it while the file
// is opened by the filter // is opened by the filter.
ostringstream obuf; ostringstream obuf;
string file_md5; string file_md5;
if (m_filefirst) { if (m_filefirst) {
@ -182,7 +183,8 @@ bool MimeHandlerExecMultiple::next_document()
if (MD5File(m_fn, md5, &reason)) { if (MD5File(m_fn, md5, &reason)) {
file_md5 = MD5HexPrint(md5, xmd5); file_md5 = MD5HexPrint(md5, xmd5);
} else { } else {
LOGERR("MimeHandlerExecM: cant compute md5 for [" << (m_fn) << "]: " << (reason) << "\n" ); LOGERR("MimeHandlerExecM: cant compute md5 for [" << m_fn <<
"]: " << reason << "\n");
} }
} }
obuf << "FileName: " << m_fn.length() << "\n" << m_fn; obuf << "FileName: " << m_fn.length() << "\n" << m_fn;
@ -192,7 +194,8 @@ bool MimeHandlerExecMultiple::next_document()
obuf << "Filename: " << 0 << "\n"; obuf << "Filename: " << 0 << "\n";
} }
if (!m_ipath.empty()) { if (!m_ipath.empty()) {
LOGDEB("next_doc: sending len " << (m_ipath.length()) << " val [" << (m_ipath) << "]\n" ); LOGDEB("next_doc: sending ipath " << m_ipath.length() << " val [" <<
m_ipath << "]\n");
obuf << "Ipath: " << m_ipath.length() << "\n" << m_ipath; obuf << "Ipath: " << m_ipath.length() << "\n" << m_ipath;
} }
if (!m_dfltInputCharset.empty()) { if (!m_dfltInputCharset.empty()) {
@ -250,17 +253,17 @@ bool MimeHandlerExecMultiple::next_document()
subdocerror_received = true; subdocerror_received = true;
} else if (!stringlowercmp("ipath:", name)) { } else if (!stringlowercmp("ipath:", name)) {
ipath = data; ipath = data;
LOGDEB("MHExecMultiple: got ipath [" << (data) << "]\n" ); LOGDEB("MHExecMultiple: got ipath [" << data << "]\n");
} else if (!stringlowercmp("charset:", name)) { } else if (!stringlowercmp("charset:", name)) {
charset = data; charset = data;
LOGDEB("MHExecMultiple: got charset [" << (data) << "]\n" ); LOGDEB("MHExecMultiple: got charset [" << data << "]\n");
} else if (!stringlowercmp("mimetype:", name)) { } else if (!stringlowercmp("mimetype:", name)) {
mtype = data; mtype = data;
LOGDEB("MHExecMultiple: got mimetype [" << (data) << "]\n" ); LOGDEB("MHExecMultiple: got mimetype [" << data << "]\n");
} else { } else {
string nm = stringtolower((const string&)name); string nm = stringtolower((const string&)name);
trimstring(nm, ":"); trimstring(nm, ":");
LOGDEB("MHExecMultiple: got [" << (nm) << "] -> [" << (data) << "]\n" ); LOGDEB("MHExecMultiple: got [" << nm << "] -> [" << data << "]\n");
m_metaData[nm] += data; m_metaData[nm] += data;
} }
if (loop == 20) { if (loop == 20) {
@ -283,7 +286,8 @@ bool MimeHandlerExecMultiple::next_document()
// this was wrong. Empty documents can be found ie in zip files and should // this was wrong. Empty documents can be found ie in zip files and should
// not be interpreted as eof. // not be interpreted as eof.
if (m_metaData[cstr_dj_keycontent].empty()) { if (m_metaData[cstr_dj_keycontent].empty()) {
LOGDEB0("MHExecMultiple: got empty document inside [" << (m_fn) << "]: [" << (ipath) << "]\n" ); LOGDEB0("MHExecMultiple: got empty document inside [" << m_fn <<
"]: [" << ipath << "]\n");
} }
if (!ipath.empty()) { if (!ipath.empty()) {
@ -293,7 +297,8 @@ bool MimeHandlerExecMultiple::next_document()
// string which we can use to compute a mime type // string which we can use to compute a mime type
m_metaData[cstr_dj_keyipath] = ipath; m_metaData[cstr_dj_keyipath] = ipath;
if (mtype.empty()) { if (mtype.empty()) {
LOGDEB0("MHExecMultiple: no mime type from filter, 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); mtype = mimetype(ipath, 0, m_config, false);
if (mtype.empty()) { if (mtype.empty()) {
// mimetype() won't call idFile when there is no file. Do it // mimetype() won't call idFile when there is no file. Do it
@ -327,7 +332,10 @@ bool MimeHandlerExecMultiple::next_document()
if (eofnext_received) if (eofnext_received)
m_havedoc = false; m_havedoc = false;
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" ); 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; return true;
} }