From ab5ee6c07719d6bb6a3d387f88f96ab783d8b8c7 Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Mon, 7 Jun 2010 13:37:26 +0200 Subject: get rid of std::string from bugzilla Signed-off-by: Nikola Pajkovsky --- lib/plugins/Logger.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/plugins/Logger.cpp') diff --git a/lib/plugins/Logger.cpp b/lib/plugins/Logger.cpp index ece450d4..a02845fe 100644 --- a/lib/plugins/Logger.cpp +++ b/lib/plugins/Logger.cpp @@ -60,7 +60,9 @@ std::string CLogger::Report(const map_crash_data_t& pCrashData, const map_plugin_settings_t& pSettings, const char *pArgs) { - std::string description = make_description_logger(pCrashData); + char *dsc = make_description_logger(pCrashData); + char *full_dsc = xasprintf("%s\n\n\n", dsc); + free(dsc); /* open, not fopen - want to set mode if we create the file, not just open */ const char *fname = m_sLogPath.c_str(); @@ -71,9 +73,9 @@ std::string CLogger::Report(const map_crash_data_t& pCrashData, throw CABRTException(EXCEP_PLUGIN, "Can't open '%s'", fname); update_client(_("Writing report to '%s'"), fname); - description += "\n\n\n"; - const char *desc = description.c_str(); - full_write(fd, desc, strlen(desc)); + full_write(fd, full_dsc, strlen(full_dsc)); + free(full_dsc); + close(fd); const char *format = m_bAppendLogs ? _("The report was appended to %s") : _("The report was stored to %s"); -- cgit From 7216534ab452158ce39f8044118f28a61970528b Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Mon, 7 Jun 2010 13:37:28 +0200 Subject: get rid of std::string from logger Signed-off-by: Nikola Pajkovsky --- lib/plugins/Logger.cpp | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) (limited to 'lib/plugins/Logger.cpp') 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, -- cgit