diff options
author | Nikola Pajkovsky <npajkovs@redhat.com> | 2010-06-07 13:37:28 +0200 |
---|---|---|
committer | Nikola Pajkovsky <npajkovs@redhat.com> | 2010-08-17 15:19:04 +0200 |
commit | 7216534ab452158ce39f8044118f28a61970528b (patch) | |
tree | 25bfd92c4ce1c54d4506b8d020f7c58bfb82fa94 | |
parent | a1c6a692e955ff977616096bae3cb2ffa7a8b831 (diff) | |
download | abrt-7216534ab452158ce39f8044118f28a61970528b.tar.gz abrt-7216534ab452158ce39f8044118f28a61970528b.tar.xz abrt-7216534ab452158ce39f8044118f28a61970528b.zip |
get rid of std::string from logger
Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
-rw-r--r-- | lib/plugins/Logger.cpp | 40 | ||||
-rw-r--r-- | lib/plugins/Logger.h | 8 |
2 files changed, 21 insertions, 27 deletions
diff --git a/lib/plugins/Logger.cpp b/lib/plugins/Logger.cpp index a02845fe..0c4aad61 100644 --- a/lib/plugins/Logger.cpp +++ b/lib/plugins/Logger.cpp @@ -24,10 +24,16 @@ #include "comm_layer_inner.h" #include "abrt_exception.h" -CLogger::CLogger() : - m_sLogPath("/var/log/abrt.log"), - m_bAppendLogs(true) -{} +CLogger::CLogger() +{ + m_log_path = xstrdup("/var/log/abrt.log"); + m_append_logs = true; +} + +CLogger::~CLogger() +{ + free(m_log_path); +} void CLogger::SetSettings(const map_plugin_settings_t& pSettings) { @@ -38,24 +44,14 @@ void CLogger::SetSettings(const map_plugin_settings_t& pSettings) it = pSettings.find("LogPath"); if (it != end) { - m_sLogPath = it->second; + free(m_log_path); + m_log_path = xstrdup(it->second.c_str()); } it = pSettings.find("AppendLogs"); if (it != end) - { - m_bAppendLogs = string_to_bool(it->second.c_str()); - } + m_append_logs = string_to_bool(it->second.c_str()); } -//ok to delete? -//const map_plugin_settings_t& CLogger::GetSettings() -//{ -// m_pSettings["LogPath"] = m_sLogPath; -// m_pSettings["AppendLogs"] = m_bAppendLogs ? "yes" : "no"; -// -// return m_pSettings; -//} - std::string CLogger::Report(const map_crash_data_t& pCrashData, const map_plugin_settings_t& pSettings, const char *pArgs) @@ -65,10 +61,8 @@ std::string CLogger::Report(const map_crash_data_t& pCrashData, free(dsc); /* open, not fopen - want to set mode if we create the file, not just open */ - const char *fname = m_sLogPath.c_str(); - int fd = open(fname, - m_bAppendLogs ? O_WRONLY|O_CREAT|O_APPEND : O_WRONLY|O_CREAT|O_TRUNC, - 0600); + const char *fname = m_log_path; + int fd = open(fname, m_append_logs ? O_WRONLY|O_CREAT|O_APPEND : O_WRONLY|O_CREAT|O_TRUNC, 0600); if (fd < 0) throw CABRTException(EXCEP_PLUGIN, "Can't open '%s'", fname); @@ -78,8 +72,8 @@ std::string CLogger::Report(const map_crash_data_t& pCrashData, close(fd); - const char *format = m_bAppendLogs ? _("The report was appended to %s") : _("The report was stored to %s"); - return ssprintf(format, m_sLogPath.c_str()); + const char *format = m_append_logs ? _("The report was appended to %s") : _("The report was stored to %s"); + return ssprintf(format, m_log_path); } PLUGIN_INFO(REPORTER, diff --git a/lib/plugins/Logger.h b/lib/plugins/Logger.h index aa7def32..d2b80075 100644 --- a/lib/plugins/Logger.h +++ b/lib/plugins/Logger.h @@ -28,14 +28,14 @@ class CLogger : public CReporter { private: - std::string m_sLogPath; - bool m_bAppendLogs; + char *m_log_path; + bool m_append_logs; public: CLogger(); + ~CLogger(); virtual void SetSettings(const map_plugin_settings_t& pSettings); -//ok to delete? -// virtual const map_plugin_settings_t& GetSettings(); + virtual std::string Report(const map_crash_data_t& pCrashData, const map_plugin_settings_t& pSettings, const char *pArgs); |