[HICN-483] log strategy decisions using hicn-light log 75/24475/2
authormichele papalini <micpapal@cisco.com>
Wed, 22 Jan 2020 13:26:48 +0000 (14:26 +0100)
committerMichele Papalini <micpapal@cisco.com>
Wed, 22 Jan 2020 13:37:59 +0000 (13:37 +0000)
Signed-off-by: michele papalini <micpapal@cisco.com>
Change-Id: I70959ca8b534aea4682175cd755523201a5dc51b

hicn-light/src/hicn/core/logger.c
hicn-light/src/hicn/core/logger.h
hicn-light/src/hicn/strategies/lowLatency.c

index 43740f7..0b9bb26 100644 (file)
@@ -49,6 +49,7 @@ static const struct facility_to_string {
     {.facility = LoggerFacility_IO, .string = "IO"},
     {.facility = LoggerFacility_Message, .string = "Message"},
     {.facility = LoggerFacility_Processor, .string = "Processor"},
+    {.facility = LoggerFacility_Strategy, .string = "Strategy"},
     {.facility = 0, .string = NULL}};
 
 const char *logger_FacilityString(LoggerFacility facility) {
index c46a870..8ab741f 100644 (file)
@@ -50,6 +50,7 @@ typedef enum {
   LoggerFacility_IO,
   LoggerFacility_Processor,
   LoggerFacility_Message,
+  LoggerFacility_Strategy,
   LoggerFacility_END  // sentinel value
 } LoggerFacility;
 
index e1d16b3..c9e4918 100644 (file)
@@ -434,30 +434,40 @@ static void strategyLowLatency_SelectBestFaces(StrategyLowLatency *ll,
   }
 
   NEW_ROUND:
-#if 0
-    if(ll->use2paths){
-      printf("use 2 paths. rtt face %d = %f queue = %f is_lossy = %d,"
-             "rtt face %d = %f queue = %f is_lossy = %d\n",
-        strategyNexthopStateLL_GetFaceId(ll->bestFaces[0]),
-        strategyNexthopStateLL_GetRTTLive(ll->bestFaces[0]),
-        strategyNexthopStateLL_GetQueuing(ll->bestFaces[0]),
-        strategyNexthopStateLL_IsLossy(ll->bestFaces[0]),
-        strategyNexthopStateLL_GetFaceId(ll->bestFaces[1]),
-        strategyNexthopStateLL_GetRTTLive(ll->bestFaces[1]),
-        strategyNexthopStateLL_GetQueuing(ll->bestFaces[1]),
-        strategyNexthopStateLL_IsLossy(ll->bestFaces[1]));
-    }else{
-      if(ll->bestFaces[0] != NULL){
-        printf("use 1 path. rtt face %d = %f is_lossy = %d (avoid multipath = %d)\n",
-          strategyNexthopStateLL_GetFaceId(ll->bestFaces[0]),
-          strategyNexthopStateLL_GetRTTLive(ll->bestFaces[0]),
-          strategyNexthopStateLL_IsLossy(ll->bestFaces[0]),
-          ll->avoid_multipath);
-      }else{
-        printf("no face to use!\n");
+    {
+      Logger * log = forwarder_GetLogger(ll->forwarder);
+      if(log != NULL &&
+        logger_IsLoggable(log, LoggerFacility_Strategy, PARCLogLevel_Info)){
+      if(ll->use2paths){
+          logger_Log(log, LoggerFacility_Strategy, PARCLogLevel_Info,
+            __func__, "use 2 paths. rtt face %d = %f queue = %f is_lossy = %d,"
+            "rtt face %d = %f queue = %f is_lossy = %d\n",
+            strategyNexthopStateLL_GetFaceId(ll->bestFaces[0]),
+            strategyNexthopStateLL_GetRTTLive(ll->bestFaces[0]),
+            strategyNexthopStateLL_GetQueuing(ll->bestFaces[0]),
+            strategyNexthopStateLL_IsLossy(ll->bestFaces[0]),
+            strategyNexthopStateLL_GetFaceId(ll->bestFaces[1]),
+            strategyNexthopStateLL_GetRTTLive(ll->bestFaces[1]),
+            strategyNexthopStateLL_GetQueuing(ll->bestFaces[1]),
+            strategyNexthopStateLL_IsLossy(ll->bestFaces[1]));
+        }else{
+          if(ll->bestFaces[0] != NULL){
+            logger_Log(log, LoggerFacility_Strategy,
+              PARCLogLevel_Info, __func__,
+              "use 1 path. rtt face %d = %f is_lossy = %d ",
+              "(avoid multipath = %d)\n",
+              strategyNexthopStateLL_GetFaceId(ll->bestFaces[0]),
+              strategyNexthopStateLL_GetRTTLive(ll->bestFaces[0]),
+              strategyNexthopStateLL_IsLossy(ll->bestFaces[0]),
+              ll->avoid_multipath);
+          }else{
+            logger_Log(log, LoggerFacility_Strategy, PARCLogLevel_Info,
+                     __func__, "no face to use!\n");
+          }
+        }
       }
     }
-#endif
+
   //update the round only at the end for all the faces
   if(new_round){
     PARCIterator * iterator = parcHashMap_CreateKeyIterator(ll->strategy_state);