summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-11-06 17:51:17 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-11-06 17:51:17 +0100
commit1202706839ec42299e8794750cec66dfa7db0206 (patch)
tree328fec88403061afca8a71c74bc78e1b3dd96f34
parentb1336faa48bee2cdb7ef0486a5a4faa5c74f4fa7 (diff)
downloadabrt-1202706839ec42299e8794750cec66dfa7db0206.tar.gz
abrt-1202706839ec42299e8794750cec66dfa7db0206.tar.xz
abrt-1202706839ec42299e8794750cec66dfa7db0206.zip
simplify logging a bit. warn_client() is gone, reuse error_msg() for it.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--inc/abrtlib.h36
-rw-r--r--lib/Plugins/Bugzilla.cpp4
-rw-r--r--lib/Plugins/CCpp.cpp8
-rw-r--r--lib/Plugins/Catcut.cpp6
-rw-r--r--lib/Plugins/FileTransfer.cpp13
-rw-r--r--lib/Plugins/SOSreport.cpp2
-rw-r--r--lib/Plugins/TicketUploader.cpp15
-rw-r--r--lib/Utils/CommLayerInner.cpp57
-rw-r--r--lib/Utils/CommLayerInner.h16
-rw-r--r--lib/Utils/logging.cpp46
-rw-r--r--src/Daemon/CommLayerServerSocket.cpp12
-rw-r--r--src/Daemon/CrashWatcher.cpp28
-rw-r--r--src/Daemon/Daemon.cpp2
-rw-r--r--src/Daemon/MiddleWare.cpp20
-rw-r--r--src/Daemon/PluginManager.cpp2
15 files changed, 138 insertions, 129 deletions
diff --git a/inc/abrtlib.h b/inc/abrtlib.h
index 9bcd5bf..f9228d3 100644
--- a/inc/abrtlib.h
+++ b/inc/abrtlib.h
@@ -58,31 +58,29 @@ enum {
LOGMODE_STDIO = (1 << 0),
LOGMODE_SYSLOG = (1 << 1),
LOGMODE_BOTH = LOGMODE_SYSLOG + LOGMODE_STDIO,
+ LOGMODE_CUSTOM = (1 << 2),
};
+extern void (*g_custom_logger)(const char*);
extern const char *msg_prefix;
extern const char *msg_eol;
extern int logmode;
extern int xfunc_error_retval;
-extern void xfunc_die(void) NORETURN;
-extern void die_out_of_memory(void) NORETURN;
-extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
-extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
-extern void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
-extern void simple_perror_msg(const char *s);
-extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
-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);
-/* 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
- */
+void xfunc_die(void) NORETURN;
+void log_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
+/* It's a macro, not function, since it collides with log() from math.h */
#undef log
-#define log(...) error_msg(__VA_ARGS__)
+#define log(...) log_msg(__VA_ARGS__)
+/* error_msg family will use g_custom_logger. log_msg does not. */
+void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
+void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
+void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
+void simple_perror_msg(const char *s);
+void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
+void simple_perror_msg_and_die(const char *s) NORETURN;
+void perror_nomsg_and_die(void) NORETURN;
+void perror_nomsg(void);
+void verror_msg(const char *s, va_list p, const char *strerr);
+void die_out_of_memory(void) NORETURN;
/* Verbosity level */
extern int g_verbose;
diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp
index ca83d36..18ab5c8 100644
--- a/lib/Plugins/Bugzilla.cpp
+++ b/lib/Plugins/Bugzilla.cpp
@@ -313,7 +313,7 @@ int32_t ctx::check_uuid_in_bugzilla(const char* component, const char* UUID)
xmlrpc_int bug_id;
xmlrpc_read_int(&env, bug, &bug_id);
log("Bug is already reported: %i", (int)bug_id);
- update_client(_("Bug is already reported: ") + to_string(bug_id));
+ update_client(_("Bug is already reported: %i"), (int)bug_id);
xmlrpc_DECREF(bug);
xmlrpc_DECREF(item);
@@ -375,7 +375,7 @@ uint32_t ctx::new_bug(const map_crash_report_t& pCrashReport)
xmlrpc_read_int(&env, id, &bug_id);
throw_if_xml_fault_occurred(&env);
log("New bug id: %i", bug_id);
- update_client(_("New bug id: ") + to_string(bug_id));
+ update_client(_("New bug id: %i"), bug_id);
}
xmlrpc_DECREF(result);
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp
index a2d65f3..b6a5db8 100644
--- a/lib/Plugins/CCpp.cpp
+++ b/lib/Plugins/CCpp.cpp
@@ -610,8 +610,8 @@ Another application is holding the yum lock, cannot continue
if (last >= 0 && buff[last] == '\n')
buff[last] = '\0';
- /* log(buff); - update_client logs it too */
- update_client(buff); /* maybe only if buff != ""? */
+ log("%s", buff);
+ update_client("%s", buff); /* maybe only if buff != ""? */
#ifdef COMPLAIN_IF_NO_DEBUGINFO
if (already_installed == false)
@@ -715,8 +715,8 @@ static void InstallDebugInfos(const char *pDebugDumpDir, std::string& build_ids)
}
if (*p)
{
- /* log(buff); - update_client logs it too */
- update_client(buff);
+ log("%s", buff);
+ update_client("%s", buff);
}
}
diff --git a/lib/Plugins/Catcut.cpp b/lib/Plugins/Catcut.cpp
index 6bb44a9..23b1d2c 100644
--- a/lib/Plugins/Catcut.cpp
+++ b/lib/Plugins/Catcut.cpp
@@ -162,9 +162,7 @@ static void create_new_bug_description(const map_crash_report_t& pCrashReport, s
}
else if (it->second[CD_TYPE] == CD_BIN)
{
- string msg = ssprintf(_("Binary file %s will not be reported."), it->first.c_str());
- warn_client(msg);
- //update_client(_("Binary file ")+it->first+_(" will not be reported."));
+ error_msg(_("Binary file %s will not be reported"), it->first.c_str());
}
}
}
@@ -244,7 +242,7 @@ static string new_bug(const char *auth_cookie, const map_crash_report_t& pCrashR
throw_if_xml_fault_occurred();
bug_id_str = bug_id;
log("New bug id: %s", bug_id);
- update_client(_("New bug id: ") + bug_id_str);
+ update_client(_("New bug id: %s"), bug_id);
free((void*)bug_id);
xmlrpc_DECREF(bug_id_xml);
diff --git a/lib/Plugins/FileTransfer.cpp b/lib/Plugins/FileTransfer.cpp
index 8a88fef..2220e94 100644
--- a/lib/Plugins/FileTransfer.cpp
+++ b/lib/Plugins/FileTransfer.cpp
@@ -60,12 +60,11 @@ void CFileTransfer::SendFile(const char *pURL, const char *pFilename)
int len = strlen(pURL);
if (len == 0)
{
- warn_client(_("FileTransfer: URL not specified"));
+ error_msg(_("FileTransfer: URL not specified"));
return;
}
- string msg = ssprintf(_("Sending archive %s to %s"), pFilename, pURL);
- update_client(msg.c_str());
+ update_client(_("Sending archive %s to %s"), pFilename, pURL);
string wholeURL = concat_path_file(pURL, pFilename);
@@ -332,8 +331,7 @@ void CFileTransfer::Run(const char *pActionDir, const char *pArgs)
}
catch (CABRTException& e)
{
- warn_client(ssprintf(_("Can't create and send an archive: %s"), e.what()));
- //update_client("CFileTransfer::Run(): Cannot create and send an archive: " + e.what());
+ error_msg(_("Can't create and send an archive: %s"), e.what());
}
unlink(archivename.c_str());
}
@@ -358,8 +356,7 @@ void CFileTransfer::Run(const char *pActionDir, const char *pArgs)
}
catch (CABRTException& e)
{
- warn_client(ssprintf(_("Can't create and send an archive: "), e.what()));
-// update_client("CFileTransfer::Run(): Cannot create and send an archive: " + e.what());
+ error_msg(_("Can't create and send an archive %s"), e.what());
}
unlink(archivename.c_str());
}
@@ -381,7 +378,7 @@ void CFileTransfer::SetSettings(const map_plugin_settings_t& pSettings)
}
else
{
- warn_client(_("FileTransfer: URL not specified"));
+ error_msg(_("FileTransfer: URL not specified"));
}
it = pSettings.find("RetryCount");
diff --git a/lib/Plugins/SOSreport.cpp b/lib/Plugins/SOSreport.cpp
index da77cce..fedc51a 100644
--- a/lib/Plugins/SOSreport.cpp
+++ b/lib/Plugins/SOSreport.cpp
@@ -119,7 +119,7 @@ void CActionSOSreport::Run(const char *pActionDir, const char *pArgs)
command = ssprintf("%s %s 2>&1", command_prefix, args[0].c_str());
}
- update_client(_("running sosreport: ") + command);
+ update_client(_("running sosreport: %s"), command.c_str());
FILE *fp = popen(command.c_str(), "r");
if (fp == NULL)
{
diff --git a/lib/Plugins/TicketUploader.cpp b/lib/Plugins/TicketUploader.cpp
index 4aa05b7..60cba31 100644
--- a/lib/Plugins/TicketUploader.cpp
+++ b/lib/Plugins/TicketUploader.cpp
@@ -43,7 +43,7 @@ CTicketUploader::~CTicketUploader()
static void Error(const char *msg)
{
- update_client(msg);
+ update_client("%s", msg);
throw CABRTException(EXCEP_PLUGIN, msg);
}
@@ -102,11 +102,11 @@ void CTicketUploader::SendFile(const char *pURL, const char *pFilename)
{
if (pURL[0] == '\0')
{
- warn_client(_("FileTransfer: URL not specified"));
+ error_msg(_("FileTransfer: URL not specified"));
return;
}
- update_client(ssprintf(_("Sending archive %s to %s"), pFilename, pURL));
+ update_client(_("Sending archive %s to %s"), pFilename, pURL);
const char *base = (strrchr(pFilename, '/') ? : pFilename-1) + 1;
string wholeURL = concat_path_file(pURL, base);
@@ -133,7 +133,6 @@ void CTicketUploader::SendFile(const char *pURL, const char *pFilename)
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
/* specify target */
curl_easy_setopt(curl, CURLOPT_URL, wholeURL.c_str());
- /*file handle: passed to the default callback, it will fread() it*/
curl_easy_setopt(curl, CURLOPT_READDATA, f);
curl_easy_setopt(curl, CURLOPT_INFILESIZE, buf.st_size);
/* everything is done here; result 0 means success */
@@ -143,7 +142,7 @@ void CTicketUploader::SendFile(const char *pURL, const char *pFilename)
fclose(f);
if (result != 0)
{
- update_client(ssprintf(_("Sending failed, trying again. %s"), curl_easy_strerror((CURLcode)result)));
+ update_client(_("Sending failed, trying again. %s"), curl_easy_strerror((CURLcode)result));
}
}
/*retry the upload if not succesful, wait a bit before next try*/
@@ -317,19 +316,19 @@ string CTicketUploader::Report(const map_crash_report_t& pCrashReport,
}
msgbuf << _("END: ") << endl;
- warn_client(msgbuf.str());
+ error_msg("%s", msgbuf.str());
string ret;
if (do_upload)
{
string xx = _("report sent to ") + upload_url + '/' + outfile_basename;
- update_client(xx);
+ update_client("%s", xx);
ret = xx;
}
else
{
string xx = _("report copied to /tmp/") + outfile_basename;
- update_client(xx);
+ update_client("%s", xx);
ret = xx;
}
diff --git a/lib/Utils/CommLayerInner.cpp b/lib/Utils/CommLayerInner.cpp
index 8490e2f..307fe66 100644
--- a/lib/Utils/CommLayerInner.cpp
+++ b/lib/Utils/CommLayerInner.cpp
@@ -10,29 +10,48 @@ static map_uint_str_t s_mapClientID;
static pthread_mutex_t s_map_mutex;
static bool s_map_mutex_inited;
+/* called via [p]error_msg() */
+static void warn_client(const char *msg)
+{
+ if (!s_pObs)
+ return;
+
+ uint64_t key = uint64_t(pthread_self());
+
+ pthread_mutex_lock(&s_map_mutex);
+ map_uint_str_t::const_iterator ki = s_mapClientID.find(key);
+ const char* peer = (ki != s_mapClientID.end() ? ki->second.c_str() : NULL);
+ pthread_mutex_unlock(&s_map_mutex);
+
+ if (peer)
+ s_pObs->Warning(msg, peer, key);
+}
+
void init_daemon_logging(CObserver *pObs)
{
s_pObs = pObs;
if (!s_map_mutex_inited)
{
- pthread_mutex_init(&s_map_mutex, NULL);
s_map_mutex_inited = true;
+ pthread_mutex_init(&s_map_mutex, NULL);
+ g_custom_logger = &warn_client;
}
}
-void set_client_name(const char* name)
+void set_client_name(const char *name)
{
uint64_t key = uint64_t(pthread_self());
pthread_mutex_lock(&s_map_mutex);
- if (!name)
+ if (!name) {
s_mapClientID.erase(key);
- else
+ } else {
s_mapClientID[key] = name;
+ }
pthread_mutex_unlock(&s_map_mutex);
}
-void warn_client(const std::string& pMessage)
+void update_client(const char *fmt, ...)
{
if (!s_pObs)
return;
@@ -44,26 +63,16 @@ void warn_client(const std::string& pMessage)
const char* peer = (ki != s_mapClientID.end() ? ki->second.c_str() : NULL);
pthread_mutex_unlock(&s_map_mutex);
- if (peer)
- s_pObs->Warning(pMessage.c_str(), peer, key);
- else /* Bug: someone tries to warn_client() without set_client_name()!? */
- log("Hmm, stray %s: '%s'", __func__, pMessage.c_str());
-}
-
-void update_client(const std::string& pMessage)
-{
- if (!s_pObs)
+ if (!peer)
return;
- uint64_t key = uint64_t(pthread_self());
+ va_list p;
+ va_start(p, fmt);
+ char *msg;
+ int used = vasprintf(&msg, fmt, p);
+ va_end(p);
+ if (used < 0)
+ return;
- pthread_mutex_lock(&s_map_mutex);
- map_uint_str_t::const_iterator ki = s_mapClientID.find(key);
- const char* peer = (ki != s_mapClientID.end() ? ki->second.c_str() : NULL);
- pthread_mutex_unlock(&s_map_mutex);
-
- if (peer)
- s_pObs->Status(pMessage.c_str(), peer, key);
- else
- log("Hmm, stray %s: '%s'", __func__, pMessage.c_str());
+ s_pObs->Status(msg, peer, key);
}
diff --git a/lib/Utils/CommLayerInner.h b/lib/Utils/CommLayerInner.h
index d161cfc..9c22968 100644
--- a/lib/Utils/CommLayerInner.h
+++ b/lib/Utils/CommLayerInner.h
@@ -9,15 +9,19 @@ void init_daemon_logging(CObserver *pObs);
* Set client's name (dbus ID). NULL unsets it.
*/
void set_client_name(const char* name);
-/* Ask a client to warn the user about a non-fatal, but unexpected condition.
+
+/*
+ * 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.
+ * Usually there is no need to call it directly, just use [p]error_msg().
*/
-void warn_client(const std::string& pMessage);
-/* Logs a message to a client.
+//now static: void warn_client(const char *msg);
+
+/*
+ * 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 update_client(const std::string& pMessage);
-
-#endif /* COMMLAYERINNER_H_ */
+void update_client(const char *fmt, ...);
+#endif
diff --git a/lib/Utils/logging.cpp b/lib/Utils/logging.cpp
index f70d23f..cae609b 100644
--- a/lib/Utils/logging.cpp
+++ b/lib/Utils/logging.cpp
@@ -7,19 +7,18 @@
#include <syslog.h>
int xfunc_error_retval = EXIT_FAILURE;
-
int g_verbose;
+int logmode = LOGMODE_STDIO;
+const char *msg_prefix = "";
+const char *msg_eol = "\n";
+void (*g_custom_logger)(const char*);
void xfunc_die(void)
{
exit(xfunc_error_retval);
}
-const char *msg_prefix = "";
-const char *msg_eol = "\n";
-int logmode = LOGMODE_STDIO;
-
-void verror_msg(const char *s, va_list p, const char* strerr)
+static void verror_msg_helper(const char *s, va_list p, const char* strerr, int flags)
{
char *msg;
int prefix_len, strerr_len, msgeol_len, used;
@@ -27,9 +26,6 @@ void verror_msg(const char *s, va_list p, const char* strerr)
if (!logmode)
return;
- if (!s) /* nomsg[_and_die] uses NULL fmt */
- s = ""; /* some libc don't like printf(NULL) */
-
used = vasprintf(&msg, s, p);
if (used < 0)
return;
@@ -51,7 +47,7 @@ void verror_msg(const char *s, va_list p, const char* strerr)
memcpy(msg, msg_prefix, prefix_len);
}
if (strerr) {
- if (s[0]) { /* not perror_nomsg? */
+ if (s[0]) {
msg[used++] = ':';
msg[used++] = ' ';
}
@@ -60,24 +56,26 @@ void verror_msg(const char *s, va_list p, const char* strerr)
}
strcpy(&msg[used], msg_eol);
- if (logmode & LOGMODE_STDIO) {
+ if (flags & LOGMODE_STDIO) {
fflush(stdout);
full_write(STDERR_FILENO, msg, used + msgeol_len);
}
- if (logmode & LOGMODE_SYSLOG) {
+ if (flags & LOGMODE_SYSLOG) {
syslog(LOG_ERR, "%s", msg + prefix_len);
}
+ if ((flags & LOGMODE_CUSTOM) && g_custom_logger) {
+ g_custom_logger(msg + prefix_len);
+ }
free(msg);
}
-void error_msg_and_die(const char *s, ...)
+void log_msg(const char *s, ...)
{
va_list p;
va_start(p, s);
- verror_msg(s, p, NULL);
+ verror_msg_helper(s, p, NULL, logmode);
va_end(p);
- xfunc_die();
}
void error_msg(const char *s, ...)
@@ -85,8 +83,18 @@ void error_msg(const char *s, ...)
va_list p;
va_start(p, s);
- verror_msg(s, p, NULL);
+ verror_msg_helper(s, p, NULL, (logmode | LOGMODE_CUSTOM));
+ va_end(p);
+}
+
+void error_msg_and_die(const char *s, ...)
+{
+ va_list p;
+
+ va_start(p, s);
+ verror_msg_helper(s, p, NULL, (logmode | LOGMODE_CUSTOM));
va_end(p);
+ xfunc_die();
}
void perror_msg_and_die(const char *s, ...)
@@ -95,7 +103,7 @@ void perror_msg_and_die(const char *s, ...)
va_start(p, s);
/* Guard against "<error message>: Success" */
- verror_msg(s, p, errno ? strerror(errno) : NULL);
+ verror_msg_helper(s, p, errno ? strerror(errno) : NULL, (logmode | LOGMODE_CUSTOM));
va_end(p);
xfunc_die();
}
@@ -106,7 +114,7 @@ void perror_msg(const char *s, ...)
va_start(p, s);
/* Guard against "<error message>: Success" */
- verror_msg(s, p, errno ? strerror(errno) : NULL);
+ verror_msg_helper(s, p, errno ? strerror(errno) : NULL, (logmode | LOGMODE_CUSTOM));
va_end(p);
}
@@ -122,5 +130,5 @@ void simple_perror_msg(const char *s)
void die_out_of_memory(void)
{
- error_msg_and_die("Out of memory, exiting");
+ error_msg_and_die("Out of memory, exiting");
}
diff --git a/src/Daemon/CommLayerServerSocket.cpp b/src/Daemon/CommLayerServerSocket.cpp
index 7afe4b6..ee775c6 100644
--- a/src/Daemon/CommLayerServerSocket.cpp
+++ b/src/Daemon/CommLayerServerSocket.cpp
@@ -26,7 +26,7 @@ void CCommLayerServerSocket::Send(const std::string& pData, GIOChannel *pDestina
ret = g_io_channel_write_chars(pDestination, message + offset, strlen(message + offset), &len, &err);
if (ret == G_IO_STATUS_ERROR)
{
- warn_client("Error during sending data.");
+ error_msg("Error during sending data");
}
}
@@ -72,7 +72,7 @@ gboolean CCommLayerServerSocket::client_socket_cb(GIOChannel *source, GIOConditi
ret = g_io_channel_read_chars(source, buff, 1, &len, &err);
if (ret == G_IO_STATUS_ERROR)
{
- warn_client(std::string("Error while reading data from client socket: ") + err->message);
+ error_msg("Error while reading data from client socket: %s", err->message);
return FALSE;
}
message += buff[0];
@@ -101,13 +101,13 @@ gboolean CCommLayerServerSocket::server_socket_cb(GIOChannel *source, GIOConditi
condition & G_IO_ERR ||
condition & G_IO_NVAL)
{
- warn_client("Server socket error.");
+ error_msg("Server socket error");
return FALSE;
}
if ((socket = accept(serverSocket->m_nSocket, (struct sockaddr *)&remote, &len)) == -1)
{
- warn_client("Server can not accept client.");
+ error_msg("Server can not accept client");
return TRUE;
}
log("New socket client connected");
@@ -117,7 +117,7 @@ gboolean CCommLayerServerSocket::server_socket_cb(GIOChannel *source, GIOConditi
static_cast<GIOFunc>(client_socket_cb),
data))
{
- warn_client("Can not init g_io_channel.");
+ error_msg("Can not init g_io_channel");
return TRUE;
}
serverSocket->m_mapClientChannels[socket] = gSocket;
@@ -157,7 +157,7 @@ void CCommLayerServerSocket::ProcessMessage(const std::string& pMessage, GIOChan
}
else
{
- warn_client("Received unknown message type.");
+ error_msg("Received unknown message type");
}
}
diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp
index aa86350..e684277 100644
--- a/src/Daemon/CrashWatcher.cpp
+++ b/src/Daemon/CrashWatcher.cpp
@@ -58,23 +58,23 @@ vector_crash_infos_t GetCrashInfos(const char *pUID)
{
mw_result_t res;
map_crash_info_t info;
+ const char *uuid = UUIDsUIDs[ii].first.c_str();
+ const char *uid = UUIDsUIDs[ii].second.c_str();
- res = GetCrashInfo(UUIDsUIDs[ii].first.c_str(), UUIDsUIDs[ii].second.c_str(), info);
+ res = GetCrashInfo(uuid, uid, info);
switch (res)
{
case MW_OK:
retval.push_back(info);
break;
case MW_ERROR:
- warn_client("Can not find debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting from database");
- update_client("Can not find debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting from database");
- DeleteCrashInfo(UUIDsUIDs[ii].first.c_str(), UUIDsUIDs[ii].second.c_str());
+ error_msg("Can't find dump directory for UUID %s, deleting from database", uuid);
+ DeleteCrashInfo(uuid, uid);
break;
case MW_FILE_ERROR:
+ error_msg("Can't open file in dump directory for UUID %s, deleting", uuid);
{
- warn_client("Can not open file in debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting");
- update_client("Can not open file in debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting");
- std::string debugDumpDir = DeleteCrashInfo(UUIDsUIDs[ii].first.c_str(), UUIDsUIDs[ii].second.c_str());
+ std::string debugDumpDir = DeleteCrashInfo(uuid, uid);
DeleteDebugDumpDir(debugDumpDir.c_str());
}
break;
@@ -89,8 +89,7 @@ vector_crash_infos_t GetCrashInfos(const char *pUID)
{
throw e;
}
- warn_client(e.what());
- update_client(e.what());
+ error_msg("%s", e.what());
}
//retval = GetCrashInfos(pUID);
@@ -123,15 +122,15 @@ map_crash_report_t GetJobResult(const char* pUUID, const char* pUID, int force)
case MW_OK:
break;
case MW_IN_DB_ERROR:
- warn_client(std::string("Did not find crash with UUID ") + pUUID + " in database");
+ error_msg("Can't find crash with UUID %s in database", pUUID);
break;
case MW_PLUGIN_ERROR:
- warn_client("Particular analyzer plugin isn't loaded or there is an error within plugin(s)");
+ error_msg("Particular analyzer plugin isn't loaded or there is an error within plugin(s)");
break;
case MW_CORRUPTED:
case MW_FILE_ERROR:
default:
- warn_client(std::string("Corrupted crash with UUID ") + pUUID + ", deleting");
+ error_msg("Corrupted crash with UUID %s, deleting", pUUID);
std::string debugDumpDir = DeleteCrashInfo(pUUID, pUID);
DeleteDebugDumpDir(debugDumpDir.c_str());
break;
@@ -162,7 +161,7 @@ static void* create_report(void* arg)
}
catch (CABRTException& e)
{
- warn_client(e.what());
+ error_msg("%s", e.what());
}
catch (...) {}
set_client_name(NULL);
@@ -220,8 +219,7 @@ bool DeleteDebugDump(const char *pUUID, const char *pUID)
{
throw e;
}
- warn_client(e.what());
- update_client(e.what());
+ error_msg("%s", e.what());
return false;
}
return true;
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp
index c6d0a02..67e72cc 100644
--- a/src/Daemon/Daemon.cpp
+++ b/src/Daemon/Daemon.cpp
@@ -572,7 +572,7 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin
}
catch (CABRTException& e)
{
- warn_client(e.what());
+ error_msg(e.what());
if (e.type() == EXCEP_FATAL)
{
free(buf);
diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp
index 3f26ab0..6a63564 100644
--- a/src/Daemon/MiddleWare.cpp
+++ b/src/Daemon/MiddleWare.cpp
@@ -191,7 +191,7 @@ mw_result_t CreateCrashReport(const char *pUUID,
}
if (pUUID[0] == '\0' || row.m_sUUID != pUUID)
{
- warn_client(ssprintf("CreateCrashReport(): UUID '%s' is not in database", pUUID));
+ error_msg("UUID '%s' is not in database", pUUID);
return MW_IN_DB_ERROR;
}
@@ -236,7 +236,7 @@ mw_result_t CreateCrashReport(const char *pUUID,
}
catch (CABRTException& e)
{
- warn_client(e.what());
+ error_msg("%s", e.what());
if (e.type() == EXCEP_DD_OPEN)
{
return MW_ERROR;
@@ -266,8 +266,7 @@ void RunAction(const char *pActionDir,
}
catch (CABRTException& e)
{
- warn_client(ssprintf("RunAction(): %s", e.what()));
- update_client(ssprintf("Execution of '%s' was not successful: %s", pPluginName, e.what()));
+ error_msg("Execution of '%s' was not successful: %s", pPluginName, e.what());
}
}
@@ -295,8 +294,7 @@ void RunActionsAndReporters(const char *pDebugDumpDir)
}
catch (CABRTException& e)
{
- warn_client(e.what());
- update_client(ssprintf("Activation of plugin '%s' was not successful: %s", it_ar->first.c_str(), e.what()));
+ error_msg("Activation of plugin '%s' was not successful: %s", it_ar->first.c_str(), e.what());
}
}
}
@@ -435,7 +433,7 @@ report_status_t Report(const map_crash_report_t& pCrashReport,
{
ret[pluginName].push_back("0");
ret[pluginName].push_back(e.what());
- update_client(ssprintf("Reporting via %s' was not successful: %s", pluginName.c_str(), e.what()));
+ update_client("Reporting via %s' was not successful: %s", pluginName.c_str(), e.what());
}
}
}
@@ -564,7 +562,7 @@ static mw_result_t SavePackageDescriptionToDebugDump(const char *pExecutable,
}
catch (CABRTException& e)
{
- warn_client(e.what());
+ error_msg("%s", e.what());
if (e.type() == EXCEP_DD_SAVE)
{
return MW_FILE_ERROR;
@@ -600,7 +598,7 @@ static void RunAnalyzerActions(const char *pAnalyzer, const char *pDebugDumpDir)
}
catch (CABRTException& e)
{
- update_client(ssprintf("Action performed by '%s' was not successful: %s", pluginName.c_str(), e.what()));
+ update_client("Action performed by '%s' was not successful: %s", pluginName.c_str(), e.what());
}
}
}
@@ -682,7 +680,7 @@ mw_result_t SaveDebugDump(const char *pDebugDumpDir,
}
catch (CABRTException& e)
{
- warn_client(e.what());
+ error_msg("%s", e.what());
if (e.type() == EXCEP_DD_SAVE)
{
return MW_FILE_ERROR;
@@ -732,7 +730,7 @@ mw_result_t GetCrashInfo(const char *pUUID,
}
catch (CABRTException& e)
{
- warn_client(e.what());
+ error_msg("%s", e.what());
if (e.type() == EXCEP_DD_LOAD)
{
return MW_FILE_ERROR;
diff --git a/src/Daemon/PluginManager.cpp b/src/Daemon/PluginManager.cpp
index aa0b531..5b87151 100644
--- a/src/Daemon/PluginManager.cpp
+++ b/src/Daemon/PluginManager.cpp
@@ -179,7 +179,7 @@ void CPluginManager::LoadPlugin(const std::string& pName)
catch (CABRTException& e)
{
delete abrtPlugin;
- warn_client(ssprintf("Failed to load plugin %s: %s", pName.c_str(), e.what()));
+ error_msg("Failed to load plugin %s: %s", pName.c_str(), e.what());
}
}
}