summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorZdenek Prikryl <zprikryl@redhat.com>2009-02-18 10:13:26 +0100
committerZdenek Prikryl <zprikryl@redhat.com>2009-02-18 10:13:26 +0100
commitf111c8cf17cbdef8a7f044324ffd510cbcc7ab6f (patch)
treead1fccbb5d741a0efcfd334bf5a9c74aae4efbbb /lib
parent3c988f99dd2d0898c78feb042e14dda5a6525de5 (diff)
downloadabrt-f111c8cf17cbdef8a7f044324ffd510cbcc7ab6f.tar.gz
abrt-f111c8cf17cbdef8a7f044324ffd510cbcc7ab6f.tar.xz
abrt-f111c8cf17cbdef8a7f044324ffd510cbcc7ab6f.zip
new logger plugin
Diffstat (limited to 'lib')
-rw-r--r--lib/Plugins/Logger.conf5
-rw-r--r--lib/Plugins/Logger.cpp80
-rw-r--r--lib/Plugins/Logger.h33
3 files changed, 118 insertions, 0 deletions
diff --git a/lib/Plugins/Logger.conf b/lib/Plugins/Logger.conf
new file mode 100644
index 00000000..8cd09503
--- /dev/null
+++ b/lib/Plugins/Logger.conf
@@ -0,0 +1,5 @@
+# Configuration for Logger plugin
+
+Log_Path = /tmp/CCLogger
+
+Append_Logs = yes \ No newline at end of file
diff --git a/lib/Plugins/Logger.cpp b/lib/Plugins/Logger.cpp
new file mode 100644
index 00000000..0af8f078
--- /dev/null
+++ b/lib/Plugins/Logger.cpp
@@ -0,0 +1,80 @@
+#include "Logger.h"
+#include <fstream>
+
+CLogger::CLogger() :
+ m_sLogPath("/tmp/CCLogger"),
+ m_bAppendLogs(true)
+{}
+
+void CLogger::SetSettings(const map_settings_t& pSettings)
+{
+ if (pSettings.find("Log_Path")!= pSettings.end())
+ {
+ m_sLogPath = pSettings.find("Log_Path")->second;
+ }
+ if (pSettings.find("Append_Logs")!= pSettings.end())
+ {
+ m_bAppendLogs = pSettings.find("Append_Logs")->second == "yes";
+ }
+}
+
+void CLogger::Report(const crash_report_t& pReport)
+{
+ std::ofstream fOut;
+ if (m_bAppendLogs)
+ {
+ fOut.open(m_sLogPath.c_str(), std::ios::app);
+ }
+ else
+ {
+ fOut.open(m_sLogPath.c_str());
+ }
+ if (fOut.is_open())
+ {
+ fOut << "Common information" << std::endl;
+ fOut << "==================" << std::endl << std::endl;
+ fOut << "Architecture" << std::endl;
+ fOut << "------------" << std::endl;
+ fOut << pReport.m_sArchitecture << std::endl << std::endl;
+ fOut << "Kernel version" << std::endl;
+ fOut << "--------------" << std::endl;
+ fOut << pReport.m_sKernel << std::endl << std::endl;
+ fOut << "Package" << std::endl;
+ fOut << "-------" << std::endl;
+ fOut << pReport.m_sPackage << std::endl << std::endl;
+ fOut << "Executable" << std::endl;
+ fOut << "----------" << std::endl;
+ fOut << pReport.m_sExecutable << std::endl << std::endl;
+ fOut << "CmdLine" << std::endl;
+ fOut << "----------" << std::endl;
+ fOut << pReport.m_sCmdLine << std::endl << std::endl;
+ fOut << "Created report" << std::endl;
+ fOut << "==============" << std::endl;
+ fOut << "Text reports" << std::endl;
+ fOut << "==============" << std::endl;
+ if (pReport.m_sTextData1 != "")
+ {
+ fOut << "Text Data 1" << std::endl;
+ fOut << "-----------" << std::endl;
+ fOut << pReport.m_sTextData1 << std::endl << std::endl;
+ }
+ if (pReport.m_sTextData2 != "")
+ {
+ fOut << "Text Data 2" << std::endl;
+ fOut << "-----------" << std::endl;
+ fOut << pReport.m_sTextData2 << std::endl << std::endl;
+ }
+ fOut << "Binary reports" << std::endl;
+ fOut << "==============" << std::endl;
+ if (pReport.m_sBinaryData1 != "")
+ {
+ fOut << "1. " << pReport.m_sBinaryData1 << std::endl;
+ }
+ if (pReport.m_sBinaryData2 != "")
+ {
+ fOut << "2. " << pReport.m_sBinaryData2 << std::endl;
+ }
+ fOut << std::endl;
+ fOut.close();
+ }
+}
diff --git a/lib/Plugins/Logger.h b/lib/Plugins/Logger.h
new file mode 100644
index 00000000..509d2ab2
--- /dev/null
+++ b/lib/Plugins/Logger.h
@@ -0,0 +1,33 @@
+#ifndef LOGGER_H_
+#define LOGGER_H_
+
+#include "Plugin.h"
+#include "Reporter.h"
+
+class CLogger : public CReporter
+{
+ private:
+ std::string m_sLogPath;
+ bool m_bAppendLogs;
+ public:
+ CLogger();
+ virtual ~CLogger() {}
+
+ void Init() {}
+ void DeInit() {}
+ void SetSettings(const map_settings_t& pSettings);
+
+ void Report(const crash_report_t& pReport);
+};
+
+
+PLUGIN_INFO(REPORTER,
+ "Logger",
+ "0.0.1",
+ "Write a report to a specific file",
+ "zprikryl@redhat.com",
+ "https://fedorahosted.org/crash-catcher/wiki");
+
+PLUGIN_INIT(CLogger);
+
+#endif /* LOGGER_H_ */