diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-30 19:03:17 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-30 19:03:17 +0100 |
commit | b4e0ad1ef24fd49bcd5cdd1b6f1dd69768036e07 (patch) | |
tree | 39d7ce4ab5193fc31e3420ed5c52c9b42b4ddc22 /lib/Plugins/Logger.cpp | |
parent | 70e0330d6919b3e7e372e5cdd04282a51fe64788 (diff) | |
download | abrt-b4e0ad1ef24fd49bcd5cdd1b6f1dd69768036e07.tar.gz abrt-b4e0ad1ef24fd49bcd5cdd1b6f1dd69768036e07.tar.xz abrt-b4e0ad1ef24fd49bcd5cdd1b6f1dd69768036e07.zip |
move logger's report text creation to lib/Utils/make_descr.cpp
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib/Plugins/Logger.cpp')
-rw-r--r-- | lib/Plugins/Logger.cpp | 79 |
1 files changed, 10 insertions, 69 deletions
diff --git a/lib/Plugins/Logger.cpp b/lib/Plugins/Logger.cpp index ff7bbb8f..69453d40 100644 --- a/lib/Plugins/Logger.cpp +++ b/lib/Plugins/Logger.cpp @@ -57,85 +57,26 @@ std::string CLogger::Report(const map_crash_report_t& pCrashReport, const std::s { update_client(_("Creating a report...")); - std::stringstream binaryFiles, commonFiles, bigTextFiles, additionalFiles, UUIDFile; - std::ofstream fOut; - - map_crash_report_t::const_iterator it; - for (it = pCrashReport.begin(); it != pCrashReport.end(); it++) - { - if (it->second[CD_TYPE] == CD_TXT) - { - if (it->first != CD_UUID && - it->first != FILENAME_ARCHITECTURE && - it->first != FILENAME_KERNEL && - it->first != FILENAME_PACKAGE) - { - additionalFiles << it->first << std::endl; - additionalFiles << "-----" << std::endl; - additionalFiles << it->second[CD_CONTENT] << std::endl << std::endl; - } - else if (it->first == CD_UUID) - { - UUIDFile << it->first << std::endl; - UUIDFile << "-----" << std::endl; - UUIDFile << it->second[CD_CONTENT] << std::endl << std::endl; - } - else - { - commonFiles << it->first << std::endl; - commonFiles << "-----" << std::endl; - commonFiles << it->second[CD_CONTENT] << std::endl << std::endl; - } - } - if (it->second[CD_TYPE] == CD_ATT) - { - bigTextFiles << it->first << std::endl; - bigTextFiles << "-----" << std::endl; - bigTextFiles << it->second[CD_CONTENT] << std::endl << std::endl; - } - if (it->second[CD_TYPE] == CD_BIN) - { - binaryFiles << it->first << std::endl; - binaryFiles << "-----" << std::endl; - binaryFiles << it->second[CD_CONTENT] << std::endl << std::endl; - } - } - + std::string description = make_description_logger(pCrashReport); + FILE *fOut; if (m_bAppendLogs) { - fOut.open(m_sLogPath.c_str(), std::ios::app); + fOut = fopen(m_sLogPath.c_str(), "a"); } else { - fOut.open(m_sLogPath.c_str()); + fOut = fopen(m_sLogPath.c_str(), "w"); } - if (fOut.is_open()) - { - fOut << "Duplicity check" << std::endl; - fOut << "======" << std::endl << std::endl; - fOut << UUIDFile.str() << std::endl; - fOut << "Common information" << std::endl; - fOut << "======" << std::endl << std::endl; - fOut << commonFiles.str() << std::endl; - fOut << "Additional information" << std::endl; - fOut << "======" << std::endl << std::endl; - fOut << additionalFiles.str() << std::endl; - fOut << "Big Text Files" << std::endl; - fOut << "======" << std::endl; - fOut << bigTextFiles.str() << std::endl; - fOut << "Binary files" << std::endl; - fOut << "======" << std::endl; - fOut << binaryFiles.str() << std::endl; - fOut << std::endl; - fOut.close(); - } - else + if (fOut) { - throw CABRTException(EXCEP_PLUGIN, "CLogger::Report(): Cannot open file: " + m_sLogPath); + fputs(description.c_str(), fOut); + fclose(fOut); + return "file://" + m_sLogPath; } - return "file://" + m_sLogPath; + + throw CABRTException(EXCEP_PLUGIN, "CLogger::Report(): Cannot open file: " + m_sLogPath); } PLUGIN_INFO(REPORTER, |