diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-26 16:22:26 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-26 16:22:26 +0200 |
commit | fca6fa371006186d12a720cd48c270789c67d2e6 (patch) | |
tree | bb17aaf2e00132d41263aac0fee6481d754800dd | |
parent | 556a4b3df4f116965e8dc46c08ac5e720834022e (diff) | |
download | abrt-fca6fa371006186d12a720cd48c270789c67d2e6.tar.gz abrt-fca6fa371006186d12a720cd48c270789c67d2e6.tar.xz abrt-fca6fa371006186d12a720cd48c270789c67d2e6.zip |
replace comm_layer_inner_debug() with log() everywhere
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | inc/abrtlib.h | 8 | ||||
-rw-r--r-- | lib/CommLayer/CommLayerInner.cpp | 7 | ||||
-rw-r--r-- | lib/CommLayer/CommLayerInner.h | 9 | ||||
-rw-r--r-- | lib/Utils/DebugDump.cpp | 26 | ||||
-rw-r--r-- | src/Daemon/CommLayerServer.h | 2 | ||||
-rw-r--r-- | src/Daemon/PluginManager.cpp | 5 |
6 files changed, 24 insertions, 33 deletions
diff --git a/inc/abrtlib.h b/inc/abrtlib.h index 1cac10c0..4f0244e8 100644 --- a/inc/abrtlib.h +++ b/inc/abrtlib.h @@ -72,7 +72,13 @@ extern void simple_perror_msg_and_die(const char *s) NORETURN; extern void perror_nomsg_and_die(void) NORETURN; extern void perror_nomsg(void); extern void verror_msg(const char *s, va_list p, const char *strerr); -/* This is a macro since it collides with log() from math.h */ +/* error_msg() and log() do the same thing: + * they log a message on stderr, syslog, etc. + * They are only semantically different: error_msg() implies that + * the logged event is a warning/error, while log() does not. + * Another reason is that log() is such a short and nice name. :) + * It's a macro, not function, since it collides with log() from math.h + */ #undef log #define log(...) error_msg(__VA_ARGS__) diff --git a/lib/CommLayer/CommLayerInner.cpp b/lib/CommLayer/CommLayerInner.cpp index 71b26aa3..ec569e44 100644 --- a/lib/CommLayer/CommLayerInner.cpp +++ b/lib/CommLayer/CommLayerInner.cpp @@ -11,13 +11,6 @@ void comm_layer_inner_init(CObserver *pObs) } } -void comm_layer_inner_debug(const std::string& pMessage) -{ - if (g_pObs) - { - g_pObs->Debug(pMessage); - } -} void comm_layer_inner_warning(const std::string& pMessage) { if (g_pObs) diff --git a/lib/CommLayer/CommLayerInner.h b/lib/CommLayer/CommLayerInner.h index 491c1613..43faac05 100644 --- a/lib/CommLayer/CommLayerInner.h +++ b/lib/CommLayer/CommLayerInner.h @@ -4,8 +4,15 @@ #include "Observer.h" void comm_layer_inner_init(CObserver *pObs); -void comm_layer_inner_debug(const std::string& pMessage); + +/* Ask a client to warn the user about a non-fatal, but unexpected condition. + * In GUI, it will usually be presented as a popup message. + */ void comm_layer_inner_warning(const std::string& pMessage); +/* Logs a message to a client. + * In UI, it will usually appear as a new status line message in GUI, + * or as a new message line in CLI. + */ void comm_layer_inner_status(const std::string& pMessage); #endif /* COMMLAYERINNER_H_ */ diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp index f63a8c6b..330e1cc9 100644 --- a/lib/Utils/DebugDump.cpp +++ b/lib/Utils/DebugDump.cpp @@ -19,26 +19,16 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "abrtlib.h" -#include "DebugDump.h" -#include "ABRTException.h" #include <fstream> #include <iostream> #include <sstream> #include <cerrno> #include <sys/utsname.h> #include <magic.h> - +#include "abrtlib.h" +#include "DebugDump.h" +#include "ABRTException.h" #include "CommLayerInner.h" -// BUG? in C/C++, compiler may assume that function address is never NULL -#pragma weak comm_layer_inner_debug -#define comm_layer_inner_debug(msg) ({\ - if (comm_layer_inner_debug)\ - {\ - comm_layer_inner_debug(msg);\ - }}) - -#define PID_STR_MAX 16 /* Is it "." or ".."? */ /* abrtlib candidate */ @@ -112,7 +102,7 @@ bool CDebugDump::GetAndSetLock(const std::string& pLockFile, const std::string& { throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::GetAndSetLock(): cannot get lock status"); } - char pid[PID_STR_MAX + 1]; + char pid[sizeof(pid_t)*3 + 4]; int r = read(fd, pid, sizeof(pid) - 1); if (r == -1) { @@ -124,7 +114,7 @@ bool CDebugDump::GetAndSetLock(const std::string& pLockFile, const std::string& { close(fd); m_bUnlock = false; - comm_layer_inner_debug("Lock file '"+pLockFile+"' is locked by same process"); + log("Lock file '%s' is locked by same process", pLockFile.c_str()); return true; } if (lockf(fd, F_TEST, 0) == 0) @@ -134,7 +124,7 @@ bool CDebugDump::GetAndSetLock(const std::string& pLockFile, const std::string& Delete(); throw CABRTException(EXCEP_ERROR, "CDebugDump::GetAndSetLock(): dead lock found"); } - comm_layer_inner_debug("Lock file '"+pLockFile+"' is locked by another process"); + log("Lock file '%s' is locked by another process", pLockFile.c_str()); close(fd); return false; } @@ -154,7 +144,7 @@ bool CDebugDump::GetAndSetLock(const std::string& pLockFile, const std::string& m_nFD = fd; m_bUnlock = true; - comm_layer_inner_debug("Locking '"+pLockFile+"'..."); + log("Locking '%s'...", pLockFile.c_str()); return true; } @@ -176,7 +166,7 @@ void CDebugDump::UnLock() std::string lockFile = m_sDebugDumpDir + ".lock"; if (m_bUnlock) { - comm_layer_inner_debug("UnLocking '"+lockFile+"'..."); + log("UnLocking '%s'...", lockFile.c_str()); close(m_nFD); m_nFD = -1; remove(lockFile.c_str()); diff --git a/src/Daemon/CommLayerServer.h b/src/Daemon/CommLayerServer.h index 67b7e89e..2808f8a8 100644 --- a/src/Daemon/CommLayerServer.h +++ b/src/Daemon/CommLayerServer.h @@ -5,8 +5,6 @@ #include "abrtlib.h" #include "CrashTypes.h" -class CCrashWatcher; - class CCommLayerServer { public: CCommLayerServer(); diff --git a/src/Daemon/PluginManager.cpp b/src/Daemon/PluginManager.cpp index 3d698b16..01c2ef97 100644 --- a/src/Daemon/PluginManager.cpp +++ b/src/Daemon/PluginManager.cpp @@ -179,10 +179,7 @@ void CPluginManager::LoadPlugin(const std::string& pName) } catch (CABRTException& e) { - if (abrtPlugin != NULL) - { - delete abrtPlugin; - } + delete abrtPlugin; comm_layer_inner_warning("CPluginManager::LoadPlugin(): " + e.what()); comm_layer_inner_warning("Failed to load plugin " + pName); } |