summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-08-26 16:22:26 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-08-26 16:22:26 +0200
commitfca6fa371006186d12a720cd48c270789c67d2e6 (patch)
treebb17aaf2e00132d41263aac0fee6481d754800dd /lib
parent556a4b3df4f116965e8dc46c08ac5e720834022e (diff)
downloadabrt-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>
Diffstat (limited to 'lib')
-rw-r--r--lib/CommLayer/CommLayerInner.cpp7
-rw-r--r--lib/CommLayer/CommLayerInner.h9
-rw-r--r--lib/Utils/DebugDump.cpp26
3 files changed, 16 insertions, 26 deletions
diff --git a/lib/CommLayer/CommLayerInner.cpp b/lib/CommLayer/CommLayerInner.cpp
index 71b26aa..ec569e4 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 491c161..43faac0 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 f63a8c6..330e1cc 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());