Debugging through syslog, only with -DDEBUG.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Tue, 15 Oct 2013 11:17:00 +0000 (13:17 +0200)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Tue, 15 Oct 2013 11:17:00 +0000 (13:17 +0200)
src/Throw.cpp
src/Vfs.cpp
src/Vfs.h

index d51888b..02e5688 100644 (file)
 
 
 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);
 }
 
 
index 1a7dc09..57d2430 100644 (file)
@@ -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();
 }
 
index 022fb04..f36f1fd 100644 (file)
--- a/src/Vfs.h
+++ b/src/Vfs.h
 #include <dmlite/cpp/io.h>
 #include <dmlite/cpp/poolmanager.h>
 
+#ifdef DEBUG
+#include <syslog.h>
+#else
+#define syslog
+#define LOG_DEBUG 0
+#endif
+
 
 #ifdef __GNUC__
   #define vfsThrowErrno(MSG...) dmlite::vfsThrowHelper(getImplId(), __func__, DMLITE_SYSERR(errno) , ##MSG)