Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use macros DEBUG and INFO instead of printf
authorthiery <thiery@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 3 Jul 2006 07:00:46 +0000 (07:00 +0000)
committerthiery <thiery@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 3 Jul 2006 07:00:46 +0000 (07:00 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2465 48e7efb5-ca39-0410-a469-dd3cf9ba447f

examples/simdag/sd_test.c
src/simdag/sd_global.c
src/simdag/sd_task.c

index 3c79394..ec7047c 100644 (file)
@@ -3,14 +3,17 @@
 #include "simdag/simdag.h"
 #include "xbt/ex.h"
 
+XBT_LOG_NEW_DEFAULT_CATEGORY(sd_test,
+                            "Logging specific to this SimDag example");
+
 int main(int argc, char **argv) {
   
   /* initialisation of SD */
   SD_init(&argc, argv);
 
   if (argc < 2) {
-     printf ("Usage: %s platform_file\n", argv[0]);
-     printf ("example: %s sd_platform.xml\n", argv[0]);
+     INFO1("Usage: %s platform_file", argv[0]);
+     INFO1("example: %s sd_platform.xml", argv[0]);
      exit(1);
   }
 
@@ -63,27 +66,27 @@ int main(int argc, char **argv) {
   changed_tasks = SD_simulate(100);
   
   while (changed_tasks[0] != NULL) {
-    printf("Tasks whose state has changed:\n");
+    INFO0("Tasks whose state has changed:");
     i = 0;
     while(changed_tasks[i] != NULL) {
       switch (SD_task_get_state(changed_tasks[i])) {
       case SD_SCHEDULED:
-       printf("%s is scheduled.\n", SD_task_get_name(changed_tasks[i]));
+       INFO1("%s is scheduled.", SD_task_get_name(changed_tasks[i]));
        break;
       case SD_READY:
-       printf("%s is ready.\n", SD_task_get_name(changed_tasks[i]));
+       INFO1("%s is ready.", SD_task_get_name(changed_tasks[i]));
        break;
       case SD_RUNNING:
-       printf("%s is running.\n", SD_task_get_name(changed_tasks[i]));
+       INFO1("%s is running.", SD_task_get_name(changed_tasks[i]));
        break;
       case SD_DONE:
-       printf("%s is done.\n", SD_task_get_name(changed_tasks[i]));
+       INFO1("%s is done.", SD_task_get_name(changed_tasks[i]));
        break;
       case SD_FAILED:
-       printf("%s is failed.\n", SD_task_get_name(changed_tasks[i]));
+       INFO1("%s is failed.", SD_task_get_name(changed_tasks[i]));
        break;
       default:
-       printf("Unknown status for %s\n", SD_task_get_name(changed_tasks[i]));
+       INFO1("Unknown status for %s", SD_task_get_name(changed_tasks[i]));
        break;
       }
       i++;
index b4e17c7..8716913 100644 (file)
@@ -67,17 +67,9 @@ void SD_create_environment(const char *platform_file) {
 
   surf_timer_resource_init(platform_file);  /* tell Surf to create the environnement */
 
-  
-  /*printf("surf_workstation_resource = %p, workstation_set = %p\n", surf_workstation_resource, workstation_set);
-    printf("surf_network_resource = %p, network_link_set = %p\n", surf_network_resource, network_link_set);*/
-
   /*surf_workstation_resource_init_KCCFLN05(platform_file);*/
   surf_workstation_resource_init_CLM03(platform_file);
 
-  /*printf("surf_workstation_resource = %p, workstation_set = %p\n", surf_workstation_resource, workstation_set);
-    printf("surf_network_resource = %p, network_link_set = %p\n", surf_network_resource, network_link_set);*/
-
-
   /* now let's create the SD wrappers for workstations and links */
   xbt_dict_foreach(workstation_set, cursor, name, surf_workstation) {
     __SD_workstation_create(surf_workstation, NULL);
@@ -214,7 +206,7 @@ SD_task_t* SD_simulate(double how_long)
   }
 
   INFO0("Simulation finished");
-  /*  printf("elapsed_time = %f, total_time = %f, watch_point_reached = %d\n", elapsed_time, total_time, sd_global->watch_point_reached);*/
+  DEBUG3("elapsed_time = %f, total_time = %f, watch_point_reached = %d", elapsed_time, total_time, sd_global->watch_point_reached);
 
   return changed_tasks;
 }
index 059fa86..a40dd23 100644 (file)
@@ -3,6 +3,9 @@
 #include "xbt/sysdep.h"
 #include "xbt/dynar.h"
 
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_task,sd,
+                               "Logging specific to SimDag (task)");
+
 static void __SD_task_remove_dependencies(SD_task_t task);
 
 /**
@@ -130,7 +133,7 @@ void __SD_task_set_state(SD_task_t task, e_SD_task_state_t new_state) {
   xbt_swag_insert(task, task->state_set);
 
   if (task->watch_points & new_state) {
-    printf("Watch point reached with task '%s'!\n", SD_task_get_name(task));
+    INFO1("Watch point reached with task '%s'!", SD_task_get_name(task));
     sd_global->watch_point_reached = 1;
     SD_task_unwatch(task, new_state); /* remove the watch point */
   }
@@ -180,25 +183,25 @@ double SD_task_get_remaining_amount(SD_task_t task) {
 
 /* temporary function for debbuging */
 static void __SD_print_dependencies(SD_task_t task) {
-  printf("The following tasks must be executed before %s:", SD_task_get_name(task));
+  INFO1("The following tasks must be executed before %s:", SD_task_get_name(task));
   xbt_dynar_t dynar = task->tasks_before;
   int length = xbt_dynar_length(dynar);
   int i;
   SD_dependency_t dependency;
   for (i = 0; i < length; i++) {
     xbt_dynar_get_cpy(dynar, i, &dependency);
-    printf(" %s", SD_task_get_name(dependency->src));
+    INFO1(" %s", SD_task_get_name(dependency->src));
   }
 
-  printf("\nThe following tasks must be executed after %s:", SD_task_get_name(task));
+  INFO1("The following tasks must be executed after %s:", SD_task_get_name(task));
 
   dynar = task->tasks_after;
   length = xbt_dynar_length(dynar);
   for (i = 0; i < length; i++) {
     xbt_dynar_get_cpy(dynar, i, &dependency);
-    printf(" %s", SD_task_get_name(dependency->dst));
+    INFO1(" %s", SD_task_get_name(dependency->dst));
   }
-  printf("\n----------------------------\n");
+  INFO0("----------------------------");
 }
 
 /* Destroys a dependency between two tasks.
@@ -257,7 +260,7 @@ void SD_task_dependency_add(const char *name, void *data, SD_task_t src, SD_task
   /* if the task was ready, then dst->tasks_before is not empty anymore,
      so we must go back to state SD_SCHEDULED */
   if (__SD_task_is_ready(dst)) {
-    printf("SD_task_dependency_add: %s was ready and becomes scheduled!\n", SD_task_get_name(dst));
+    DEBUG1("SD_task_dependency_add: %s was ready and becomes scheduled!", SD_task_get_name(dst));
     __SD_task_set_state(dst, SD_SCHEDULED);
   }
 
@@ -346,14 +349,13 @@ static void __SD_print_watch_points(SD_task_t task) {
   static const int state_masks[] = {SD_SCHEDULED, SD_RUNNING, SD_READY, SD_DONE, SD_FAILED};
   static const char* state_names[] = {"scheduled", "running", "ready", "done", "failed"};
 
-  printf("Task '%s' watch points (%x): ", SD_task_get_name(task), task->watch_points);
+  INFO2("Task '%s' watch points (%x): ", SD_task_get_name(task), task->watch_points);
 
   int i;
   for (i = 0; i < 5; i++) {
     if (task->watch_points & state_masks[i])
-      printf("%s ", state_names[i]);
+      INFO1("%s ", state_names[i]);
   }
-  printf("\n");
 }
 
 /**
@@ -529,7 +531,7 @@ void SD_task_destroy(SD_task_t task) {
   SD_CHECK_INIT_DONE();
   xbt_assert0(task != NULL, "Invalid parameter");
 
-  /*printf("Destroying task %s...\n", SD_task_get_name(task));*/
+  DEBUG1("Destroying task %s...", SD_task_get_name(task));
 
   __SD_task_remove_dependencies(task);
 
@@ -544,5 +546,5 @@ void SD_task_destroy(SD_task_t task) {
   xbt_dynar_free(&task->tasks_after);
   xbt_free(task);
 
-  /*printf("Task destroyed.\n");*/
+  DEBUG0("Task destroyed.");
 }