summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-08-07 18:13:23 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-08-07 18:13:23 +0200
commitc64f91baf599133f88658e7a45a4d7e4a6c43d2b (patch)
tree194cce790f33327c26d6d569fce9f756981e432d
parentf2ee86e3b37b3d917cdf00fceffeffd65be1b3ce (diff)
downloadabrt-c64f91baf599133f88658e7a45a4d7e4a6c43d2b.tar.gz
abrt-c64f91baf599133f88658e7a45a4d7e4a6c43d2b.tar.xz
abrt-c64f91baf599133f88658e7a45a4d7e4a6c43d2b.zip
simplify logging by removing CCommLayerInner class
It had single use site. The class itself is trivial, it just passed messages down to an CObserver. Now we pass messages directly to an CObserver. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--lib/CommLayer/CommLayerInner.cpp29
-rw-r--r--lib/CommLayer/CommLayerInner.h101
-rw-r--r--lib/CommLayer/Observer.h9
-rw-r--r--src/Daemon/CrashWatcher.cpp4
-rw-r--r--src/Daemon/CrashWatcher.h1
5 files changed, 19 insertions, 125 deletions
diff --git a/lib/CommLayer/CommLayerInner.cpp b/lib/CommLayer/CommLayerInner.cpp
index 33e09093..71b26aa3 100644
--- a/lib/CommLayer/CommLayerInner.cpp
+++ b/lib/CommLayer/CommLayerInner.cpp
@@ -1,44 +1,35 @@
#include "CommLayerInner.h"
-CCommLayerInner* g_pCommLayerInner = NULL;
+static CObserver *g_pObs = NULL;
-void comm_layer_inner_init(CCommLayerInner *pCommLayerInner)
+void comm_layer_inner_init(CObserver *pObs)
{
- if (!g_pCommLayerInner)
+ if (!g_pObs)
{
- g_pCommLayerInner = pCommLayerInner;
+ g_pObs = pObs;
}
}
void comm_layer_inner_debug(const std::string& pMessage)
{
- if (g_pCommLayerInner)
+ if (g_pObs)
{
- if (g_pCommLayerInner->GetDebugCommLayer())
- {
- g_pCommLayerInner->GetDebugCommLayer()->Message(pMessage);
- }
+ g_pObs->Debug(pMessage);
}
}
void comm_layer_inner_warning(const std::string& pMessage)
{
- if (g_pCommLayerInner)
+ if (g_pObs)
{
- if (g_pCommLayerInner->GetWarningCommLayer())
- {
- g_pCommLayerInner->GetWarningCommLayer()->Message(pMessage);
- }
+ g_pObs->Warning(pMessage);
}
}
void comm_layer_inner_status(const std::string& pMessage)
{
- if (g_pCommLayerInner)
+ if (g_pObs)
{
- if (g_pCommLayerInner->GetStatusCommLayer())
- {
- g_pCommLayerInner->GetStatusCommLayer()->Message(pMessage);
- }
+ g_pObs->Status(pMessage);
}
}
diff --git a/lib/CommLayer/CommLayerInner.h b/lib/CommLayer/CommLayerInner.h
index f4b1ac24..491c1613 100644
--- a/lib/CommLayer/CommLayerInner.h
+++ b/lib/CommLayer/CommLayerInner.h
@@ -1,108 +1,9 @@
#ifndef COMMLAYERINNER_H_
#define COMMLAYERINNER_H_
-#include <iostream>
#include "Observer.h"
-class CDebugCommLayer
-{
- private:
- CObserver *m_pObserver;
- public:
- CDebugCommLayer(CObserver *pObs) :
- m_pObserver(pObs)
- {}
- void Message(const std::string& pMsg)
- {
- if(m_pObserver)
- {
- m_pObserver->Debug(pMsg);
- }
- }
-};
-
-class CWarningCommLayer
-{
- private:
- CObserver *m_pObserver;
- public:
- CWarningCommLayer(CObserver *pObs) :
- m_pObserver(pObs)
- {}
- void Message(const std::string& pMsg)
- {
- if(m_pObserver)
- {
- m_pObserver->Warning(pMsg);
- }
- }
-};
-
-class CStatusCommLayer
-{
- private:
- CObserver *m_pObserver;
- public:
- CStatusCommLayer(CObserver *pObs) :
- m_pObserver(pObs)
- {}
- void Message(const std::string& pMsg)
- {
- if(m_pObserver)
- {
- m_pObserver->Status(pMsg);
- }
- }
-};
-
-class CCommLayerInner
-{
- private:
- CDebugCommLayer* m_pDebugCommLayer;
- CWarningCommLayer* m_pWarningCommLayer;
- CStatusCommLayer* m_pStatusCommLayer;
- public:
- CDebugCommLayer* GetDebugCommLayer()
- {
- return m_pDebugCommLayer;
- }
- CWarningCommLayer* GetWarningCommLayer()
- {
- return m_pWarningCommLayer;
- }
- CStatusCommLayer* GetStatusCommLayer()
- {
- return m_pStatusCommLayer;
- }
- CCommLayerInner(CObserver *pObs, bool pDebug, bool pWarning)
- {
- m_pDebugCommLayer = NULL;
- m_pWarningCommLayer = NULL;
- if (pDebug)
- {
- m_pDebugCommLayer = new CDebugCommLayer(pObs);
- }
- if (pWarning)
- {
- m_pWarningCommLayer = new CWarningCommLayer(pObs);
- }
- m_pStatusCommLayer = new CStatusCommLayer(pObs);
- }
- ~CCommLayerInner()
- {
- if (m_pDebugCommLayer)
- {
- delete m_pDebugCommLayer;
- }
- if (m_pWarningCommLayer)
- {
- delete m_pWarningCommLayer;
- }
- delete m_pStatusCommLayer;
- }
-};
-
-void comm_layer_inner_init(CCommLayerInner *pCommLayerInner);
+void comm_layer_inner_init(CObserver *pObs);
void comm_layer_inner_debug(const std::string& pMessage);
void comm_layer_inner_warning(const std::string& pMessage);
void comm_layer_inner_status(const std::string& pMessage);
diff --git a/lib/CommLayer/Observer.h b/lib/CommLayer/Observer.h
index 81e7695e..42fd1479 100644
--- a/lib/CommLayer/Observer.h
+++ b/lib/CommLayer/Observer.h
@@ -4,6 +4,7 @@
//FIXME: move all common types to AbrtTypes.h ??
#include "DBusCommon.h"
#include <string>
+#include <iostream>
#include <stdint.h>
class CObserver {
@@ -13,10 +14,14 @@ class CObserver {
virtual void Status(const std::string& pMessage, const std::string& pDest="0") = 0;
virtual void Debug(const std::string& pMessage, const std::string& pDest="0") = 0;
virtual void Warning(const std::string& pMessage, const std::string& pDest="0") = 0;
-/* this should be implemented in daemon */
+ /* this should be implemented in daemon */
virtual vector_crash_infos_t GetCrashInfos(const std::string &pSender) = 0;
virtual map_crash_report_t CreateReport(const std::string &pUUID,const std::string &pSender) = 0;
- virtual uint64_t CreateReport_t(const std::string &pUUID,const std::string &pUID, const std::string &pSender){std::cout << "DEFAULT OBSERVER";return 0;};
+ virtual uint64_t CreateReport_t(const std::string &pUUID,const std::string &pUID, const std::string &pSender)
+ {
+ std::cout << "DEFAULT OBSERVER";
+ return 0;
+ }
virtual bool Report(map_crash_report_t pReport, const std::string &pSender) = 0;
virtual bool DeleteDebugDump(const std::string& pUUID, const std::string& pSender) = 0;
virtual map_crash_report_t GetJobResult(uint64_t pJobID, const std::string &pSender) = 0;
diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp
index c64e22a0..1ad59988 100644
--- a/src/Daemon/CrashWatcher.cpp
+++ b/src/Daemon/CrashWatcher.cpp
@@ -450,8 +450,7 @@ CCrashWatcher::CCrashWatcher(const std::string& pPath)
// TODO: initialize object according parameters -w -d
// status has to be always created.
m_pCommLayer = NULL;
- m_pCommLayerInner = new CCommLayerInner(this, true, true);
- comm_layer_inner_init(m_pCommLayerInner);
+ comm_layer_inner_init(this);
m_pSettings = new CSettings();
m_pSettings->LoadSettings(std::string(CONF_DIR) + "/abrt.conf");
@@ -506,7 +505,6 @@ CCrashWatcher::~CCrashWatcher()
delete m_pCommLayer;
delete m_pMW;
delete m_pSettings;
- delete m_pCommLayerInner;
if (pthread_mutex_destroy(&m_pJobsMutex) != 0)
{
throw CABRTException(EXCEP_FATAL, "CCrashWatcher::CCrashWatcher(): Can't destroy mutex!");
diff --git a/src/Daemon/CrashWatcher.h b/src/Daemon/CrashWatcher.h
index 1d91c9bb..1ad9d4e7 100644
--- a/src/Daemon/CrashWatcher.h
+++ b/src/Daemon/CrashWatcher.h
@@ -111,7 +111,6 @@ class CCrashWatcher
std::string m_sTarget;
CMiddleWare *m_pMW;
CCommLayerServer *m_pCommLayer;
- CCommLayerInner *m_pCommLayerInner;
/*FIXME not needed */
//DBus::Connection *m_pConn;
CSettings *m_pSettings;