From 5d35494c5fbaa4fe4fb80c5b2213cf5d80dc1ee6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Tue, 15 Oct 2013 13:17:00 +0200 Subject: [PATCH] Debugging through syslog, only with -DDEBUG. --- src/Throw.cpp | 8 +++++++- src/Vfs.cpp | 8 ++++++++ src/Vfs.h | 7 +++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Throw.cpp b/src/Throw.cpp index d51888b..02e5688 100644 --- a/src/Throw.cpp +++ b/src/Throw.cpp @@ -10,7 +10,13 @@ void dmlite::vfsThrowHelper(const std::string &classname, const std::string& func, int code, const std::string& msg) throw (DmException) { - throw DmException(code, classname + "::" + func + "(): " + msg); + std::string text; + + text = classname + "::" + func + "(): " + msg; +#ifdef DEBUG + syslog(LOG_DEBUG, "%s", text.c_str()); +#endif + throw DmException(code, text); } diff --git a/src/Vfs.cpp b/src/Vfs.cpp index 1a7dc09..57d2430 100644 --- a/src/Vfs.cpp +++ b/src/Vfs.cpp @@ -36,6 +36,9 @@ VfsFactory::VfsFactory() throw (DmException) struct hostent* hent = gethostbyname(hname.nodename); this->hostName_ = hent->h_name; +#ifdef DEBUG + openlog("dmlite-vfs-plugin", LOG_PID, LOG_USER); +#endif } @@ -76,6 +79,7 @@ void VfsFactory::configure(const std::string& key, const std::string& value) thr Catalog* VfsFactory::createCatalog(PluginManager*) throw (DmException) { + syslog(LOG_DEBUG, "%s", __func__); return new VfsCatalog(this->hostName_, this->allow_, this->deny_); } @@ -83,6 +87,7 @@ Catalog* VfsFactory::createCatalog(PluginManager*) throw (DmException) PoolManager* VfsFactory::createPoolManager(PluginManager*) throw (DmException) { + syslog(LOG_DEBUG, "%s", __func__); return new VfsPoolManager(this->hostName_, this->tokenPasswd_, this->tokenUseIp_, this->tokenLife_); @@ -99,6 +104,7 @@ std::string VfsFactory::implementedPool() throw () PoolDriver* VfsFactory::createPoolDriver() throw (DmException) { + syslog(LOG_DEBUG, "%s", __func__); return new VfsPoolDriver(this->hostName_, this->tokenPasswd_, this->tokenUseIp_, this->tokenLife_); @@ -108,6 +114,7 @@ PoolDriver* VfsFactory::createPoolDriver() throw (DmException) IODriver* VfsFactory::createIODriver(PluginManager*) throw (DmException) { + syslog(LOG_DEBUG, "%s", __func__); return new VfsIODriver(this->tokenPasswd_, this->tokenUseIp_); } @@ -115,6 +122,7 @@ IODriver* VfsFactory::createIODriver(PluginManager*) throw (DmException) Authn* VfsFactory::createAuthn(PluginManager*) throw (DmException) { + syslog(LOG_DEBUG, "%s", __func__); return new VfsAuthn(); } diff --git a/src/Vfs.h b/src/Vfs.h index 022fb04..f36f1fd 100644 --- a/src/Vfs.h +++ b/src/Vfs.h @@ -10,6 +10,13 @@ #include #include +#ifdef DEBUG +#include +#else +#define syslog +#define LOG_DEBUG 0 +#endif + #ifdef __GNUC__ #define vfsThrowErrno(MSG...) dmlite::vfsThrowHelper(getImplId(), __func__, DMLITE_SYSERR(errno) , ##MSG) -- 1.8.2.3