From b4c73396bb0ceb1d8f8c3028d786c123f12bda62 Mon Sep 17 00:00:00 2001
From: aschwinn <al.schwinn@gsi.de>
Date: Tue, 23 May 2017 15:22:10 +0200
Subject: [PATCH] Bug 1387 - Provide Command-Line Silecs Client - added support
 for silecs-logger

---
 .../src/silecs-cli-client/main.cpp            | 33 ++++++++-----------
 1 file changed, 13 insertions(+), 20 deletions(-)

diff --git a/silecs-cli-client/src/silecs-cli-client/main.cpp b/silecs-cli-client/src/silecs-cli-client/main.cpp
index 128774c..bd713ad 100755
--- a/silecs-cli-client/src/silecs-cli-client/main.cpp
+++ b/silecs-cli-client/src/silecs-cli-client/main.cpp
@@ -42,10 +42,14 @@ std::string arg_deviceName = "";
 std::string arg_blockName = "";
 std::string arg_registerName = "";
 bool arg_silent = false;
+bool arg_verbose = false;
 bool arg_checkChecksum = true;
 ModeType arg_mode = UNDEFINED;
 uint32_t periodicInterval = 0;
 
+char* log_arg_base[2] = {(char*)"-plcLog",(char*)"ERROR,COMM"};
+char* log_arg_verbose[2] = {(char*)"-plcLog",(char*)"ERROR,DEBUG,SETUP,ALLOC,LOCK,COMM,SEND,RECV,DATA,DIAG"};
+
 void printHelp()
 {
     std::cout << std::endl;
@@ -65,7 +69,7 @@ void printHelp()
     std::cout << startbold << "\t-f " << endbold << "path to silecs-parameter-file of the plc" << std::endl;
     std::cout << startbold << "\t-h " << endbold << "print this help" << std::endl;
     std::cout << startbold << "\t-i " << endbold << "start interactive session" << std::endl;  // TODO: Implement
-    std::cout << startbold << "\t-l " << endbold << "define LOGTOPICS" << std::endl; // TODO: Implement
+    std::cout << startbold << "\t-v " << endbold << "verbose, all LOGTOPICS are enabled" << std::endl; // TODO: Implement
     //std::cout << startbold << "\t-m " << endbold << "mode, can be 'GET_DEVICE', 'GET_BLOCK', 'GET_REGISTER' or 'SET_REGISTER'" << std::endl;
     std::cout << startbold << "\t-m " << endbold << "mode, can be 'GET_DEVICE', 'GET_BLOCK' or 'GET_REGISTER'" << std::endl;
     std::cout << startbold << "\t-p " << endbold << "periodic Interval(ms) us ? to measure" << std::endl;
@@ -472,7 +476,7 @@ int main(int argc, char **argv)
 		bool interactiveOptionSet = false;
 		bool periodicOptionSet = false;
 
-		while ((opt = getopt(argc, argv, ":l:hcp:r:b:d:f:m:is")) != -1)
+		while ((opt = getopt(argc, argv, ":vhcp:r:b:d:f:m:is")) != -1)
 		{
 
 			switch (opt)
@@ -483,10 +487,8 @@ int main(int argc, char **argv)
 				case 'h':
 					printHelp();
 					return EXIT_SUCCESS;
-				case 'l':
-					arg_logTopics.assign(optarg);
-					std::cout << "TODO: make use of log-topics + define some defaults" << std::endl;
-					return EXIT_FAILURE;
+				case 'v':
+					arg_verbose = true;
 					break;
 				case 'p':
 					{
@@ -575,20 +577,11 @@ int main(int argc, char **argv)
 
 		Silecs::XMLParser::init();
 		Silecs::XMLParser paramParser(arg_parameterFile,true);
-
-//	    if(logTopics.length() == 0)
-//	    {
-		Silecs::Service *silecsService  = Silecs::Service::getInstance(0, NULL);
-//	    }
-//	    else
-//	    {
-//	    	Utils::logInfo(messageConsole_,"the following log topics will be used: " + logTopics);
-//	        char *a = new char[logTopics.size()+1];
-//	        a[logTopics.size()]=0;
-//	        memcpy(a,logTopics.c_str(),logTopics.size());
-//	        char *argv[2] = { (char *)"-plcLog", a };
-//	        silecsService  = Silecs::Service::getInstance(2,argv);
-//	    }
+		Silecs::Service *silecsService  = NULL;
+	    if(arg_verbose)
+	    	silecsService  = Silecs::Service::getInstance(2,log_arg_verbose);
+	    else
+	        silecsService  = Silecs::Service::getInstance(2,log_arg_base);
 
 		if(interactiveOptionSet)
 		{
-- 
GitLab