[nnc debug] Update debug format in sources (#943)
authorDenis Maksimenko/AI Tools Lab /SRR/Assistant Engineer/삼성전자 <d.maksimenko@partner.samsung.com>
Wed, 15 Aug 2018 11:42:16 +0000 (14:42 +0300)
committerSergey Vostokov/AI Tools Lab /SRR/Staff Engineer/삼성전자 <s.vostokov@samsung.com>
Wed, 15 Aug 2018 11:42:16 +0000 (14:42 +0300)
Changed format used for debugging in most files.

Signed-off-by: Denis Maksimenko <d.maksimenko@partner.samsung.com>
contrib/nnc/CMakeLists.txt
contrib/nnc/examples/plugin_example/samplePlugin.cpp
contrib/nnc/libs/backend/soft/CMakeLists.txt
contrib/nnc/libs/backend/soft/src/soft_backend.cpp
contrib/nnc/src/module/plugin/PluginManager.cpp
contrib/nnc/src/module/plugin/shared_library.cpp

index 2fc75b0..9c88137 100644 (file)
@@ -9,6 +9,8 @@ file(GLOB_RECURSE TESTS "unittests/*.cpp")
 file(GLOB_RECURSE MAIN "src/main.cpp")
 list(REMOVE_ITEM SOURCES ${MAIN})
 
+include_directories(include)
+
 # Used by unit tests
 set(NNC_SOFT_BACKEND_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs/backend/soft)
 set(NNC_CORE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs/core)
index 528d366..14b504e 100644 (file)
@@ -6,6 +6,11 @@
 #include "ConfigException.h"
 #include "PluginType.h"
 
+// Enable debugging
+#include "debug.h"
+#define DEBUG_AREA "examples"
+using nncc::contrib::dbgs;
+
 static const std::string pluginName = "Your plugin name here";
 static const std::string pluginVersion = "Your plugin version here";
 static const std::string pluginDesc = "Your plugin description here";
@@ -39,7 +44,7 @@ private:
 AbstractPluginInstance &SamplePluginInstance::getInstance()
 {
   static SamplePluginInstance instance;
-  std::cout << std::endl << "!!! plugin (" << pluginName << ") " << __func__ << std::endl;
+  NNC_DEBUG(dbgs() << std::endl << "!!! plugin (" << pluginName << ") " << __func__ << std::endl);
 
   return instance;
 }
@@ -62,18 +67,18 @@ void SamplePluginInstance::fillSession()
 
 void SamplePluginInstance::checkConfig()
 {
-  std::cout << std::endl << "!!! plugin (" << pluginName << ") " << __func__ << std::endl;
+  NNC_DEBUG(dbgs() << std::endl << "!!! plugin (" << pluginName << ") " << __func__ << std::endl);
 }
 
 void *SamplePluginInstance::execute(void *data)
 {
-  std::cout << std::endl << "!!! plugin (" << pluginName << ") " << __func__ << std::endl;
+  NNC_DEBUG(dbgs() << std::endl << "!!! plugin (" << pluginName << ") " << __func__ << std::endl);
   return data;
 }
 
 void SamplePluginInstance::setParam(const std::string &name)
 {
-  std::cout << "bad parameter <" << name << ">";
+  NNC_DEBUG(dbgs() << "bad parameter <" << name << ">");
 }
 
 void SamplePluginInstance::setParam(const std::string &name, const std::string &value)
@@ -86,12 +91,12 @@ void SamplePluginInstance::setParam(const std::string &name, const std::string &
   {
     throw nncc::contrib::ConfigException("unsupported parameter <" + name + ">");
   }
-  std::cout << __func__ << " : " << name << " = " << value << std::endl;
+  NNC_DEBUG(dbgs() << __func__ << " : " << name << " = " << value << std::endl);
 }
 
 extern "C" AbstractPluginInstance *get_instance()
 {
-  std::cout << std::endl << "!!! plugin (" << pluginName << ") " << __func__ << std::endl;
+  NNC_DEBUG(dbgs() << std::endl << "!!! plugin (" << pluginName << ") " << __func__ << std::endl);
   return &SamplePluginInstance::getInstance();
 }
 
index 5c53acd..686749f 100644 (file)
@@ -17,6 +17,8 @@ target_include_directories(soft_backend_common PRIVATE ${CMAKE_CURRENT_BINARY_DI
 target_link_libraries(soft_backend_common PRIVATE nncc_core)
 target_link_libraries(soft_backend_common PRIVATE nnc_plugin_core)
 target_link_libraries(soft_backend_common PRIVATE nnc_core)
+# This is included because right now common functional is built into nnc_module
+target_link_libraries(soft_backend_common PRIVATE nnc_module)
 
 function(make_soft_backend NAME)
     add_library(${NAME} SHARED ${ARGN} ${SOFT_GENERATED_SOURCES})
index c3fa362..a796fc9 100644 (file)
@@ -12,6 +12,9 @@
 #include <sys/types.h>
 #include <dirent.h>
 
+#include "debug.h"
+#define DEBUG_AREA "soft_backend"
+
 using namespace std;
 using namespace nncc::contrib;
 using namespace nncc::contrib::config;
@@ -98,7 +101,7 @@ void *BaseSoftBackend::execute(void *data)
   assert(data);
   Graph *graph = static_cast<Graph*>(data);
   generate(graph);
-  clog << "[" << _pluginName << "] Plugin executed" << endl;
+  NNC_DEBUG(dbgs() << "[" << _pluginName << "] Plugin executed" << endl);
   return data;
 }
 
index 1d3aa3f..79cb971 100644 (file)
@@ -16,6 +16,9 @@
 #define STR_EXTENSION_PLUGIN ".so"
 #endif /* __APPLE__ */
 
+#include "debug.h"
+#define DEBUG_AREA "plugins"
+
 namespace nncc
 {
 namespace contrib
@@ -64,8 +67,7 @@ std::vector<std::string> PluginManager::getPluginPathList() {
 }
 
 void PluginManager::loadPlugins(std::vector<AbstractModule *> &modules) {
-  // FIXME: it's necessary to make this printing via debugging system (see issue #893)
-  //std::cout << "Current plugin path is <" << _pluginsPath << ">" << std::endl;
+  NNC_DEBUG(dbgs() << "Current plugin path is <" << _pluginsPath << ">" << std::endl);
   auto plugins = getPluginPathList();
 
   for (const auto &pluginPath : plugins) {
@@ -159,8 +161,7 @@ void PluginManager::applyParam(const std::string &name) {
 }
 
 void PluginManager::applyParam(const std::string &name, const std::string &value) {
-  // FIXME: it's necessary to make this printing via debugging system (see issue #893)
-  //std::cout << __func__ << " <" + name + "> = " + value << std::endl;
+  NNC_DEBUG(dbgs() << __func__ << " <" + name + "> = " + value << std::endl);
   if (name == paramPluginPath) {
     _pluginsPath = value;
   } else {
index 6a67603..698529c 100644 (file)
@@ -3,6 +3,9 @@
 
 #include "module/plugin/shared_library.h"
 
+#include "debug.h"
+#define DEBUG_AREA "plugins"
+
 namespace nncc
 {
 namespace contrib
@@ -45,7 +48,7 @@ bool SharedLibrary::loadLibrary()
     _isLoaded = true;
 
     // open the library
-    std::cout << "Opening " << _path << std::endl;
+    NNC_DEBUG(dbgs() << "Opening " << _path << std::endl);
 
     _handle = dlopen(_path.c_str(), RTLD_LAZY);