diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-26 19:40:28 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-26 19:40:28 +0200 |
| commit | caf38bbfe3279b9bea861e4d5b70f3c50c6e1755 (patch) | |
| tree | 5ed7f83b0bdb584422f2e99489cfc81aac645500 /lib/CommLayer/CommLayerInner.cpp | |
| parent | fca6fa371006186d12a720cd48c270789c67d2e6 (diff) | |
| download | abrt-caf38bbfe3279b9bea861e4d5b70f3c50c6e1755.tar.gz abrt-caf38bbfe3279b9bea861e4d5b70f3c50c6e1755.tar.xz abrt-caf38bbfe3279b9bea861e4d5b70f3c50c6e1755.zip | |
add job ids (== thread ids) to warning/update DBus messages
renamed:
comm_layer_inner_warning -> warn_client
comm_layer_inner_status -> update_client
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib/CommLayer/CommLayerInner.cpp')
| -rw-r--r-- | lib/CommLayer/CommLayerInner.cpp | 50 |
1 files changed, 37 insertions, 13 deletions
diff --git a/lib/CommLayer/CommLayerInner.cpp b/lib/CommLayer/CommLayerInner.cpp index ec569e4..1a58814 100644 --- a/lib/CommLayer/CommLayerInner.cpp +++ b/lib/CommLayer/CommLayerInner.cpp @@ -1,28 +1,52 @@ +#include <pthread.h> /* pthread_self() */ +#include "abrtlib.h" #include "CommLayerInner.h" -static CObserver *g_pObs = NULL; +static CObserver *s_pObs; +static pthread_t s_main_id; - -void comm_layer_inner_init(CObserver *pObs) +void init_daemon_logging(CObserver *pObs) { - if (!g_pObs) - { - g_pObs = pObs; - } + s_pObs = pObs; + s_main_id = pthread_self(); } -void comm_layer_inner_warning(const std::string& pMessage) +void warn_client(const std::string& pMessage) { - if (g_pObs) + if (!s_pObs) + return; + pthread_t self = pthread_self(); + if (self != s_main_id) { - g_pObs->Warning(pMessage); + std::string s = ssprintf("%%%llx: %s", (unsigned long long)self, pMessage.c_str()); + s_pObs->Warning(s); +//log("w: '%s'", s.c_str()); + } + else + { + s_pObs->Warning(pMessage); +// debug: this should not happen - if it is, we are trying to log to a client +// but we have no job id! +log("W: '%s'", pMessage.c_str()); } } -void comm_layer_inner_status(const std::string& pMessage) +void update_client(const std::string& pMessage) { - if (g_pObs) + if (!s_pObs) + return; + pthread_t self = pthread_self(); + if (self != s_main_id) + { + std::string s = ssprintf("%%%llx: %s", (unsigned long long)self, pMessage.c_str()); + s_pObs->Status(s); +//log("u: '%s'", s.c_str()); + } + else { - g_pObs->Status(pMessage); + s_pObs->Status(pMessage); +// debug: this should not happen - if it is, we are trying to log to a client +// but we have no job id! +log("U: '%s'", pMessage.c_str()); } } |
