diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-28 14:06:18 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-28 14:06:18 +0200 |
commit | 5b07fe7069347f4c442155cc737ef24bd85fa24a (patch) | |
tree | 1ffec21b4d38f942d816a062a016b365a0bdd51c /src | |
parent | 7cd21b9ed1a87af2979573b580508651466a67a8 (diff) | |
download | abrt-5b07fe7069347f4c442155cc737ef24bd85fa24a.tar.gz abrt-5b07fe7069347f4c442155cc737ef24bd85fa24a.tar.xz abrt-5b07fe7069347f4c442155cc737ef24bd85fa24a.zip |
daemon: log DBus calls with -v; log file creation only with -vvv
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/Daemon/CommLayerServerDBus.cpp | 27 | ||||
-rw-r--r-- | src/Daemon/CommLayerServerSocket.cpp | 1 | ||||
-rw-r--r-- | src/Daemon/Daemon.cpp | 116 | ||||
-rw-r--r-- | src/Daemon/Daemon.h | 3 |
4 files changed, 80 insertions, 67 deletions
diff --git a/src/Daemon/CommLayerServerDBus.cpp b/src/Daemon/CommLayerServerDBus.cpp index a1758ca5..1e159c88 100644 --- a/src/Daemon/CommLayerServerDBus.cpp +++ b/src/Daemon/CommLayerServerDBus.cpp @@ -5,6 +5,7 @@ #include "Daemon.h" #include "CommLayerServerDBus.h" + void attach_dbus_dispatcher_to_glib_main_context() { DBus::Glib::BusDispatcher* dispatcher; @@ -59,7 +60,9 @@ DBus::Message CCommLayerServerDBus::_GetCrashInfos_stub(const DBus::CallMessage { DBus::MessageIter ri = call.reader(); - unsigned long unix_uid = m_pConn->sender_unix_uid(call.sender()); + const char* sender = call.sender(); + unsigned long unix_uid = m_pConn->sender_unix_uid(sender); + VERB1 log("got %s() call from %s, uid %lu", "GetCrashInfos", sender, unix_uid); vector_crash_infos_t argout1 = GetCrashInfos(to_string(unix_uid)); DBus::ReturnMessage reply(call); @@ -76,6 +79,7 @@ DBus::Message CCommLayerServerDBus::_CreateReport_stub(const DBus::CallMessage & const char* sender = call.sender(); unsigned long unix_uid = m_pConn->sender_unix_uid(sender); + VERB1 log("got %s('%s') call from %s, uid %lu", "CreateReport", argin1.c_str(), sender, unix_uid); uint64_t argout1 = CreateReport_t(argin1, to_string(unix_uid), sender); DBus::ReturnMessage reply(call); @@ -90,7 +94,9 @@ DBus::Message CCommLayerServerDBus::_Report_stub(const DBus::CallMessage &call) map_crash_report_t argin1; ri >> argin1; - unsigned long unix_uid = m_pConn->sender_unix_uid(call.sender()); + const char* sender = call.sender(); + unsigned long unix_uid = m_pConn->sender_unix_uid(sender); + VERB1 log("got %s(...) call from %s, uid %lu", "Report", sender, unix_uid); report_status_t argout1 = Report(argin1, to_string(unix_uid)); DBus::ReturnMessage reply(call); @@ -105,7 +111,9 @@ DBus::Message CCommLayerServerDBus::_DeleteDebugDump_stub(const DBus::CallMessag std::string argin1; ri >> argin1; - unsigned long unix_uid = m_pConn->sender_unix_uid(call.sender()); + const char* sender = call.sender(); + unsigned long unix_uid = m_pConn->sender_unix_uid(sender); + VERB1 log("got %s('%s') call from %s, uid %lu", "DeleteDebugDump", argin1.c_str(), sender, unix_uid); bool argout1 = DeleteDebugDump(argin1, to_string(unix_uid)); DBus::ReturnMessage reply(call); @@ -120,7 +128,9 @@ DBus::Message CCommLayerServerDBus::_GetJobResult_stub(const DBus::CallMessage & uint64_t job_id; ri >> job_id; - unsigned long unix_uid = m_pConn->sender_unix_uid(call.sender()); + const char* sender = call.sender(); + unsigned long unix_uid = m_pConn->sender_unix_uid(sender); + VERB1 log("got %s(%llx) call from %s, uid %lu", "GetJobResult", (long long)job_id, sender, unix_uid); map_crash_report_t report = GetJobResult(job_id, to_string(unix_uid)); DBus::ReturnMessage reply(call); @@ -143,10 +153,11 @@ DBus::Message CCommLayerServerDBus::_GetPluginSettings_stub(const DBus::CallMess { DBus::MessageIter ri = call.reader(); std::string PluginName; - std::string uid; ri >> PluginName; - unsigned long unix_uid = m_pConn->sender_unix_uid(call.sender()); + const char* sender = call.sender(); + unsigned long unix_uid = m_pConn->sender_unix_uid(sender); + VERB1 log("got %s('%s') call from %s, uid %lu", "GetPluginSettings", PluginName.c_str(), sender, unix_uid); map_plugin_settings_t plugin_settings = g_pPluginManager->GetPluginSettings(PluginName, to_string(unix_uid)); DBus::ReturnMessage reply(call); @@ -163,7 +174,9 @@ DBus::Message CCommLayerServerDBus::_SetPluginSettings_stub(const DBus::CallMess ri >> PluginName; ri >> plugin_settings; - unsigned long unix_uid = m_pConn->sender_unix_uid(call.sender()); + const char* sender = call.sender(); + unsigned long unix_uid = m_pConn->sender_unix_uid(sender); + VERB1 log("got %s('%s',...) call from %s, uid %lu", "SetPluginSettings", PluginName.c_str(), sender, unix_uid); g_pPluginManager->SetPluginSettings(PluginName, to_string(unix_uid), plugin_settings); DBus::ReturnMessage reply(call); diff --git a/src/Daemon/CommLayerServerSocket.cpp b/src/Daemon/CommLayerServerSocket.cpp index 3e38a709..c88e0f3f 100644 --- a/src/Daemon/CommLayerServerSocket.cpp +++ b/src/Daemon/CommLayerServerSocket.cpp @@ -166,7 +166,6 @@ void CCommLayerServerSocket::ProcessMessage(const std::string& pMessage, GIOChan CCommLayerServerSocket::CCommLayerServerSocket() : CCommLayerServer() { - int len; struct sockaddr_un local; unlink(SOCKET_FILE); diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp index b6155f17..ea41302e 100644 --- a/src/Daemon/Daemon.cpp +++ b/src/Daemon/Daemon.cpp @@ -451,75 +451,73 @@ static gboolean handle_event_cb(GIOChannel *gio, GIOCondition condition, gpointe event = (struct inotify_event *) &buf[i]; if (event->len) - name = &buf[i] + sizeof (struct inotify_event); - i += sizeof (struct inotify_event) + event->len; + name = &buf[i] + sizeof (*event); + i += sizeof (*event) + event->len; - log("Created file: %s", name); + /* ignore lock files and such */ + if (!(event->mask & IN_ISDIR)) + { + VERB3 log("File '%s' creation detected, ignoring", name); + continue; + } - /* we ignore the lock files */ - if (event->mask & IN_ISDIR) + log("Directory '%s' creation detected", name); + if (GetDirSize(DEBUG_DUMPS_DIR) / (1024*1024) >= g_settings_nMaxCrashReportsSize) + { +//TODO: delete oldest or biggest dir + log("Size of '%s' >= %u MB, deleting '%s'", DEBUG_DUMPS_DIR, g_settings_nMaxCrashReportsSize, name); + DeleteDebugDumpDir(std::string(DEBUG_DUMPS_DIR) + "/" + name); + continue; + } + + map_crash_info_t crashinfo; + try { - if (GetDirSize(DEBUG_DUMPS_DIR) / (1024*1024) < g_settings_nMaxCrashReportsSize) + mw_result_t res; + res = SaveDebugDump(std::string(DEBUG_DUMPS_DIR) + "/" + name, crashinfo); + switch (res) { - //std::string sName = name; - map_crash_info_t crashinfo; - try - { - mw_result_t res; - res = SaveDebugDump(std::string(DEBUG_DUMPS_DIR) + "/" + name, crashinfo); - switch (res) - { - case MW_OK: - log("New crash, saving..."); - RunActionsAndReporters(crashinfo[CD_MWDDD][CD_CONTENT]); - /* Send dbus signal */ - g_pCommLayer->Crash(crashinfo[CD_PACKAGE][CD_CONTENT], crashinfo[CD_UID][CD_CONTENT]); - break; - case MW_REPORTED: - case MW_OCCURED: - log("Already saved crash, deleting..."); - /* Send dbus signal */ - g_pCommLayer->Crash(crashinfo[CD_PACKAGE][CD_CONTENT], crashinfo[CD_UID][CD_CONTENT]); - DeleteDebugDumpDir(std::string(DEBUG_DUMPS_DIR) + "/" + name); - break; - case MW_BLACKLISTED: - case MW_CORRUPTED: - case MW_PACKAGE_ERROR: - case MW_GPG_ERROR: - case MW_IN_DB: - case MW_FILE_ERROR: - default: - warn_client("Corrupted or bad crash, deleting..."); - DeleteDebugDumpDir(std::string(DEBUG_DUMPS_DIR) + "/" + name); - break; - } - } - catch (CABRTException& e) - { - warn_client(e.what()); - if (e.type() == EXCEP_FATAL) - { - delete[] buf; - return -1; - } - } - catch (...) - { - delete[] buf; - throw; - } + case MW_OK: + log("New crash, saving..."); + RunActionsAndReporters(crashinfo[CD_MWDDD][CD_CONTENT]); + /* Send dbus signal */ + g_pCommLayer->Crash(crashinfo[CD_PACKAGE][CD_CONTENT], crashinfo[CD_UID][CD_CONTENT]); + break; + case MW_REPORTED: + case MW_OCCURED: + log("Already saved crash, deleting..."); + /* Send dbus signal */ + g_pCommLayer->Crash(crashinfo[CD_PACKAGE][CD_CONTENT], crashinfo[CD_UID][CD_CONTENT]); + DeleteDebugDumpDir(std::string(DEBUG_DUMPS_DIR) + "/" + name); + break; + case MW_BLACKLISTED: + case MW_CORRUPTED: + case MW_PACKAGE_ERROR: + case MW_GPG_ERROR: + case MW_IN_DB: + case MW_FILE_ERROR: + default: + warn_client("Corrupted or bad crash, deleting..."); + DeleteDebugDumpDir(std::string(DEBUG_DUMPS_DIR) + "/" + name); + break; } - else + } + catch (CABRTException& e) + { + warn_client(e.what()); + if (e.type() == EXCEP_FATAL) { - log("DebugDumps size has exceeded the limit, deleting the last dump: %s", name); - DeleteDebugDumpDir(std::string(DEBUG_DUMPS_DIR) + "/" + name); + delete[] buf; + return -1; } } - else + catch (...) { - log("Some file created, ignoring..."); + delete[] buf; + throw; } - } + } /* while */ + delete[] buf; return TRUE; } diff --git a/src/Daemon/Daemon.h b/src/Daemon/Daemon.h index 7c236972..084ccd94 100644 --- a/src/Daemon/Daemon.h +++ b/src/Daemon/Daemon.h @@ -31,6 +31,9 @@ class CRPM; /* Verbosity level */ extern int g_verbose; +#define VERB1 if (g_verbose >= 1) +#define VERB2 if (g_verbose >= 2) +#define VERB3 if (g_verbose >= 3) /* Used for sending dbus signals */ extern CCommLayerServer *g_pCommLayer; |