From d2ea801240509b8412a31c9a280bece9d697e69e Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Wed, 10 Apr 2019 11:25:17 +0000
Subject: [PATCH] SW-642: Print command line arguments separated by spaces,
 instead of as a vector, for easier readability and use.

---
 MAC/APL/PAC/ITRFBeamServer/src/beamctl.cc    | 10 ++++------
 MAC/APL/PIC/RSP_Driver/src/rspctl_main.cc    | 10 ++++------
 MAC/APL/PIC/TBB_Driver/src/tbbctl.cc         | 10 ++++------
 MAC/APL/StationCU/src/ClockControl/clkctl.cc | 14 ++++++--------
 4 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/MAC/APL/PAC/ITRFBeamServer/src/beamctl.cc b/MAC/APL/PAC/ITRFBeamServer/src/beamctl.cc
index 4ae973b0584..6b83e7fe369 100644
--- a/MAC/APL/PAC/ITRFBeamServer/src/beamctl.cc
+++ b/MAC/APL/PAC/ITRFBeamServer/src/beamctl.cc
@@ -28,7 +28,6 @@
 #include <Common/LofarBitModeInfo.h>
 #include <Common/lofar_string.h>
 #include <Common/lofar_list.h>
-#include <Common/StreamUtil.h>
 #include <ApplCommon/AntennaSets.h>
 
 #include <APL/CAL_Protocol/CAL_Protocol.ph>
@@ -45,8 +44,7 @@
 #include <getopt.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <vector>
-#include <string>
+#include <sstream>
 
 #include "beamctl.h"
 
@@ -896,10 +894,10 @@ int main(int argc, char** argv)
     GCFScheduler::instance()->init(argc, argv, "beamctl");
 
     // Log command line to track usage
-    vector<string> args;
+    stringstream s;
     for (int i = 0; i < argc; i++)
-      args.push_back(argv[i]);
-    LOG_INFO_STR("Command line: " << args);
+      s << argv[i] << " ";
+    LOG_INFO_STR("Command line: " << s.str());
 
     ASSERTSTR(BEAMLET_RING_OFFSET > maxBeamlets(MIN_BITS_PER_SAMPLE),
                 formatString("(%d>%d) beamctl is not suitable for handling %d bit mode. Revise program.",
diff --git a/MAC/APL/PIC/RSP_Driver/src/rspctl_main.cc b/MAC/APL/PIC/RSP_Driver/src/rspctl_main.cc
index 79566f1be6e..caafd79d039 100644
--- a/MAC/APL/PIC/RSP_Driver/src/rspctl_main.cc
+++ b/MAC/APL/PIC/RSP_Driver/src/rspctl_main.cc
@@ -1,15 +1,13 @@
 #include <lofar_config.h>
 #include <Common/LofarLogger.h>
 #include <Common/StringUtil.h>
-#include <Common/StreamUtil.h>
 #include <Common/Exception.h>
 
 #include <GCF/TM/GCF_Scheduler.h>
 
 #include "rspctl.h"
 
-#include <vector>
-#include <string>
+#include <sstream>
 
 using namespace LOFAR;
 using namespace LOFAR::rspctl;
@@ -21,10 +19,10 @@ int main(int argc, char** argv)
 	GCFScheduler::instance()->init(argc, argv, "rspctl");
 
   // Log command line to track usage
-  vector<string> args;
+  stringstream s;
   for (int i = 0; i < argc; i++)
-    args.push_back(argv[i]);
-  LOG_INFO_STR("Command line: " << args);
+    s << argv[i] << " ";
+  LOG_INFO_STR("Command line: " << s.str());
 
 	LOG_INFO(formatString("Program %s has started", argv[0]));
 
diff --git a/MAC/APL/PIC/TBB_Driver/src/tbbctl.cc b/MAC/APL/PIC/TBB_Driver/src/tbbctl.cc
index 233710decee..7080b11a569 100644
--- a/MAC/APL/PIC/TBB_Driver/src/tbbctl.cc
+++ b/MAC/APL/PIC/TBB_Driver/src/tbbctl.cc
@@ -26,7 +26,6 @@
 #include <lofar_config.h>
 #include <Common/LofarLogger.h>
 #include <Common/StringUtil.h>
-#include <Common/StreamUtil.h>
 #include <Common/Exception.h>
 #include <Common/ParameterSet.h>
 
@@ -49,8 +48,7 @@
 #include <net/ethernet.h>
 #include <cstdio>
 #include <signal.h>
-#include <vector>
-#include <string>
+#include <sstream>
 
 #include "tbbctl.h"
 
@@ -4373,10 +4371,10 @@ int main(int argc, char** argv)
     GCFScheduler::instance()->init(argc, argv, "tbbctl");
 
     // Log command line to track usage
-    vector<string> args;
+    stringstream s;
     for (int i = 0; i < argc; i++)
-      args.push_back(argv[i]);
-    LOG_INFO_STR("Command line: " << args);
+      s << argv[i] << " ";
+    LOG_INFO_STR("Command line: " << s.str());
 
     LOG_DEBUG(formatString("Program %s has started", argv[0]));
 
diff --git a/MAC/APL/StationCU/src/ClockControl/clkctl.cc b/MAC/APL/StationCU/src/ClockControl/clkctl.cc
index 0ad87694359..8a959189805 100644
--- a/MAC/APL/StationCU/src/ClockControl/clkctl.cc
+++ b/MAC/APL/StationCU/src/ClockControl/clkctl.cc
@@ -23,7 +23,6 @@
 #include <lofar_config.h>
 #include <Common/LofarLogger.h>
 #include <Common/Exception.h>
-#include <Common/StreamUtil.h>
 #include <MACIO/MACServiceInfo.h>
 #include "Clock_Protocol.ph"
 
@@ -31,8 +30,7 @@
 
 #include "clkctl.h"
 
-#include <string>
-#include <vector>
+#include <sstream>
 
 namespace LOFAR {
 	using namespace Clock_Protocol;
@@ -218,11 +216,11 @@ int main(int argc, char* argv[])
 	// args: cntlrname, parentHost, parentService
 	GCFScheduler::instance()->init(argc, argv, "clkctl");
 
-  // Log command line to track usage
-  vector<string> args;
-  for (int i = 0; i < argc; i++)
-    args.push_back(argv[i]);
-  LOG_INFO_STR("Command line: " << args);
+    // Log command line to track usage
+    stringstream s;
+    for (int i = 0; i < argc; i++)
+      s << argv[i] << " ";
+    LOG_INFO_STR("Command line: " << s.str());
 
 	ClkCtl		cc(argv[1]);
 	cc.start(); 	// make initial transition
-- 
GitLab