From 02eb054f646f50b3044df413740379474d6985d3 Mon Sep 17 00:00:00 2001
From: John Biddiscombe <biddisco@cscs.ch>
Date: Wed, 20 Oct 2021 14:26:25 +0200
Subject: [PATCH] More debug output to try to resolve container issues

---
 src/cpp/cdo_wrapper.hpp | 20 ++++++++++++++++----
 src/cpp/process-CDO.cpp | 29 ++++++++++++++++++++---------
 2 files changed, 36 insertions(+), 13 deletions(-)

diff --git a/src/cpp/cdo_wrapper.hpp b/src/cpp/cdo_wrapper.hpp
index 10a2adb..5a3a1b4 100644
--- a/src/cpp/cdo_wrapper.hpp
+++ b/src/cpp/cdo_wrapper.hpp
@@ -22,11 +22,23 @@
 #include <chrono>
 
 #define DEBUG_OUTPUT 1
+#define DEBUG_TOFILE 0
+
+#if DEBUG_TOFILE
+#define DEBUG_FILE(msg) \
+    { \
+        std::filesystem::path home(getenv("HOME")); \
+        std::ofstream l_commands(home /= "commands.txt", std::ios_base::app); \
+        l_commands << component_ << " : " << std::endl << msg; \
+    } \
+#endif
+#else
+#define DEBUG_FILE(msg)
+#endif
+
 #define DEBUG_LOG(msg) { \
-    std::filesystem::path home(getenv("HOME")); \
-    std::ofstream commands(home /= "commands.txt", std::ios_base::app); \
-    commands  << "component    : " << component_ << std::endl << msg; \
-    std::cout << "component    : " << component_ << " : " << msg << std::endl; \
+    std::cout << component_ << " : " << msg << std::endl; \
+    DEBUG_FILE(msg) \
 }
 
 struct cdo_wrapper : std::enable_shared_from_this<cdo_wrapper>
diff --git a/src/cpp/process-CDO.cpp b/src/cpp/process-CDO.cpp
index 23f625f..9364873 100644
--- a/src/cpp/process-CDO.cpp
+++ b/src/cpp/process-CDO.cpp
@@ -68,7 +68,19 @@ void set_signal_handler()
 
 int main(int argc, char *argv[])
 {
-    set_signal_handler();
+    std::ostringstream temp1;
+    for (int i = 0; i < argc; i++){
+        temp1 << argv[i] << " ";
+    }
+    std::cout << temp1.str() << std::endl;
+    {
+        std::string component_("unknown");
+        DEBUG_LOG(temp1.str());
+    }
+
+    //
+    //set_signal_handler();
+
     //
     // Input Argument Handling
     //
@@ -145,7 +157,7 @@ int main(int argc, char *argv[])
     // in stager mode, we copy input to output, ignore any outputs set
     if (stagermode) {
         if (produces.size()>0) {
-            DEBUG_LOG("WARNING      : Stager mode set, command-line outputs will be ignored");
+            DEBUG_LOG("Warning      : Stager mode set, command-line outputs will be ignored");
         }
         produces = consumes;
         for (auto &p : produces) {
@@ -156,12 +168,13 @@ int main(int argc, char *argv[])
     // make sure every CDO produced has a count of how many consumers need it
     // if not specified, assume just 1
     if (out_counts.size() < produces.size()) {
-        DEBUG_LOG("Warning : Not all outputs had consumer counts specified");
+        DEBUG_LOG("Warning      : Not all outputs had consumer counts specified");
         out_counts.resize(produces.size(), 1);
     }
 
 #if DEBUG_OUTPUT
     std::stringstream temp;
+    temp << "\n";
     temp << "------------- " << component_   << "\n";
     temp << "component    : " << component_   << "\n";
 
@@ -187,11 +200,7 @@ int main(int argc, char *argv[])
     temp << "watcher      : " << watchermode << "\n";
     temp << "stager       : " << stagermode  << "\n";
     temp << "------------- " << component_   << "\n";
-    {
-        std::ofstream commands("/home/biddisco/commands.txt", std::ios_base::app);
-        commands << temp.str();
-    }
-    std::cout << temp.str();
+    DEBUG_LOG(temp.str());
   #endif
 
     // stop file already present
@@ -199,9 +208,10 @@ int main(int argc, char *argv[])
 
     mocktage_read_pminfo_file(pminfo.c_str());
 
+    DEBUG_LOG("Calling mstro_init");
     mstro_status result = mstro_init("mocktage", component_.c_str(), 0);
     if (result != MSTRO_OK) {
-        printf("Error \n");
+        DEBUG_LOG("Error mstro_init");
         return EXIT_FAILURE;
     }
 
@@ -225,6 +235,7 @@ int main(int argc, char *argv[])
 
     // async wait on all of the consumed CDOs
     for (auto &t : threads) {
+        DEBUG_LOG("getting future");
         shared_cdo cdo = t.get();
         if (stagermode) {
             cached_data_map.insert( std::make_pair(cdo->name_, cdo->deep_copy_data()) );
-- 
GitLab