Ver Fonte

Patch from Hans to significantly improve the logging functionality
read openais.conf.5 for info on how the new logging works.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@995 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake há 20 anos atrás
pai
commit
f50a6a11c8
23 ficheiros alterados com 520 adições e 403 exclusões
  1. 76 76
      exec/amf.c
  2. 0 1
      exec/amfconfig.c
  3. 1 0
      exec/cfg.c
  4. 2 0
      exec/ckpt.c
  5. 2 0
      exec/clm.c
  6. 2 0
      exec/cpg.c
  7. 2 0
      exec/lck.c
  8. 9 7
      exec/main.c
  9. 101 2
      exec/mainconfig.c
  10. 10 0
      exec/mainconfig.h
  11. 2 0
      exec/msg.c
  12. 103 206
      exec/print.c
  13. 100 33
      exec/print.h
  14. 2 0
      exec/service.c
  15. 2 0
      exec/sync.c
  16. 1 1
      exec/totem.h
  17. 15 12
      exec/totemnet.c
  18. 5 3
      exec/totempg.c
  19. 4 1
      exec/totemrrp.c
  20. 64 61
      exec/totemsrp.c
  21. 14 0
      exec/util.c
  22. 1 0
      exec/util.h
  23. 2 0
      exec/vsf_ykd.c

+ 76 - 76
exec/amf.c

@@ -537,17 +537,17 @@ void *clc_command_run (void *context)
 
 	sleep (1);
 
-printf ("clc_command_run()\n");
+	dprintf ("clc_command_run()\n");
 	pid = fork();
 
 	if (pid == -1) {
-		printf ("Couldn't fork process %s\n", strerror (errno));
+		dprintf ("Couldn't fork process %s\n", strerror (errno));
 		return (0);
 	}
 
 	if (pid) {
 		waiting = 1;
-printf ("waiting for pid %d to finish\n", pid);
+		dprintf ("waiting for pid %d to finish\n", pid);
 		waitpid (pid, &status, 0);
 		if (clc_command_run_data->completion_callback) {
 			clc_command_run_data->completion_callback (context);
@@ -623,16 +623,16 @@ printf ("waiting for pid %d to finish\n", pid);
 	if (cmd[0] == '\0') {
 		return (0);
 	}
-	printf ("running command '%s' with environment:\n", cmd);
-	printf ("0 %s\n", envp[0]);
-	printf ("1 %s\n", envp[1]);
-	printf ("2 %s\n", envp[2]);
-	printf ("3 %s\n", envp[3]);
-	printf ("4 %s\n", envp[4]);
+	dprintf ("running command '%s' with environment:\n", cmd);
+	dprintf ("0 %s\n", envp[0]);
+	dprintf ("1 %s\n", envp[1]);
+	dprintf ("2 %s\n", envp[2]);
+	dprintf ("3 %s\n", envp[3]);
+	dprintf ("4 %s\n", envp[4]);
 		
 	res = execve (cmd, argv, envp);
 	if (res == -1) {
-		printf ("Couldn't exec process %d=%s\n", errno, strerror (errno));
+		dprintf ("Couldn't exec process %d=%s\n", errno, strerror (errno));
 	}
 	assert (res != -1);
 	return (0);
@@ -682,7 +682,8 @@ int clc_cli_instantiate (struct amf_comp *comp)
 
 	struct clc_command_run_data *clc_command_run_data;
 
-	printf ("clc_cli_instaniate\n");
+	ENTER_ARGS("comp %s\n", getSaNameT (&comp->name));
+
 	clc_command_run_data = malloc (sizeof (struct clc_command_run_data));
 	clc_command_run_data->comp = comp;
 	clc_command_run_data->type = CLC_COMMAND_RUN_OPERATION_TYPE_INSTANTIATE;
@@ -695,13 +696,13 @@ int clc_cli_instantiate (struct amf_comp *comp)
 
 int clc_instantiate_callback (struct amf_comp *comp)
 {
-	printf ("clc_instantiate_callback\n");
+	ENTER_ARGS("comp %s\n", getSaNameT (&comp->name));
 	return (0);
 }
 
 int clc_csi_set_callback (struct amf_comp *comp)
 {
-	printf ("clc_csi_set_callback\n");
+	ENTER_ARGS("comp %s\n", getSaNameT (&comp->name));
 	return (0);
 }
 
@@ -710,7 +711,7 @@ int clc_csi_set_callback (struct amf_comp *comp)
  */
 int clc_cli_terminate (struct amf_comp *comp)
 {
-	printf ("clc_cli_terminate\n");
+	ENTER_ARGS("comp %s\n", getSaNameT (&comp->name));
 	return (0);
 }
 int clc_terminate_callback (struct amf_comp *comp)
@@ -718,16 +719,17 @@ int clc_terminate_callback (struct amf_comp *comp)
 	struct res_lib_amf_componentterminatecallback res_lib_amf_componentterminatecallback;
 	struct component_terminate_callback_data *component_terminate_callback_data;
 
-	printf ("clc_terminate_callback %p\n", comp->conn);
+	ENTER_ARGS("comp %s\n", getSaNameT (&comp->name));
+
 	if (comp->presence_state != SA_AMF_PRESENCE_INSTANTIATED) {
-		printf ("component terminated but not instantiated %s - %d\n",
+		dprintf ("component terminated but not instantiated %s - %d\n",
 			getSaNameT (&comp->name), comp->presence_state);
 		assert (0);
 		return (0);
 	}
 
-printf ("component name terminating %s\n", getSaNameT (&comp->name));
-printf ("component presence state %d\n", comp->presence_state);
+	dprintf ("component name terminating %s\n", getSaNameT (&comp->name));
+	dprintf ("component presence state %d\n", comp->presence_state);
 
 	res_lib_amf_componentterminatecallback.header.id = MESSAGE_RES_AMF_COMPONENTTERMINATECALLBACK;
 	res_lib_amf_componentterminatecallback.header.size = sizeof (struct res_lib_amf_componentterminatecallback);
@@ -746,7 +748,7 @@ printf ("component presence state %d\n", comp->presence_state);
 		invocation_create (
 		AMF_RESPONSE_COMPONENTTERMINATECALLBACK,
 		component_terminate_callback_data);
-printf ("Creating invocation %llu", 
+	dprintf ("Creating invocation %llu", 
 	(unsigned long long)res_lib_amf_componentterminatecallback.invocation);
 				        
 	openais_conn_send_response (
@@ -759,7 +761,7 @@ printf ("Creating invocation %llu",
 
 int clc_csi_remove_callback (struct amf_comp *comp)
 {
-	printf ("clc_tcsi_remove_callback\n");
+	dprintf ("clc_tcsi_remove_callback\n");
 	return (0);
 }
 
@@ -782,7 +784,7 @@ int clc_cli_cleanup (struct amf_comp *comp)
 
 	struct clc_command_run_data *clc_command_run_data;
 
-	printf ("clc_cli_instaniate\n");
+	dprintf ("clc_cli_instaniate\n");
 	clc_command_run_data = malloc (sizeof (struct clc_command_run_data));
 	clc_command_run_data->comp = comp;
 	clc_command_run_data->type = CLC_COMMAND_RUN_OPERATION_TYPE_CLEANUP;
@@ -797,7 +799,7 @@ int clc_cli_cleanup (struct amf_comp *comp)
 
 int clc_cli_cleanup_local (struct amf_comp *comp)
 {
-	printf ("clc_cli_cleanup_local\n");
+	dprintf ("clc_cli_cleanup_local\n");
 	return (0);
 }
 
@@ -805,7 +807,7 @@ int clc_instantiate (struct amf_comp *comp)
 {
 	int res;
 
-	printf ("clc instantiate for comp %s\n", getSaNameT (&comp->name));
+	dprintf ("clc instantiate for comp %s\n", getSaNameT (&comp->name));
 
 	presence_state_comp_set (comp, SA_AMF_PRESENCE_INSTANTIATING);
 	res = clc_interfaces[comp->comptype]->instantiate (comp);
@@ -816,8 +818,8 @@ int clc_terminate (struct amf_comp *comp)
 {
 	int res;
 
-	printf ("clc terminate for comp %s\n", getSaNameT (&comp->name));
-assert (0);
+	dprintf ("clc terminate for comp %s\n", getSaNameT (&comp->name));
+	assert (0);
 	operational_state_comp_set (comp, SA_AMF_OPERATIONAL_DISABLED);
 	presence_state_comp_set (comp, SA_AMF_PRESENCE_TERMINATING);
 
@@ -829,7 +831,7 @@ int clc_cleanup (struct amf_comp *comp)
 {
 	int res;
 
-	printf ("clc cleanup for comp %s\n", getSaNameT (&comp->name));
+	dprintf ("clc cleanup for comp %s\n", getSaNameT (&comp->name));
 	comp_healthcheck_deactivate (comp);
 	operational_state_comp_set (comp, SA_AMF_OPERATIONAL_DISABLED);
 	presence_state_comp_set (comp, SA_AMF_PRESENCE_TERMINATING);
@@ -847,6 +849,8 @@ static int amf_exec_init_fn (struct objdb_iface_ver0 *objdb)
 	int enabled = 0;
 	char *value;
 
+	log_init ("AMF");
+
 	objdb->object_find_reset (OBJECT_PARENT_HANDLE);
 	if (objdb->object_find (
 		    OBJECT_PARENT_HANDLE,
@@ -873,6 +877,8 @@ static int amf_exec_init_fn (struct objdb_iface_ver0 *objdb)
 	if (enabled) {
 		res = openais_amf_config_read (&error_string);
 		if (res == -1) {
+			dprintf("hej %s", "nisse");
+			TRACE8("hej %s", "nisse");
 			log_printf (LOG_LEVEL_ERROR, error_string);
 			return res;
 		}
@@ -930,7 +936,7 @@ int amf_lib_exit_fn (void *conn)
 	if (comp) {
 		comp->conn = 0;
 
-printf ("setting in exit fn to uninst for comp %p\n", comp);
+		dprintf ("setting in exit fn to uninst for comp %p\n", comp);
 		presence_state_comp_set (
 			comp,
 			SA_AMF_PRESENCE_UNINSTANTIATED);
@@ -946,7 +952,6 @@ printf ("setting in exit fn to uninst for comp %p\n", comp);
 
 static int amf_lib_init_fn (void *conn)
 {
-	log_printf (LOG_LEVEL_DEBUG, "Got request to initalize availability management framework service.\n"); 
 	struct amf_pd *amf_pd = (struct amf_pd *)openais_conn_private_data_get (conn);
 
 	list_init (&amf_pd->list);
@@ -1332,7 +1337,7 @@ void comp_healthcheck_deactivate (
 		healthcheck_active = list_entry (list,
 			struct healthcheck_active, list);
 
-		printf ("healthcheck deactivating %p\n", healthcheck_active);
+		dprintf ("healthcheck deactivating %p\n", healthcheck_active);
 		healthcheck_deactivate (healthcheck_active);
 	}
 }
@@ -1361,10 +1366,10 @@ void presence_state_comp_set (
 
 void readiness_state_comp_set (struct amf_comp *comp)
 {
-	printf ("inputs to readiness_state_comp_set\n");
-	printf ("\tunit readiness state %s\n",
+	dprintf ("inputs to readiness_state_comp_set\n");
+	dprintf ("\tunit readiness state %s\n",
 		readinessstate_ntoa (comp->unit->readiness_state));
-	printf ("\tcomp operational state %s\n",
+	dprintf ("\tcomp operational state %s\n",
 		operationalstate_ntoa (comp->unit->readiness_state));
 
 	/*
@@ -1378,7 +1383,7 @@ void readiness_state_comp_set (struct amf_comp *comp)
 	} else {
 		comp->readiness_state = SA_AMF_READINESS_OUT_OF_SERVICE;
 	}
-	printf ("readiness_state_comp_set (%s)\n",
+	dprintf ("readiness_state_comp_set (%s)\n",
 		operationalstate_ntoa (comp->operational_state));
 }
 
@@ -1419,14 +1424,14 @@ void csi_comp_set_callback (
 
     size_t char_legnth_of_csi_attrs=0;
     size_t num_of_csi_attrs=0;
-    printf("\t   Assigning CSI %s to component\n", getSaNameT (&csi->name));
+    dprintf("\t   Assigning CSI %s to component\n", getSaNameT (&csi->name));
 
     for (name_value_list = csi->name_value_head.next;
 	name_value_list != &csi->name_value_head;
 	name_value_list = name_value_list->next) {
 	num_of_csi_attrs++;
 	name_value = list_entry (name_value_list, struct amf_csi_name_value, csi_name_list);
-	printf("\t\tname = %s, value = %s\n", name_value->name, name_value->value);
+	dprintf("\t\tname = %s, value = %s\n", name_value->name, name_value->value);
 	char_legnth_of_csi_attrs += strlen(name_value->name);
 	char_legnth_of_csi_attrs += strlen(name_value->value);
 	char_legnth_of_csi_attrs += 2;
@@ -1577,11 +1582,9 @@ void csi_unit_set_callback (struct amf_unit *unit, struct amf_si *si)
 //    pg_create (csi_in->si, &pg);
     // TODO remove si from csi data structure
 
-    printf ("assigning SI %s to ",
-        getSaNameT (&si->name));
-
-    printf ("SU %s for components:\n",
-        getSaNameT (&unit->name));
+    dprintf ("assigning SI %s to SU %s for components:\n",
+			 getSaNameT (&si->name),
+			 getSaNameT (&unit->name));
 
     /*
     ** for each component in SU, find a CSI in the SI with the same type
@@ -1592,7 +1595,7 @@ void csi_unit_set_callback (struct amf_unit *unit, struct amf_si *si)
 
         comp = list_entry (complist, struct amf_comp, comp_list);
 
-        printf ("\t%s\n", getSaNameT (&comp->name));
+        dprintf ("\t%s\n", getSaNameT (&comp->name));
 
         int no_of_csi_types = 0;
         for (typenamelist = comp->csi_type_name_head.next;
@@ -1615,12 +1618,12 @@ void csi_unit_set_callback (struct amf_unit *unit, struct amf_si *si)
                         }
                 }
                 if (no_of_assignments == 0) {
-                    printf ("\t   No CSIs of type %s configured?!!\n",
+                    dprintf ("\t   No CSIs of type %s configured?!!\n",
                             getSaNameT (&type_name->name));
                 }
         }
         if (no_of_csi_types == 0) {
-            printf ("\t   No CSI types configured for %s ?!!\n",
+           dprintf ("\t   No CSI types configured for %s ?!!\n",
                     getSaNameT (&comp->name));
                 }
     }
@@ -1769,7 +1772,7 @@ void clc_unit_instantiate (struct amf_unit *unit)
 	struct list_head *list_comp;
 	struct amf_comp *comp;
 
-printf ("ZZZZZZZZZZZZZZZZZ clc_unit_instantitate\n");
+	dprintf ("ZZZZZZZZZZZZZZZZZ clc_unit_instantitate\n");
 	for (list_comp = unit->comp_head.next;
 		list_comp != &unit->comp_head;
 		list_comp = list_comp->next) {
@@ -1861,7 +1864,7 @@ void csi_unit_create (struct amf_unit *unit, struct amf_si *si,
 {
 	struct amf_csi *csi;
 
-	printf ("creating csi for si %p unit %p\n", si, unit);
+	dprintf ("creating csi for si %p unit %p\n", si, unit);
 	si->csi_count += 1;
 	csi = malloc (sizeof (struct amf_csi));
 	list_init (&csi->csi_list);
@@ -1881,10 +1884,8 @@ void csi_unit_create (struct amf_unit *unit, struct amf_si *si,
 void ha_state_unit_set (struct amf_unit *unit, struct amf_si *si,
 		SaAmfHAStateT ha_state)
 {
-
-	printf ("Assigning SI %s ", getSaNameT (&si->name));
-	printf ("to SU %s ", getSaNameT (&unit->name));
-	printf ("with hastate %s\n", hastate_ntoa (ha_state));
+	dprintf ("Assigning SI %s to SU %s with hastate %s\n",
+			 getSaNameT (&si->name), getSaNameT (&unit->name), hastate_ntoa (ha_state));
 
 	unit->requested_ha_state = ha_state;
 
@@ -2130,14 +2131,14 @@ void assign_sis (struct amf_group *group)
 	 * to assign based upon reduction procedure
 	 */
 	if ((inservice_count - active_sus_needed) < 0) {
-		printf ("assignment VI - partial assignment with SIs drop outs\n");
+		dprintf ("assignment VI - partial assignment with SIs drop outs\n");
 
 		su_active_assign = active_sus_needed;
 		su_standby_assign = 0;
 		su_spare_assign = 0;
 	} else
 	if ((inservice_count - active_sus_needed - standby_sus_needed) < 0) {
-		printf ("assignment V - partial assignment with reduction of standby units\n");
+		dprintf ("assignment V - partial assignment with reduction of standby units\n");
 
 		su_active_assign = active_sus_needed;
 		if (standby_sus_needed > units_for_standby) {
@@ -2148,33 +2149,33 @@ void assign_sis (struct amf_group *group)
 		su_spare_assign = 0;
 	} else
 	if ((group->maximum_standby_instances * units_for_standby) <= si_count (group)) {
-		printf ("IV: full assignment with reduction of active service units\n");
+		dprintf ("IV: full assignment with reduction of active service units\n");
 		su_active_assign = inservice_count - standby_sus_needed;
 		su_standby_assign = standby_sus_needed;
 		su_spare_assign = 0;
 	} else 
 	if ((group->maximum_active_instances * units_for_active) <= si_count (group)) {
 
-		printf ("III: full assignment with reduction of standby service units\n");
+		dprintf ("III: full assignment with reduction of standby service units\n");
 		su_active_assign = group->preferred_active_units;
 		su_standby_assign = units_for_standby;
 		su_spare_assign = 0;
 	} else
 	if (ii_spare == 0) {
-		printf ("II: full assignment with spare reduction\n");
+		dprintf ("II: full assignment with spare reduction\n");
 
 		su_active_assign = group->preferred_active_units;
 		su_standby_assign = group->preferred_standby_units;
 		su_spare_assign = 0;
 	} else {
-		printf ("I: full assignment with spares\n");
+		dprintf ("I: full assignment with spares\n");
 
 		su_active_assign = group->preferred_active_units;
 		su_standby_assign = group->preferred_standby_units;
 		su_spare_assign = ii_spare;
 	}
 
-	printf ("(inservice=%d) (assigning active=%d) (assigning standby=%d) (assigning spares=%d)\n",
+	dprintf ("(inservice=%d) (assigning active=%d) (assigning standby=%d) (assigning spares=%d)\n",
 		inservice_count, su_active_assign, su_standby_assign, su_spare_assign);
 	assign_nm_active (group, su_active_assign);
 	assign_nm_standby (group, su_standby_assign);
@@ -2182,10 +2183,8 @@ void assign_sis (struct amf_group *group)
 
 void readiness_state_unit_set (struct amf_unit *unit, SaAmfReadinessStateT readiness_state)
 {
-	printf ("Assigning unit %s ",
-		getSaNameT (&unit->name));
-	printf ("readiness state %s\n",
-		readinessstate_ntoa (readiness_state));
+	dprintf ("Assigning unit %s readiness state %s\n",
+			 getSaNameT (&unit->name), readinessstate_ntoa (readiness_state));
 
 	unit->readiness_state = readiness_state;
 	assign_sis (unit->amf_group);
@@ -2193,15 +2192,15 @@ void readiness_state_unit_set (struct amf_unit *unit, SaAmfReadinessStateT readi
 
 void presence_state_unit_set (struct amf_unit *unit, SaAmfPresenceStateT presence_state)
 {
-	printf ("Setting service unit presence state %s\n",
+	dprintf ("Setting service unit presence state %s\n",
 		presencestate_ntoa (presence_state));
 }
 
 
 static void escalation_policy_restart (struct amf_comp *comp)
 {
-	printf ("escalation_policy_restart %d\n", comp->unit->escalation_level);
-printf ("escalation policy restart uninsint %p\n", comp);
+	dprintf ("escalation_policy_restart %d\n", comp->unit->escalation_level);
+	dprintf ("escalation policy restart uninsint %p\n", comp);
 	presence_state_comp_set (
 		comp,
 		SA_AMF_PRESENCE_UNINSTANTIATED);
@@ -2295,7 +2294,7 @@ void healthcheck_activate (struct healthcheck_active *healthcheck_active)
 	res_lib_amf_healthcheckcallback.header.error = SA_AIS_OK;
 
 
-	log_printf (LOG_LEVEL_NOTICE, "sending healthcheck to component %s\n",
+	log_printf (LOG_LEVEL_DEBUG, "sending healthcheck to component %s\n",
 		getSaNameT (&healthcheck_active->comp->name));
 
 	res_lib_amf_healthcheckcallback.invocation =
@@ -2407,11 +2406,11 @@ void operational_state_unit_set (
 	SaAmfOperationalStateT operational_state)
 {
 	if (operational_state == unit->operational_state) {
-		printf ("Not assigning service unit new operational state - same state\n");
+		dprintf ("Not assigning service unit new operational state - same state\n");
 		return;
 	}
 	unit->operational_state = operational_state;
-	printf ("Service unit operational state set to %s\n",
+	dprintf ("Service unit operational state set to %s\n",
 		operationalstate_ntoa (operational_state));
 	if (operational_state == SA_AMF_OPERATIONAL_ENABLED) {
 		readiness_state_unit_set (unit,
@@ -2445,7 +2444,7 @@ static void message_handler_req_exec_amf_operational_state_comp_set (
 	comp = find_comp (&req_exec_amf_operational_state_comp_set->name);
 	comp->operational_state = req_exec_amf_operational_state_comp_set->operational_state;
 	
-	printf ("Setting component %s operational state to %s\n",
+	dprintf ("Setting component %s operational state to %s\n",
 		getSaNameT (&comp->name),
 		operationalstate_ntoa (comp->operational_state));
 	/*
@@ -2485,7 +2484,7 @@ static void message_handler_req_exec_amf_presence_state_comp_set (
 
 	comp = find_comp (&req_exec_amf_presence_state_comp_set->name);
 	if (req_exec_amf_presence_state_comp_set->presence_state == comp->presence_state) {
-		printf ("duplicate presence state set, not setting presence state\n");
+		dprintf ("duplicate presence state set, not setting presence state\n");
 		return;
 	}
 
@@ -2499,17 +2498,17 @@ static void message_handler_req_exec_amf_presence_state_comp_set (
 	if (req_exec_amf_presence_state_comp_set->presence_state == SA_AMF_PRESENCE_RESTARTING &&
 		comp->presence_state != SA_AMF_PRESENCE_UNINSTANTIATED) {
 
-printf ("restart presence state set even though not in terminating state\n");
+		dprintf ("restart presence state set even though not in terminating state\n");
 		return;
 	}
 
 	comp->presence_state = req_exec_amf_presence_state_comp_set->presence_state;
 	if (comp->presence_state == SA_AMF_PRESENCE_RESTARTING) {
-		printf ("SET TO RESTARTING instantiating now\n");
+		dprintf ("SET TO RESTARTING instantiating now\n");
 		clc_instantiate (comp);
 	}
 
-	printf ("Setting component %s presence state %s\n",
+	dprintf ("Setting component %s presence state %s\n",
 		getSaNameT (&comp->name),
 		presencestate_ntoa (comp->presence_state));
 	
@@ -2927,6 +2926,7 @@ static void message_handler_req_lib_amf_componenterrorreport (
 	struct amf_comp *comp;
 	SaAisErrorT error = SA_AIS_ERR_NOT_EXIST;
 
+	ENTER();
 	log_printf (LOG_LEVEL_NOTICE, "Handle : message_handler_req_lib_amf_componenterrorreport()\n");
 
 printf ("ERROR REPORT\n");
@@ -3006,7 +3006,7 @@ static void message_handler_req_lib_amf_response (void *conn, void *msg)
 	void *data;
 	SaAisErrorT error = SA_AIS_OK;
 
-	log_printf (LOG_LEVEL_DEBUG, "message_handler_req_lib_amf_response()\n");
+	ENTER();
 
 	res = invocation_get_and_destroy (req_lib_amf_response->invocation,
 		&interface, &data);
@@ -3017,7 +3017,6 @@ static void message_handler_req_lib_amf_response (void *conn, void *msg)
 		goto error_exit;
 	}
 
-	log_printf (LOG_LEVEL_DEBUG, "handling response connection interface %x\n", interface);
 	switch (interface) {
 	case AMF_RESPONSE_HEALTHCHECKCALLBACK:
 		healthcheck_active = (struct healthcheck_active *)data;
@@ -3037,7 +3036,7 @@ static void message_handler_req_lib_amf_response (void *conn, void *msg)
 	case AMF_RESPONSE_CSISETCALLBACK:
 		csi_set_callback_data = (struct csi_set_callback_data *)data;
 
-		printf ("csi callback executed from library.\n");
+		dprintf ("csi callback executed from library.\n");
 		csi_set_callback_data->comp->ha_state =
 			csi_set_callback_data->comp->unit->requested_ha_state;
 //		list_add (&csi_set_callback_data->comp->
@@ -3053,7 +3052,7 @@ static void message_handler_req_lib_amf_response (void *conn, void *msg)
 
 	case AMF_RESPONSE_CSIREMOVECALLBACK:
 		csi_remove_callback_data = (struct csi_remove_callback_data *)data;
-		printf ("response from removing the CSI\n");
+		dprintf ("response from removing the CSI\n");
 // AAAA
 		list_del (&csi_remove_callback_data->csi->si->unit_list);
 		list_del (&csi_remove_callback_data->csi->csi_list);
@@ -3064,7 +3063,7 @@ static void message_handler_req_lib_amf_response (void *conn, void *msg)
 	case AMF_RESPONSE_COMPONENTTERMINATECALLBACK:
 		component_terminate_callback_data = (struct component_terminate_callback_data *)data;
 
-		printf ("response from terminating component\n");
+		dprintf ("response from terminating component\n");
 		comp_healthcheck_deactivate (component_terminate_callback_data->comp);
 
 		escalation_policy_restart (component_terminate_callback_data->comp);
@@ -3083,6 +3082,7 @@ error_exit:
 	openais_conn_send_response (conn, &res_lib_amf_response,
 		sizeof (struct res_lib_amf_response));
 
+	LEAVE();
 }
 
 

+ 0 - 1
exec/amfconfig.c

@@ -47,7 +47,6 @@
 #include "util.h"
 #include "amfconfig.h"
 #include "mempool.h"
-#include "print.h"
 #include "totem.h"
 
 DECLARE_LIST_INIT (amf_groupHead);

+ 1 - 0
exec/cfg.c

@@ -189,6 +189,7 @@ __attribute__ ((constructor)) static void register_this_component (void) {
 
 static int cfg_exec_init_fn (struct objdb_iface_ver0 *objdb)
 {
+	log_init ("CFG");
 	return (0);
 }
 static void cfg_confchg_fn (

+ 2 - 0
exec/ckpt.c

@@ -1513,6 +1513,8 @@ int ckpt_checkpoint_close (struct saCkptCheckpoint *checkpoint) {
 
 static int ckpt_exec_init_fn (struct objdb_iface_ver0 *objdb)
 {
+	log_init ("CKPT");
+
 	/*
 	 *  Initialize the saved ring ID.
 	 */

+ 2 - 0
exec/clm.c

@@ -257,6 +257,8 @@ struct req_exec_clm_nodejoin {
 
 static int clm_exec_init_fn (struct objdb_iface_ver0 *objdb)
 {
+	log_init ("CLM");
+
 	memset (clusterNodes, 0, sizeof (SaClmClusterNodeT) * NODE_MAX);
 
 	/*

+ 2 - 0
exec/cpg.c

@@ -397,6 +397,8 @@ static int cpg_exec_init_fn (struct objdb_iface_ver0 *objdb)
 {
 	int i;
 
+	log_init ("CPG");
+
 	for (i=0; i<GROUP_HASH_SIZE; i++) {
 		list_init(&group_lists[i]);
 	}

+ 2 - 0
exec/lck.c

@@ -579,6 +579,8 @@ void lck_resource_cleanup_remove (
 
 static int lck_exec_init_fn (struct objdb_iface_ver0 *objdb)
 {
+	log_init ("LCK");
+
 	/*
 	 *  Initialize the saved ring ID.
 	 */

+ 9 - 7
exec/main.c

@@ -1169,6 +1169,8 @@ int main (int argc, char **argv)
 	void *config_p;
 	char *config_iface;
 	int res;
+ 	int totem_log_service;
+ 	log_init ("MAIN");
 
 	log_printf (LOG_LEVEL_NOTICE, "AIS Executive Service RELEASE %s\n", release_name);
 	log_printf (LOG_LEVEL_NOTICE, "Copyright (C) 2002-2006 MontaVista Software, Inc and contributors.\n");
@@ -1253,7 +1255,7 @@ int main (int argc, char **argv)
 		openais_exit_error (AIS_DONE_MAINCONFIGREAD);
 	}
 
-	res = log_setup (&error_string, main_config.logmode, main_config.logfile);
+	res = log_setup (&error_string, &main_config);
 	if (res == -1) {
 		log_printf (LOG_LEVEL_ERROR, error_string);
 		openais_exit_error (AIS_DONE_LOGSETUP);
@@ -1273,12 +1275,12 @@ int main (int argc, char **argv)
 	aisexec_mlockall ();
 
 	totem_config.totem_logging_configuration = totem_logging_configuration;
-
-	totem_config.totem_logging_configuration.log_level_security = mklog (LOG_LEVEL_SECURITY, LOG_SERVICE_GMI);
-	totem_config.totem_logging_configuration.log_level_error = mklog (LOG_LEVEL_ERROR, LOG_SERVICE_GMI);
-	totem_config.totem_logging_configuration.log_level_warning = mklog (LOG_LEVEL_WARNING, LOG_SERVICE_GMI);
-	totem_config.totem_logging_configuration.log_level_notice = mklog (LOG_LEVEL_NOTICE, LOG_SERVICE_GMI);
-	totem_config.totem_logging_configuration.log_level_debug = mklog (LOG_LEVEL_DEBUG, LOG_SERVICE_GMI);
+	totem_log_service = _log_init ("TOTEM");
+  	totem_config.totem_logging_configuration.log_level_security = mkpri (LOG_LEVEL_SECURITY, totem_log_service);
+	totem_config.totem_logging_configuration.log_level_error = mkpri (LOG_LEVEL_ERROR, totem_log_service);
+	totem_config.totem_logging_configuration.log_level_warning = mkpri (LOG_LEVEL_WARNING, totem_log_service);
+	totem_config.totem_logging_configuration.log_level_notice = mkpri (LOG_LEVEL_NOTICE, totem_log_service);
+	totem_config.totem_logging_configuration.log_level_debug = mkpri (LOG_LEVEL_DEBUG, totem_log_service);
 	totem_config.totem_logging_configuration.log_printf = internal_log_printf;
 
 	/*

+ 101 - 2
exec/mainconfig.c

@@ -69,14 +69,33 @@ static inline int objdb_get_string(struct objdb_iface_ver0 *objdb, unsigned int
 	return -1;
 }
 
-extern int openais_main_config_read (
+static inline void objdb_get_int (
+	struct objdb_iface_ver0 *objdb, unsigned int object_service_handle,
+	char *key, unsigned int *intvalue)
+{
+	char *value = NULL;
+
+	if (!objdb->object_key_get (object_service_handle,
+				    key,
+				    strlen (key),
+				    (void *)&value,
+				    NULL)) {
+		if (value) {
+			*intvalue = atoi(value);
+		}
+	}
+}
+
+int openais_main_config_read (
 	struct objdb_iface_ver0 *objdb,
 	char **error_string,
 	struct main_config *main_config)
 {
 	unsigned int object_service_handle;
+	unsigned int object_logger_handle;
 	char *value;
 	char *error_reason = error_string_response;
+	int i;
 
 	memset (main_config, 0, sizeof (struct main_config));
 
@@ -118,7 +137,7 @@ extern int openais_main_config_read (
 				main_config->logmode |= LOG_MODE_DEBUG;
 			} else
 			if (strcmp (value, "off") == 0) {
-		       		main_config->logmode &= ~LOG_MODE_DEBUG;
+				main_config->logmode &= ~LOG_MODE_DEBUG;
 			} else {
 				goto parse_error;
 			}
@@ -136,6 +155,86 @@ extern int openais_main_config_read (
 		if (!objdb_get_string (objdb,object_service_handle, "logfile", &value)) {
 			main_config->logfile = strdup (value);
 		}
+
+		if (!objdb_get_string (objdb,object_service_handle, "fileline", &value)) {
+			if (strcmp (value, "on") == 0) {
+				main_config->logmode |= LOG_MODE_FILELINE;
+			} else
+			if (strcmp (value, "off") == 0) {
+				main_config->logmode &= ~LOG_MODE_FILELINE;
+			} else {
+				goto parse_error;
+			}
+		}
+
+		while (	objdb->object_find (object_service_handle,
+									"logger",
+									strlen ("logger"),
+									&object_logger_handle) == 0) {
+			main_config->logger =
+				realloc(main_config->logger,
+						sizeof(struct logger_config) *
+						(main_config->loggers + 1));
+			i = main_config->loggers;
+			main_config->loggers++;
+			memset(&main_config->logger[i], 0, sizeof(struct logger_config));
+
+			if (!objdb_get_string (objdb, object_logger_handle, "ident", &value)) {
+				main_config->logger[i].ident = value;
+			}
+			else {
+				error_reason = "ident required for logger directive";
+				goto parse_error;
+			}
+			if (!objdb_get_string (objdb, object_logger_handle, "debug", &value)) {
+				if (strcmp (value, "on") == 0) {
+					main_config->logger[i].level = LOG_LEVEL_DEBUG;
+				} else
+				if (strcmp (value, "off") == 0) {
+					main_config->logger[i].level &= ~LOG_LEVEL_DEBUG;
+				} else {
+					goto parse_error;
+				}
+			}
+			if (!objdb_get_string (objdb, object_logger_handle, "tags", &value)) {
+				char *token = strtok (value, "|");
+
+				while (token != NULL) {
+					if (strcmp (token, "enter") == 0) {
+						main_config->logger[i].tags |= TAG_ENTER;
+					} else
+					if (strcmp (token, "leave") == 0) {
+						main_config->logger[i].tags |= TAG_LEAVE;
+					} else
+					if (strcmp (token, "trace1") == 0) {
+						main_config->logger[i].tags |= TAG_TRACE1;
+					} else
+					if (strcmp (token, "trace2") == 0) {
+						main_config->logger[i].tags |= TAG_TRACE2;
+					} else
+					if (strcmp (token, "trace3") == 0) {
+						main_config->logger[i].tags |= TAG_TRACE3;
+					}
+					if (strcmp (token, "trace4") == 0) {
+						main_config->logger[i].tags |= TAG_TRACE3;
+					}
+					if (strcmp (token, "trace5") == 0) {
+						main_config->logger[i].tags |= TAG_TRACE3;
+					}
+					if (strcmp (token, "trace6") == 0) {
+						main_config->logger[i].tags |= TAG_TRACE3;
+					}
+					if (strcmp (token, "trace7") == 0) {
+						main_config->logger[i].tags |= TAG_TRACE3;
+					}
+					if (strcmp (token, "trace8") == 0) {
+						main_config->logger[i].tags |= TAG_TRACE3;
+					}
+
+					token = strtok(NULL, "|");
+				}
+			}
+		}
 	}
 
 	objdb->object_find_reset (OBJECT_PARENT_HANDLE);

+ 10 - 0
exec/mainconfig.h

@@ -53,6 +53,13 @@ struct dynamic_service {
 };
 #define MAX_DYNAMIC_SERVICES 128
 
+struct logger_config {
+	char *ident;
+	int level;
+	int tags;
+	int mode;
+};
+
 struct main_config {
 	/*
 	 * logging
@@ -63,6 +70,9 @@ struct main_config {
 	/* user/group to run as */
 	char *user;
 	char *group;
+
+	int loggers;
+	struct logger_config *logger;
 };
 
 extern char *strstr_rs (const char *haystack, const char *needle);

+ 2 - 0
exec/msg.c

@@ -671,6 +671,8 @@ static struct queue_group_entry *queue_group_entry_find (
 
 static int msg_exec_init_fn (struct objdb_iface_ver0 *objdb)
 {
+	log_init ("MSG");
+
 	/*
 	 *  Initialize the saved ring ID.
 	 */

+ 103 - 206
exec/print.c

@@ -1,10 +1,15 @@
 /*
  * Copyright (c) 2002-2004 MontaVista Software, Inc.
  *
- * All rights reserved.
- *
  * Author: Steven Dake (sdake@mvista.com)
  *
+ * Copyright (c) 2006 Ericsson AB.
+ *		Author: Hans Feldt
+ *      Description: Added support for runtime installed loggers, tags tracing,
+ *                   and file & line printing.
+ *
+ * All rights reserved.
+ *
  * This software licensed under BSD license, the text of which follows:
  * 
  * Redistribution and use in source and binary forms, with or without
@@ -35,6 +40,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdarg.h>
+#include <sys/time.h>
 #include <time.h>
 #include <errno.h>
 #include <sys/types.h>
@@ -45,38 +51,16 @@
 #if defined(OPENAIS_BSD) || defined(OPENAIS_DARWIN)
 #include <sys/un.h>
 #endif
+#include <syslog.h>
 #include "print.h"
 #include "totemip.h"
 #include "../include/saAis.h"
 
-unsigned int logmode = LOG_MODE_STDERR | LOG_MODE_SYSLOG;
-char *logfile = 0;
+static unsigned int logmode = LOG_MODE_STDERR | LOG_MODE_SYSLOG;
+static char *logfile = 0;
 
-static char *log_levels[] = {
-	"[ASSERT  ]",
-	"[SECURITY]",
-	"[ERROR   ]",
-	"[WARNING ]",
-	"[NOTICE  ]",
-	"[DEBUG   ]"
-};
-
-static char *log_services[] = {
-	"[ASSER]",
-	"[MAIN ]",
-	"[TOTEM]",
-	"[CLM  ]",
-	"[AMF  ]",
-	"[CKPT ]",
-	"[EVT  ]",
-	"[LCK  ]",
-	"[MSG  ]",
-	"[EVS  ]",
-	"[SYNC ]",
-	"[YKD  ]",
-	"[CPG  ]",
-	"[SERV ]"
-};
+#define MAX_LOGGERS 32
+struct logger loggers[MAX_LOGGERS];
 
 #define LOG_MODE_DEBUG      1
 #define LOG_MODE_TIMESTAMP  2
@@ -84,235 +68,148 @@ static char *log_services[] = {
 #define LOG_MODE_SYSLOG     8
 #define LOG_MODE_STDERR     16
 
-int log_syslog_fd = -1;
-FILE *log_file_fp = 0;
+static FILE *log_file_fp = 0;
 
 struct sockaddr_un syslog_sockaddr = {
 	sun_family: AF_UNIX,
 	sun_path: "/dev/log"
 };
 
-int log_setup (char **error_string, int log_mode, char *log_file)
+static int logger_init (const char *ident, int tags, int level, int mode)
 {
-	static char error_string_response[512];
+	int i;
 
-	if (log_mode & LOG_MODE_SYSLOG && log_syslog_fd == -1) {
-		log_syslog_fd = socket (AF_UNIX, SOCK_DGRAM, 0);
-		if (log_syslog_fd == -1) {
-			sprintf (error_string_response,
-				"Can't create syslog socket for reason (%s).\n", strerror (errno));
-			*error_string = error_string_response;
-			return (-1);
+	for (i = 0; i < MAX_LOGGERS; i++) {
+		if (strcmp (loggers[i].ident, ident) == 0) {
+			break;
 		}
 	}
 
-	if (log_mode & LOG_MODE_FILE) {
-		log_file_fp = fopen (log_file, "a+");
-		if (log_file_fp == 0) {
-			sprintf (error_string_response,
-				"Can't open logfile '%s' for reason (%s).\n", logfile, strerror (errno));
-			*error_string = error_string_response;
-			return (-1);
+	if (i == MAX_LOGGERS) {
+		for (i = 0; i < MAX_LOGGERS; i++) {
+			if (strcmp (loggers[i].ident, "") == 0) {
+				strncpy (loggers[i].ident, ident, sizeof(loggers[i].ident));
+				loggers[i].tags = tags;
+				loggers[i].level = level;
+				if (logmode & LOG_MODE_DEBUG)
+					loggers[i].level = LOG_LEVEL_DEBUG;
+				loggers[i].mode = mode;
+				break;
+			}
 		}
 	}
-			
-	logmode = log_mode;
-	logfile = log_file;
 
-	return (0);
+	assert(i < MAX_LOGGERS);
+
+	return i;
+}
+
+int _log_init (const char *ident)
+{
+	assert (ident != NULL);
+
+	return logger_init (ident, TAG_LOG, LOG_LEVEL_INFO, 0);
 }
 
-void log_syslog (char *log_string) {
-	struct msghdr msg_log;
-	struct iovec iov_log;
-	int res;
+int log_setup (char **error_string, struct main_config *config)
+{
+	int i;
+	static char error_string_response[512];
 
-	if (log_syslog_fd == -1) {
-		log_syslog_fd = socket (AF_UNIX, SOCK_DGRAM, 0);
-	}
-	if (log_syslog_fd == -1) {
-		return;
-	}
-	iov_log.iov_base = log_string;
-	iov_log.iov_len = strlen (log_string) + 1;
+	logmode = config->logmode;
+	logfile = config->logfile;
 
-	msg_log.msg_iov = &iov_log;
-	msg_log.msg_iovlen = 1;
-	msg_log.msg_name = &syslog_sockaddr;
-	msg_log.msg_namelen = sizeof (syslog_sockaddr);
-	msg_log.msg_control = 0;
-	msg_log.msg_controllen = 0;
-	msg_log.msg_flags = 0;
+	if (config->logmode & LOG_MODE_FILE) {
+		log_file_fp = fopen (config->logfile, "a+");
+		if (log_file_fp == 0) {
+			sprintf (error_string_response,
+				"Can't open logfile '%s' for reason (%s).\n",
+					 config->logfile, strerror (errno));
+			*error_string = error_string_response;
+			return (-1);
+		}
+	}
 
-	res = sendmsg (log_syslog_fd, &msg_log, MSG_NOSIGNAL);
+	for (i = 0; i < config->loggers; i++) {
+		if (config->logger[i].level == 0)
+			config->logger[i].level = LOG_LEVEL_INFO;
+		config->logger[i].tags |= TAG_LOG;
+		logger_init (config->logger[i].ident,
+					 config->logger[i].tags,
+					 config->logger[i].level,
+					 config->logger[i].mode);
+	}
+			
+	return (0);
 }
 
-void internal_log_printf (int logclass, char *string, ...)
+static void _log_printf (char *file, int line, int priority,
+						char *format, va_list ap)
 {
-	va_list ap;
 	char newstring[4096];
 	char log_string[4096];
 	char char_time[512];
-	time_t curr_time;
-	int level;
-	int service;
+	struct timeval tv;
+	int level = LOG_LEVEL(priority);
+	int id = LOG_ID(priority);
+	int i = 0;
 
-	va_start (ap, string);
-	
-	assert (logmode != 0);
-	level = logclass >> 16;
-	service = logclass & 0xff;
+	assert (id < MAX_LOGGERS);
 
-	if (level == LOG_LEVEL_DEBUG && ((logmode & LOG_MODE_DEBUG) == 0)) {
-		return;
+	if (((logmode & LOG_MODE_FILE) || (logmode & LOG_MODE_STDERR)) &&
+		(logmode & LOG_MODE_TIMESTAMP)) {
+		gettimeofday (&tv, NULL);
+		strftime (char_time, sizeof (char_time), "%b %e %k:%M:%S",
+				  localtime (&tv.tv_sec));
+		i = sprintf (newstring, "%s.%06ld ", char_time, tv.tv_usec);
 	}
 
-	if (((logmode & LOG_MODE_FILE) || (logmode & LOG_MODE_STDERR)) && 
-		(logmode & LOG_MODE_TIMESTAMP)) {
-		curr_time = time (NULL);
-		strftime (char_time, sizeof (char_time), "%b %d %k:%M:%S", localtime (&curr_time));
-		sprintf (newstring, "%s %s %s %s", char_time, log_levels[level], log_services[service], string);
-	} else {
-		sprintf (newstring, "%s %s %s", log_levels[level], log_services[service], string);
+	if ((level == LOG_LEVEL_DEBUG) || (logmode & LOG_MODE_FILELINE)) {
+		sprintf (&newstring[i], "[%s:%u] %s", file, line, format);
+	} else {	
+		sprintf (&newstring[i], "[%-5s] %s", loggers[id].ident, format);
 	}
 	vsprintf (log_string, newstring, ap);
 
 	/*
 	 * Output the log data
 	 */
-	if (logmode & LOG_MODE_SYSLOG) {
-		log_syslog (log_string);
-	}
 	if (logmode & LOG_MODE_FILE && log_file_fp != 0) {
 		fprintf (log_file_fp, "%s", log_string);
 		fflush (log_file_fp);
 	}
 	if (logmode & LOG_MODE_STDERR) {
 		fprintf (stderr, "%s", log_string);
-		fflush (stderr);
 	}
 	fflush (stdout);
 
-	va_end(ap);
+	if (logmode & LOG_MODE_SYSLOG) {
+		syslog (level, &log_string[i]);
+	}
 }
 
-
-char *getSaNameT (SaNameT *name)
+void internal_log_printf (char *file, int line, int priority,
+						  char *format, ...)
 {
-	static char ret_name[300];
-
-	memset (ret_name, 0, sizeof (ret_name));
-	if (name->length > 299) {
-		memcpy (ret_name, name->value, 299);
-	} else {
-
-		memcpy (ret_name, name->value, name->length);
-	}
-	return (ret_name);
-}
+	int id = LOG_ID(priority);
+	va_list ap;
 
-#ifdef DEBUGA
-extern char *getSaClmNodeAddressT (SaClmNodeAddressT *nodeAddress) {
-	int i;
-	static char node_address[300];
-	int pos;
+	assert (id < MAX_LOGGERS);
 
-	for (i = 0, pos = 0; i < nodeAddress->length; i++) {
-		pos += sprintf (&node_address[pos], "%d.", nodeAddress->value[i]);
+	if (LOG_LEVEL(priority) > loggers[id].level) {
+		return;
 	}
-	return (node_address);
-}
-
-void printSaClmClusterNodeT (char *description, SaClmClusterNodeT *clusterNode) {
-	log_printf (LOG_LEVEL_NOTICE, "Node Information for %s:\n", description);
-
-	log_printf (LOG_LEVEL_NOTICE, "\tnode id is %x\n", (int)clusterNode->nodeId);
-
-	log_printf (LOG_LEVEL_NOTICE, "\tnode address is %s\n", getSaClmNodeAddressT (&clusterNode->nodeAddress));
 
-	log_printf (LOG_LEVEL_NOTICE, "\tnode name is %s.\n", getSaNameT (&clusterNode->nodeName));
-
-	log_printf (LOG_LEVEL_NOTICE, "\tcluster name is %s.\n", getSaNameT (&clusterNode->clusterName));
-
-	log_printf (LOG_LEVEL_NOTICE, "\tMember is %d\n", clusterNode->member);
-
-	log_printf (LOG_LEVEL_NOTICE, "\tTimestamp is %llx nanoseconds\n", clusterNode->bootTimestamp);
+	va_start (ap, format);
+	_log_printf (file, line, priority, format, ap);
+	va_end(ap);
 }
-#endif /* DEBUG */
-
 
-#ifdef CODE_COVERAGE_COMPILE_OUT
-void saAmfPrintGroups (void)
+void internal_log_printf2 (char *file, int line, int priority,
+						  char *format, ...)
 {
-	struct list_head *AmfGroupList;
-	struct list_head *AmfUnitList;
-	struct list_head *AmfComponentList;
-	struct list_head *AmfProtectionGroupList;
-	struct saAmfGroup *saAmfGroup;
-	struct saAmfUnit *AmfUnit;
-	struct saAmfComponent *AmfComponent;
-	struct saAmfProtectionGroup *AmfProtectionGroup;
-
-	for (AmfGroupList = saAmfGroupHead.next;
-		AmfGroupList != &saAmfGroupHead;
-		AmfGroupList = AmfGroupList->next) {
-
-		saAmfGroup = list_entry (AmfGroupList, 
-			struct saAmfGroup, saAmfGroupList);
-
-		log_printf (LOG_LEVEL_DEBUG, "group {\n");
-		log_printf (LOG_LEVEL_DEBUG, "\tname = ", getSaNameT (&saAmfGroup->name));
-		log_printf (LOG_LEVEL_DEBUG, "\tmodel = %d\n", saAmfGroup->model);
-		log_printf (LOG_LEVEL_DEBUG, "\tactive-units = %d\n", (int)saAmfGroup->saAmfActiveUnitsDesired);
-		log_printf (LOG_LEVEL_DEBUG, "\tbackup-units = %d\n", (int)saAmfGroup->saAmfStandbyUnitsDesired);
-
-		for (AmfUnitList = saAmfGroup->saAmfUnitHead.next;
-			AmfUnitList != &saAmfGroup->saAmfUnitHead;
-			AmfUnitList = AmfUnitList->next) {
-
-			AmfUnit = list_entry (AmfUnitList, 
-				struct saAmfUnit, saAmfUnitList);
-
-			log_printf (LOG_LEVEL_DEBUG, "\tunit {\n");
-			log_printf (LOG_LEVEL_DEBUG, "\t\tname = ", getSaNameT (&AmfUnit->name));
-
-			for (AmfComponentList = AmfUnit->saAmfComponentHead.next;
-				AmfComponentList != &AmfUnit->saAmfComponentHead;
-				AmfComponentList = AmfComponentList->next) {
-
-				AmfComponent = list_entry (AmfComponentList, 
-					struct saAmfComponent, saAmfComponentList);
-				log_printf (LOG_LEVEL_DEBUG, "\t\tcomponent {\n");
-				log_printf (LOG_LEVEL_DEBUG, "\t\t\tname = ", getSaNameT (&AmfComponent->name));
-				log_printf (LOG_LEVEL_DEBUG, "\t\t\tmodel = %d\n", AmfComponent->componentCapabilityModel);
-				log_printf (LOG_LEVEL_DEBUG, "\t\t}\n");
-			}
-			log_printf (LOG_LEVEL_DEBUG, "\t}\n");
-		}
-
-		for (AmfProtectionGroupList = saAmfGroup->saAmfProtectionGroupHead.next;
-			AmfProtectionGroupList != &saAmfGroup->saAmfProtectionGroupHead;
-			AmfProtectionGroupList = AmfProtectionGroupList->next) {
-
-			AmfProtectionGroup = list_entry (AmfProtectionGroupList, 
-				struct saAmfProtectionGroup, saAmfProtectionGroupList);
-
-			log_printf (LOG_LEVEL_DEBUG, "\tprotection {\n");
-			log_printf (LOG_LEVEL_DEBUG, "\t\tname = ", getSaNameT (&AmfProtectionGroup->name));
-
-			for (AmfComponentList = AmfProtectionGroup->saAmfMembersHead.next;
-				AmfComponentList != &AmfProtectionGroup->saAmfMembersHead;
-				AmfComponentList = AmfComponentList->next) {
-
-				AmfComponent = list_entry (AmfComponentList, 
-					struct saAmfComponent, saAmfProtectionGroupList);
-
-				log_printf (LOG_LEVEL_DEBUG, "\t\tmember = ", getSaNameT (&AmfComponent->name));
-			}
-			log_printf (LOG_LEVEL_DEBUG, "\t}\n");
-		}
-		log_printf (LOG_LEVEL_DEBUG, "}\n");
-	}
+	va_list ap;
+	va_start (ap, format);
+	_log_printf (file, line, priority, format, ap);
+	va_end(ap);
 }
-#endif /* CODE_COVERAGE_COMPILE_OUT */
-

+ 100 - 33
exec/print.h

@@ -1,10 +1,15 @@
 /*
  * Copyright (c) 2002-2004 MontaVista Software, Inc.
  *
- * All rights reserved.
- *
  * Author: Steven Dake (sdake@mvista.com)
  *
+ * Copyright (c) 2006 Ericsson AB.
+ *		Author: Hans Feldt
+ *      Description: Added support for runtime installed loggers, tags tracing,
+ *                   and file & line printing.
+ *
+ * All rights reserved.
+ *
  * This software licensed under BSD license, the text of which follows:
  * 
  * Redistribution and use in source and binary forms, with or without
@@ -34,55 +39,117 @@
 #ifndef PRINT_H_DEFINED
 #define PRINT_H_DEFINED
 
-#include "../include/saAis.h"
-#include "../include/saClm.h"
+#include <stdarg.h>
+#include <syslog.h>
+#include "mainconfig.h"
 
 #define LOG_MODE_DEBUG		1
 #define LOG_MODE_TIMESTAMP	2
 #define LOG_MODE_FILE		4
 #define LOG_MODE_SYSLOG		8
 #define LOG_MODE_STDERR		16
+#define LOG_MODE_FILELINE   32
 
 /*
- * If you change these, be sure to change log_levels in print.c
+ * Log levels, compliant with syslog and SA Forum Log spec.
  */
-#define LOG_LEVEL_SECURITY	1
-#define LOG_LEVEL_ERROR		2
-#define LOG_LEVEL_WARNING	3
-#define LOG_LEVEL_NOTICE	4
-#define LOG_LEVEL_DEBUG		5
+#define LOG_LEVEL_EMERG	    LOG_EMERG
+#define LOG_LEVEL_ALERT		LOG_ALERT
+#define LOG_LEVEL_CRIT		LOG_CRIT
+#define LOG_LEVEL_ERROR		LOG_ERR
+#define LOG_LEVEL_WARNING	LOG_WARNING
+#define LOG_LEVEL_SECURITY	LOG_WARNING // openais specific
+#define LOG_LEVEL_NOTICE	LOG_NOTICE
+#define LOG_LEVEL_INFO	    LOG_INFO
+#define LOG_LEVEL_DEBUG		LOG_DEBUG
 
 /*
- * If you change these, be sure to change log_services in print.c
- */
-#define LOG_SERVICE_MAIN	1
-#define LOG_SERVICE_GMI		2
-#define LOG_SERVICE_CLM		3
-#define LOG_SERVICE_AMF		4
-#define LOG_SERVICE_CKPT	5
-#define LOG_SERVICE_EVT		6
-#define LOG_SERVICE_LCK		7
-#define LOG_SERVICE_MSG		8
-#define LOG_SERVICE_EVS		9
-#define LOG_SERVICE_SYNC	10
-#define LOG_SERVICE_YKD		11
-#define LOG_SERVICE_CPG		12
-#define LOG_SERVICE_SERV	13
+** Log tags, used by trace macros, uses 32 bits => 32 different tags
+*/	
+#define TAG_LOG	    1<<0
+#define TAG_ENTER	1<<1
+#define TAG_LEAVE	1<<2
+#define TAG_TRACE1	1<<3
+#define TAG_TRACE2	1<<4
+#define TAG_TRACE3	1<<5
+#define TAG_TRACE4	1<<6
+#define TAG_TRACE5	1<<7
+#define TAG_TRACE6	1<<8
+#define TAG_TRACE7	1<<9
+#define TAG_TRACE8	1<<10
+
+struct logger {
+	char ident[6];
+	int level;
+	int tags;
+	int mode;
+};
+
+extern struct logger loggers[];
+
+/*
+** The logger_identifier variable holds the numerical identifier for a logger
+** obtained with log_init() and hides it from the logger.
+*/
+static int logger_identifier __attribute__((unused));
+
+extern void internal_log_printf (char *file, int line, int priority, char *format, ...);
+extern void internal_log_printf2 (char *file, int line, int priority, char *format, ...);
+
+#define LEVELMASK 0x07                 /* 3 bits */
+#define LOG_LEVEL(p) ((p) & LEVELMASK)
+#define IDMASK (0x3f << 3)             /* 6 bits */
+#define LOG_ID(p)  (((p) & IDMASK) >> 3)
+
+#define _mkpri(lvl, id) (((id) << 3) | (lvl))
+
+static inline int mkpri (int level, int id)
+{
+	return _mkpri (level, id);
+}
 
-extern void internal_log_printf (int logclass, char *format, ...);
+int log_setup (char **error_string, struct main_config *config);
 
-#define mklog(level,service) ((level << 16) | (service))
+extern int _log_init (const char *ident);
+static inline void log_init (const char *ident)
+{
+	logger_identifier = _log_init (ident);
+}
 
-#define log_printf(level,format,args...) { internal_log_printf (mklog(level,LOG_SERVICE),format,##args); }
+#define log_printf(lvl, format, args...) do { \
+    if ((lvl) <= loggers[logger_identifier].level)	{ \
+		internal_log_printf2 (__FILE__, __LINE__, _mkpri ((lvl), logger_identifier), format, ##args);  \
+    } \
+} while(0)
 
-int log_setup (char **error_string, int log_mode, char *log_file);
+#define dprintf(format, args...) do { \
+    if (LOG_LEVEL_DEBUG <= loggers[logger_identifier].level)	{ \
+		internal_log_printf2 (__FILE__, __LINE__, _mkpri (LOG_LEVEL_DEBUG, logger_identifier), format, ##args);  \
+    } \
+} while(0)
 
-extern char *getSaNameT (SaNameT *name);
+#define ENTER() do { \
+    if ((LOG_LEVEL_DEBUG <= loggers[logger_identifier].level) && (TAG_ENTER & loggers[logger_identifier].tags))	{ \
+        internal_log_printf2 (__FILE__, __LINE__, _mkpri (LOG_LEVEL_DEBUG, logger_identifier), ">%s\n", __FUNCTION__); \
+    } \
+} while(0)
 
-extern char *getSaClmNodeAddressT (SaClmNodeAddressT *nodeAddress);
+#define ENTER_ARGS(format, args...) do { \
+    if ((LOG_LEVEL_DEBUG <= loggers[logger_identifier].level) && (TAG_ENTER & loggers[logger_identifier].tags))	{ \
+        internal_log_printf2 (__FILE__, __LINE__, _mkpri (LOG_LEVEL_DEBUG, logger_identifier), ">%s: " format, __FUNCTION__, ##args); \
+    } \
+} while(0)
 
-extern void printSaClmClusterNodeT (char *description, SaClmClusterNodeT *clusterNode);
+#define LEAVE() do { \
+    if ((LOG_LEVEL_DEBUG <= loggers[logger_identifier].level) && (TAG_LEAVE & loggers[logger_identifier].tags))	{ \
+        internal_log_printf2 (__FILE__, __LINE__, _mkpri (LOG_LEVEL_DEBUG, logger_identifier), "<%s\n", __FUNCTION__); \
+    } \
+} while(0)
 
-extern void saAmfPrintGroups (void);
+#define TRACE8(format, args...) do { \
+    if ((LOG_LEVEL_DEBUG <= loggers[logger_identifier].level) && (TAG_TRACE8 & loggers[logger_identifier].tags)) { \
+		internal_log_printf2 (__FILE__, __LINE__, _mkpri (LOG_LEVEL_DEBUG, logger_identifier), format, ##args);  \
+    } \
+} while(0)
 
 #endif /* PRINT_H_DEFINED */

+ 2 - 0
exec/service.c

@@ -158,6 +158,8 @@ int openais_service_default_objdb_set (struct objdb_iface_ver0 *objdb)
 		}
 	}
 
+	log_init ("SERV");
+
 	for (i = 0; i < sizeof (default_services) / sizeof (struct default_service); i++) {
 		openais_service_objdb_add (objdb, default_services[i].name, default_services[i].ver);
 	}

+ 2 - 0
exec/sync.c

@@ -269,6 +269,8 @@ void sync_register (
 	unsigned int res;
 	unsigned int ykd_handle;
 
+ 	log_init ("SYNC");
+
 	totempg_groups_initialize (
 		&sync_group_handle,
 		sync_deliver_fn,

+ 1 - 1
exec/totem.h

@@ -69,7 +69,7 @@ struct totem_interface {
 };
 
 struct totem_logging_configuration {
-	void (*log_printf) (int, char *, ...);
+	void (*log_printf) (char *, int, int, char *, ...);
 	int log_level_security;
 	int log_level_error;
 	int log_level_warning;

+ 15 - 12
exec/totemnet.c

@@ -138,7 +138,7 @@ struct totemnet_instance {
 
 	int totemnet_log_level_debug;
 
-	void (*totemnet_log_printf) (int level, char *format, ...);
+	void (*totemnet_log_printf) (char *file, int line, int level, char *format, ...);
 
 	totemnet_handle handle;
 
@@ -224,6 +224,9 @@ static void totemnet_instance_initialize (struct totemnet_instance *instance)
 	instance->my_memb_entries = 1;
 }
 
+#define log_printf(level, format, args...) \
+    instance->totemnet_log_printf (__FILE__, __LINE__, level, format, ##args)
+
 static int authenticate_and_decrypt (
 	struct totemnet_instance *instance,
 	struct iovec *iov)
@@ -271,7 +274,7 @@ static int authenticate_and_decrypt (
 	hmac_done (&instance->totemnet_hmac_state, digest_comparison, &len);
 
 	if (memcmp (digest_comparison, header->hash_digest, len) != 0) {
-		instance->totemnet_log_printf (instance->totemnet_log_level_security, "Received message has invalid digest... ignoring.\n");
+		log_printf (instance->totemnet_log_level_security, "Received message has invalid digest... ignoring.\n");
 		res = -1;
 		return (-1);
 	}
@@ -644,7 +647,7 @@ static int net_deliver_fn (
 	if ((instance->totem_config->secauth == 1) &&
 		(bytes_received < sizeof (struct security_header))) {
 
-		instance->totemnet_log_printf (instance->totemnet_log_level_security, "Received message is too short...  ignoring %d.\n", bytes_received);
+		log_printf (instance->totemnet_log_level_security, "Received message is too short...  ignoring %d.\n", bytes_received);
 		return (0);
 	}
 	totemip_sockaddr_to_totemip_convert(&system_from, &from_address);
@@ -659,7 +662,7 @@ static int net_deliver_fn (
 
 		res = authenticate_and_decrypt (instance, iovec);
 		if (res == -1) {
-			instance->totemnet_log_printf (instance->totemnet_log_level_security,
+			log_printf (instance->totemnet_log_level_security,
 				"Invalid packet data\n");
 			iovec->iov_len = FRAME_SIZE_MAX;
 			return 0;
@@ -817,7 +820,7 @@ static void timer_function_netif_check_timeout (
 	 */
 	if (instance->netif_bind_state == BIND_STATE_REGULAR) {
 		if (instance->netif_state_report & NETIF_STATE_REPORT_UP) {
-			instance->totemnet_log_printf (instance->totemnet_log_level_notice,
+			log_printf (instance->totemnet_log_level_notice,
 				"The network interface [%s] is now up.\n",
 				totemip_print (&instance->totem_interface->boundto));
 			instance->netif_state_report = NETIF_STATE_REPORT_DOWN;
@@ -836,7 +839,7 @@ static void timer_function_netif_check_timeout (
 
 	} else {		
 		if (instance->netif_state_report & NETIF_STATE_REPORT_DOWN) {
-			instance->totemnet_log_printf (instance->totemnet_log_level_notice,
+			log_printf (instance->totemnet_log_level_notice,
 				"The network interface is down.\n");
 			instance->totemnet_iface_change_fn (instance->context, &instance->my_id);
 		}
@@ -863,7 +866,7 @@ static void totemnet_traffic_control_set(struct totemnet_instance *instance, int
     int prio = 6; /* TC_PRIO_INTERACTIVE */
 
     if (setsockopt(sock, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(int)))
-		instance->totemnet_log_printf (instance->totemnet_log_level_warning, "Could not set traffic priority. (%s)\n", strerror (errno));
+		log_printf (instance->totemnet_log_level_warning, "Could not set traffic priority. (%s)\n", strerror (errno));
 #endif
 }
 
@@ -901,7 +904,7 @@ static int totemnet_build_sockets_ip (
 	totemip_nosigpipe (sockets->mcast_recv);
 	res = fcntl (sockets->mcast_recv, F_SETFL, O_NONBLOCK);
 	if (res == -1) {
-		instance->totemnet_log_printf (instance->totemnet_log_level_warning, "Could not set non-blocking operation on multicast socket: %s\n", strerror (errno));
+		log_printf (instance->totemnet_log_level_warning, "Could not set non-blocking operation on multicast socket: %s\n", strerror (errno));
 		return (-1);
 	}
 
@@ -937,7 +940,7 @@ static int totemnet_build_sockets_ip (
 	totemip_nosigpipe (sockets->mcast_send);
 	res = fcntl (sockets->mcast_send, F_SETFL, O_NONBLOCK);
 	if (res == -1) {
-		instance->totemnet_log_printf (instance->totemnet_log_level_warning, "Could not set non-blocking operation on multicast socket: %s\n", strerror (errno));
+		log_printf (instance->totemnet_log_level_warning, "Could not set non-blocking operation on multicast socket: %s\n", strerror (errno));
 		return (-1);
 	}
 
@@ -970,7 +973,7 @@ static int totemnet_build_sockets_ip (
 	totemip_nosigpipe (sockets->token);
 	res = fcntl (sockets->token, F_SETFL, O_NONBLOCK);
 	if (res == -1) {
-		instance->totemnet_log_printf (instance->totemnet_log_level_warning, "Could not set non-blocking operation on token socket: %s\n", strerror (errno));
+		log_printf (instance->totemnet_log_level_warning, "Could not set non-blocking operation on token socket: %s\n", strerror (errno));
 		return (-1);
 	}
 
@@ -1004,13 +1007,13 @@ static int totemnet_build_sockets_ip (
 
 	res = getsockopt (sockets->mcast_recv, SOL_SOCKET, SO_RCVBUF, &recvbuf_size, &optlen);
 	if (res == 0) {
-	 	instance->totemnet_log_printf (instance->totemnet_log_level_notice,
+	 	log_printf (instance->totemnet_log_level_notice,
 			"Receive multicast socket recv buffer size (%d bytes).\n", recvbuf_size);
 	}
 
 	res = getsockopt (sockets->mcast_send, SOL_SOCKET, SO_SNDBUF, &sendbuf_size, &optlen);
 	if (res == 0) {
-		instance->totemnet_log_printf (instance->totemnet_log_level_notice,
+		log_printf (instance->totemnet_log_level_notice,
 			"Transmit multicast socket send buffer size (%d bytes).\n", sendbuf_size);
 	}
 

+ 5 - 3
exec/totempg.c

@@ -148,7 +148,7 @@ static int totempg_log_level_error;
 static int totempg_log_level_warning;
 static int totempg_log_level_notice;
 static int totempg_log_level_debug;
-static void (*totempg_log_printf) (int level, char *format, ...) = NULL;
+static void (*totempg_log_printf) (char *file, int line, int level, char *format, ...) = NULL;
 
 struct totem_config *totempg_totem_config;
 
@@ -214,6 +214,8 @@ static pthread_mutex_t totempg_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 static pthread_mutex_t callback_token_mutex = PTHREAD_MUTEX_INITIALIZER;
 
+#define log_printf(level, format, args...) \
+    totempg_log_printf (__FILE__, __LINE__, level, format, ##args)
 
 static struct assembly *find_assembly (struct totem_ip_address *addr)
 {
@@ -508,7 +510,7 @@ static void totempg_deliver_fn (
 	if (continuation) {
 
 		if (continuation != assembly->last_frag_num) {
-			totempg_log_printf (totempg_log_level_error,
+			log_printf (totempg_log_level_error,
 				"Message continuation doesn't match previous frag e: %u - a: %u\n",
 				assembly->last_frag_num, continuation);
 			continuation = 0;
@@ -516,7 +518,7 @@ static void totempg_deliver_fn (
 
 		if ((assembly->index == 0) ||
 							(!continuation && assembly->index)) {
-			totempg_log_printf (totempg_log_level_error,
+			log_printf (totempg_log_level_error,
 				"Throwing away broken message: continuation %u, index %u\n",
 				continuation, assembly->index);
 			continuation = 0;

+ 4 - 1
exec/totemrrp.c

@@ -168,7 +168,7 @@ struct totemrrp_instance {
 
 	int totemrrp_log_level_debug;
 
-	void (*totemrrp_log_printf) (int level, char *format, ...);
+	void (*totemrrp_log_printf) (char *file, int line, int level, char *format, ...);
 
 	totemrrp_handle handle;
 
@@ -291,6 +291,9 @@ static struct hdb_handle_database totemrrp_instance_database = {
 	.iterator	= 0
 };
 
+#define log_printf(level, format, args...) \
+    instance->totemrrp_log_printf (__FILE__, __LINE__, level, format, ##args)
+
 struct passive_instance *passive_instance_initialize (
 	int interface_count)
 {

+ 64 - 61
exec/totemsrp.c

@@ -407,7 +407,7 @@ struct totemsrp_instance {
 
 	int totemsrp_log_level_debug;
 
-	void (*totemsrp_log_printf) (int level, char *format, ...);
+	void (*totemsrp_log_printf) (char *file, int line, int level, char *format, ...);
 
 	enum memb_state memb_state;
 
@@ -586,6 +586,9 @@ struct message_handlers totemsrp_message_handlers = {
 	}
 };
 
+#define log_printf(level, format, args...) \
+    instance->totemsrp_log_printf (__FILE__, __LINE__, level, format, ##args)
+
 void totemsrp_instance_initialize (struct totemsrp_instance *instance)
 {
 	memset (instance, 0, sizeof (struct totemsrp_instance));
@@ -686,32 +689,32 @@ int totemsrp_initialize (
 	/*
 	 * Display totem configuration
 	 */
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+	log_printf (instance->totemsrp_log_level_notice,
 		"Token Timeout (%d ms) retransmit timeout (%d ms)\n",
 		totem_config->token_timeout, totem_config->token_retransmit_timeout);
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+	log_printf (instance->totemsrp_log_level_notice,
 		"token hold (%d ms) retransmits before loss (%d retrans)\n",
 		totem_config->token_hold_timeout, totem_config->token_retransmits_before_loss_const);
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+	log_printf (instance->totemsrp_log_level_notice,
 		"join (%d ms) consensus (%d ms) merge (%d ms)\n",
 		totem_config->join_timeout, totem_config->consensus_timeout,
 		totem_config->merge_timeout);
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+	log_printf (instance->totemsrp_log_level_notice,
 		"downcheck (%d ms) fail to recv const (%d msgs)\n",
 		totem_config->downcheck_timeout, totem_config->fail_to_recv_const);
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+	log_printf (instance->totemsrp_log_level_notice,
 		"seqno unchanged const (%d rotations) Maximum network MTU %d\n", totem_config->seqno_unchanged_const, totem_config->net_mtu);
 
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+	log_printf (instance->totemsrp_log_level_notice,
 		"window size per rotation (%d messages) maximum messages per rotation (%d messages)\n",
 		totem_config->window_size, totem_config->max_messages);
 
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+	log_printf (instance->totemsrp_log_level_notice,
 		"send threads (%d threads)\n", totem_config->threads);
 
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+	log_printf (instance->totemsrp_log_level_notice,
 		"heartbeat_failures_allowed (%d)\n", totem_config->heartbeat_failures_allowed);
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+	log_printf (instance->totemsrp_log_level_notice,
 		"max_network_delay (%d ms)\n", totem_config->max_network_delay);
 
 
@@ -732,7 +735,7 @@ int totemsrp_initialize (
 	instance->use_heartbeat = 1;
 
 	if ( totem_config->heartbeat_failures_allowed == 0 ) {
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+		log_printf (instance->totemsrp_log_level_notice,
 			"HeartBeat is Disabled. To enable set heartbeat_failures_allowed > 0\n");
 		instance->use_heartbeat = 0;
 	}
@@ -743,18 +746,18 @@ int totemsrp_initialize (
 				+ totem_config->max_network_delay;
 
 		if (instance->heartbeat_timeout >= totem_config->token_timeout) {
-			instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+			log_printf (instance->totemsrp_log_level_notice,
 				"total heartbeat_timeout (%d ms) is not less than token timeout (%d ms)\n", 
 				instance->heartbeat_timeout,
 				totem_config->token_timeout);
-			instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+			log_printf (instance->totemsrp_log_level_notice,
 				"heartbeat_timeout = heartbeat_failures_allowed * token_retransmit_timeout + max_network_delay\n");
-			instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+			log_printf (instance->totemsrp_log_level_notice,
 				"heartbeat timeout should be less than the token timeout. HeartBeat is Diabled !!\n");
 			instance->use_heartbeat = 0;
 		}
 		else {
-			instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+			log_printf (instance->totemsrp_log_level_notice,
                 		"total heartbeat_timeout (%d ms)\n", instance->heartbeat_timeout);
 		}
 	}
@@ -1086,7 +1089,7 @@ static void old_ring_state_save (struct totemsrp_instance *instance)
 		instance->old_ring_state_saved = 1;
 		instance->old_ring_state_aru = instance->my_aru;
 		instance->old_ring_state_high_seq_received = instance->my_high_seq_received;
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+		log_printf (instance->totemsrp_log_level_notice,
 			"Saving state aru %x high seq received %x\n",
 			instance->my_aru, instance->my_high_seq_received);
 	}
@@ -1112,7 +1115,7 @@ static void ring_state_restore (struct totemsrp_instance *instance)
 		totemip_zero_set(&instance->my_ring_id.rep);
 		instance->my_aru = instance->old_ring_state_aru;
 		instance->my_high_seq_received = instance->old_ring_state_high_seq_received;
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+		log_printf (instance->totemsrp_log_level_notice,
 			"Restoring instance->my_aru %x my high seq received %x\n",
 			instance->my_aru, instance->my_high_seq_received);
 	}
@@ -1205,7 +1208,7 @@ static void timer_function_orf_token_timeout (void *data)
 {
 	struct totemsrp_instance *instance = (struct totemsrp_instance *)data;
 
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+	log_printf (instance->totemsrp_log_level_notice,
 		"The token was lost in state %d from timer %x\n", instance->memb_state, data);
 	switch (instance->memb_state) {
 		case MEMB_STATE_OPERATIONAL:
@@ -1232,7 +1235,7 @@ static void timer_function_orf_token_timeout (void *data)
 static void timer_function_heartbeat_timeout (void *data)
 {
 	struct totemsrp_instance *instance = (struct totemsrp_instance *)data;
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+	log_printf (instance->totemsrp_log_level_notice,
 		"HeartBeat Timer expired Invoking token loss mechanism in state %d \n", instance->memb_state);
 	timer_function_orf_token_timeout(data);
 }
@@ -1280,7 +1283,7 @@ static void deliver_messages_from_recovery_to_regular (struct totemsrp_instance
 	void *ptr;
 	struct mcast *mcast;
 
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_debug,
+	log_printf (instance->totemsrp_log_level_debug,
 		"recovery to regular %x-%x\n", SEQNO_START_MSG + 1, instance->my_aru);
 
 	range = instance->my_aru - SEQNO_START_MSG;
@@ -1330,7 +1333,7 @@ static void deliver_messages_from_recovery_to_regular (struct totemsrp_instance
 			}
 		}
 
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_debug,
+		log_printf (instance->totemsrp_log_level_debug,
 			"comparing if ring id is for this processors old ring seqno %d\n",
 			 mcast->seq);
 
@@ -1352,7 +1355,7 @@ static void deliver_messages_from_recovery_to_regular (struct totemsrp_instance
 				}
 			}
 		} else {
-			instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+			log_printf (instance->totemsrp_log_level_notice,
 				"-not adding msg with seq no %x\n", mcast->seq);
 		}
 	}
@@ -1373,7 +1376,7 @@ static void memb_state_operational_enter (struct totemsrp_instance *instance)
 	ring_reset (instance);
 	deliver_messages_from_recovery_to_regular (instance);
 
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_debug,
+	log_printf (instance->totemsrp_log_level_debug,
 		"Delivering to app %x to %x\n",
 		instance->my_high_delivered + 1, instance->old_ring_state_high_seq_received);
 
@@ -1440,7 +1443,7 @@ static void memb_state_operational_enter (struct totemsrp_instance *instance)
 	instance->my_high_delivered = instance->my_aru;
 // TODO the recovery messages are leaked
 
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+	log_printf (instance->totemsrp_log_level_notice,
 		"entering OPERATIONAL state.\n");
 	instance->memb_state = MEMB_STATE_OPERATIONAL;
 
@@ -1489,7 +1492,7 @@ static void memb_state_gather_enter (struct totemsrp_instance *instance)
 
 	memb_consensus_set (instance, &instance->my_id);
 
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+	log_printf (instance->totemsrp_log_level_notice,
 		"entering GATHER state.\n");
 
 	instance->memb_state = MEMB_STATE_GATHER;
@@ -1525,7 +1528,7 @@ static void memb_state_commit_enter (
 	reset_token_timeout (instance); // REVIEWED
 	reset_token_retransmit_timeout (instance); // REVIEWED
 
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+	log_printf (instance->totemsrp_log_level_notice,
 		"entering COMMIT state.\n");
 
 	instance->memb_state = MEMB_STATE_COMMIT;
@@ -1556,7 +1559,7 @@ static void memb_state_recovery_enter (
 	addr = (struct totem_ip_address *)commit_token->end_of_commit_token;
 	memb_list = (struct memb_commit_token_memb_entry *)(addr + commit_token->addr_entries);
 
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+	log_printf (instance->totemsrp_log_level_notice,
 		"entering RECOVERY state.\n");
 
 	instance->my_high_ring_delivered = 0;
@@ -1590,14 +1593,14 @@ static void memb_state_recovery_enter (
 		instance->my_trans_memb_list, &instance->my_trans_memb_entries);
 
 	for (i = 0; i < instance->my_new_memb_entries; i++) {
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+		log_printf (instance->totemsrp_log_level_notice,
 			"position [%d] member %s:\n", i, totemip_print (&addr[i]));
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+		log_printf (instance->totemsrp_log_level_notice,
 			"previous ring seq %lld rep %s\n",
 			memb_list[i].ring_id.seq,
 			totemip_print (&memb_list[i].ring_id.rep));
 
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+		log_printf (instance->totemsrp_log_level_notice,
 			"aru %x high delivered %x received flag %d\n",
 			memb_list[i].aru,
 			memb_list[i].high_delivered,
@@ -1645,7 +1648,7 @@ static void memb_state_recovery_enter (
 		/*
 		 * Copy all old ring messages to instance->retrans_message_queue
 		 */
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+		log_printf (instance->totemsrp_log_level_notice,
 			"copying all old ring messages from %x-%x.\n",
 			low_ring_aru + 1, instance->old_ring_state_high_seq_received);
 		strcpy (not_originated, "Not Originated for recovery: ");
@@ -1688,14 +1691,14 @@ static void memb_state_recovery_enter (
 				sort_queue_item->iov_len);
 			queue_item_add (&instance->retrans_message_queue, &message_item);
 		}
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+		log_printf (instance->totemsrp_log_level_notice,
 			"Originated %d messages in RECOVERY.\n", messages_originated);
 		strcat (not_originated, "\n");
 		strcat (is_originated, "\n");
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_notice, is_originated);
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_notice, not_originated);
+		log_printf (instance->totemsrp_log_level_notice, is_originated);
+		log_printf (instance->totemsrp_log_level_notice, not_originated);
 	} else {
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+		log_printf (instance->totemsrp_log_level_notice,
 			"Did not need to originate any messages in recovery.\n");
 	}
 
@@ -1751,7 +1754,7 @@ int totemsrp_mcast (
 	}
 	
 	if (queue_is_full (&instance->new_message_queue)) {
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_warning, "queue full\n");
+		log_printf (instance->totemsrp_log_level_warning, "queue full\n");
 		return (-1);
 	}
 	for (j = 0, i = 0; i < iov_len; i++) {
@@ -1797,7 +1800,7 @@ int totemsrp_mcast (
 
 	message_item.iov_len = iov_len;
 
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_debug, "mcasted message added to pending queue\n");
+	log_printf (instance->totemsrp_log_level_debug, "mcasted message added to pending queue\n");
 	queue_item_add (&instance->new_message_queue, &message_item);
 
 	hdb_handle_put (&totemsrp_instance_database, handle);
@@ -1864,7 +1867,7 @@ static int orf_token_remcast (
 
 	res = sq_in_range (sort_queue, seq);
 	if (res == 0) {
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_debug, "sq not in range\n");
+		log_printf (instance->totemsrp_log_level_debug, "sq not in range\n");
 		return (-1);
 	}
 	
@@ -1900,7 +1903,7 @@ static void messages_free (
 	unsigned int release_to;
 	unsigned int range = 0;
 
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_debug,
+	log_printf (instance->totemsrp_log_level_debug,
 		"aru %x last aru %x my high delivered %x last released %x\n",
 		token_aru, instance->my_last_aru, instance->my_high_delivered, instance->last_released);
 
@@ -1944,7 +1947,7 @@ static void messages_free (
 	instance->last_released += range;
 
  	if (log_release) {
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_debug,
+		log_printf (instance->totemsrp_log_level_debug,
 			"releasing messages up to and including %x\n", release_to);
 	}
 }
@@ -2020,7 +2023,7 @@ static int orf_token_mcast (
 			(instance->memb_state == MEMB_STATE_GATHER ||
 			instance->memb_state == MEMB_STATE_COMMIT)) {
 
-			instance->totemsrp_log_printf (instance->totemsrp_log_level_debug,
+			log_printf (instance->totemsrp_log_level_debug,
 				"not multicasting at seqno is %d\n",
 			token->seq);
 			return (0);
@@ -2107,14 +2110,14 @@ static int orf_token_rtr (
 	
 	strcpy (retransmit_msg, "Retransmit List: ");
 	if (orf_token->rtr_list_entries) {
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_debug,
+		log_printf (instance->totemsrp_log_level_debug,
 			"Retransmit List %d\n", orf_token->rtr_list_entries);
 		for (i = 0; i < orf_token->rtr_list_entries; i++) {
 			sprintf (value, "%x ", rtr_list[i].seq);
 			strcat (retransmit_msg, value);
 		}
 		strcat (retransmit_msg, "\n");
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+		log_printf (instance->totemsrp_log_level_notice,
 			"%s", retransmit_msg);
 	}
 
@@ -2159,7 +2162,7 @@ static int orf_token_rtr (
 	 * but only retry if there is room in the retransmit list
 	 */
 
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_debug,
+	log_printf (instance->totemsrp_log_level_debug,
 		"high seq %x aru %x\n", instance->my_high_seq_received, instance->my_aru);
 
 	range = instance->my_high_seq_received - instance->my_aru;
@@ -2477,7 +2480,7 @@ static void memb_state_commit_token_create (
 	struct memb_commit_token_memb_entry *memb_list;
 	int token_memb_entries = 0;
 
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+	log_printf (instance->totemsrp_log_level_notice,
 		"Creating commit token because I am the rep.\n");
 
 	memb_set_subtract (token_memb, &token_memb_entries,
@@ -2580,14 +2583,14 @@ static void memb_ring_id_create_or_load (
 		umask(0);
 		fd = open (filename, O_CREAT|O_RDWR, 0777);
 		if (fd == -1) {
-			instance->totemsrp_log_printf (instance->totemsrp_log_level_warning,
+			log_printf (instance->totemsrp_log_level_warning,
 				"Couldn't create %s %s\n", filename, strerror (errno));
 		}
 		res = write (fd, &memb_ring_id->seq, sizeof (unsigned long long));
 		assert (res == sizeof (unsigned long long));
 		close (fd);
 	} else {
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_warning,
+		log_printf (instance->totemsrp_log_level_warning,
 			"Couldn't open %s %s\n", filename, strerror (errno));
 	}
 	
@@ -2612,15 +2615,15 @@ static void memb_ring_id_store (
 		fd = open (filename, O_CREAT|O_RDWR, 0777);
 	}
 	if (fd == -1) {
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_warning,
+		log_printf (instance->totemsrp_log_level_warning,
 			"Couldn't store new ring id %llx to stable storage (%s)\n",
 				commit_token->ring_id.seq, strerror (errno));
 		assert (0);
 		return;
 	}
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+	log_printf (instance->totemsrp_log_level_notice,
 		"Storing new sequence id for ring %d\n", commit_token->ring_id.seq);
-	assert (fd > 0);
+	//assert (fd > 0);
 	res = write (fd, &commit_token->ring_id.seq, sizeof (unsigned long long));
 	assert (res == sizeof (unsigned long long));
 	close (fd);
@@ -2988,7 +2991,7 @@ static int message_handler_orf_token (
 		if (instance->my_aru_count > instance->totem_config->fail_to_recv_const &&
 			!totemip_equal(&token->aru_addr, &instance->my_id)) {
 			
-			instance->totemsrp_log_printf (instance->totemsrp_log_level_error,
+			log_printf (instance->totemsrp_log_level_error,
 				"FAILED TO RECEIVE\n");
 // TODO if we fail to receive, it may be possible to end with a gather
 // state of proc == failed = 0 entries
@@ -3025,7 +3028,7 @@ static int message_handler_orf_token (
 				if (token->retrans_flg == 1 && instance->my_set_retrans_flg) {
 					token->retrans_flg = 0;
 				}
-				instance->totemsrp_log_printf (instance->totemsrp_log_level_debug,
+				log_printf (instance->totemsrp_log_level_debug,
 					"token retrans flag is %d my set retrans flag%d retrans queue empty %d count %d, low_water %x aru %x\n", 
 					token->retrans_flg, instance->my_set_retrans_flg,
 					queue_is_empty (&instance->retrans_message_queue),
@@ -3038,7 +3041,7 @@ static int message_handler_orf_token (
 				if (instance->my_retrans_flg_count == 2) {
 					instance->my_install_seq = token->seq;
 				}
-				instance->totemsrp_log_printf (instance->totemsrp_log_level_debug,
+				log_printf (instance->totemsrp_log_level_debug,
 					"install seq %x aru %x high seq received %x\n",
 					instance->my_install_seq, instance->my_aru, instance->my_high_seq_received);
 				if (instance->my_retrans_flg_count >= 2 && instance->my_aru >= instance->my_install_seq && instance->my_received_flg == 0) {
@@ -3053,7 +3056,7 @@ static int message_handler_orf_token (
 					instance->my_rotation_counter = 0;
 				}
 				if (instance->my_rotation_counter == 2) {
-				instance->totemsrp_log_printf (instance->totemsrp_log_level_debug,
+				log_printf (instance->totemsrp_log_level_debug,
 					"retrans flag count %x token aru %x install seq %x aru %x %x\n",
 					instance->my_retrans_flg_count, token->aru, instance->my_install_seq,
 					instance->my_aru, token->seq);
@@ -3121,7 +3124,7 @@ static void messages_deliver_to_app (
 	unsigned int my_high_delivered_stored = 0;
 	struct totem_ip_address msg_source;
 
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_debug,
+	log_printf (instance->totemsrp_log_level_debug,
 		"Delivering %x to %x\n", instance->my_high_delivered,
 		end_point);
 
@@ -3183,7 +3186,7 @@ static void messages_deliver_to_app (
 		/*
 		 * Message found
 		 */
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_debug,
+		log_printf (instance->totemsrp_log_level_debug,
 			"Delivering MCAST message with seq %x to pending delivery queue\n",
 			mcast->seq);
 
@@ -3306,7 +3309,7 @@ static int message_handler_mcast (
 		return (0);
 	}
 
-	instance->totemsrp_log_printf (instance->totemsrp_log_level_debug,
+	log_printf (instance->totemsrp_log_level_debug,
 		"Received ringid(%s:%lld) seq %x\n",
 		totemip_print (&mcast_header.ring_id.rep),
 		mcast_header.ring_id.seq,
@@ -3688,7 +3691,7 @@ static int message_handler_memb_commit_token (
 	if (memb_commit_token->token_seq > 0 &&
 		instance->my_token_seq >= memb_commit_token->token_seq) {
 
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+		log_printf (instance->totemsrp_log_level_notice,
 			"already received commit token %d %d\n",
 			memb_commit_token->token_seq, instance->my_token_seq);
 		return (0);
@@ -3730,7 +3733,7 @@ static int message_handler_memb_commit_token (
 			break;
 
 		case MEMB_STATE_RECOVERY:
-			instance->totemsrp_log_printf (instance->totemsrp_log_level_notice,
+			log_printf (instance->totemsrp_log_level_notice,
 				"Sending initial ORF token\n");
 
 			if (totemip_equal(&instance->my_id, &instance->my_ring_id.rep)) {
@@ -3774,7 +3777,7 @@ void main_deliver_fn (
 	struct message_header *message_header = (struct message_header *)msg;
 
 	if (msg_len < sizeof (struct message_header)) {
-		instance->totemsrp_log_printf (instance->totemsrp_log_level_security, "Received message is too short...  ignoring %d.\n", msg_len);
+		log_printf (instance->totemsrp_log_level_security, "Received message is too short...  ignoring %d.\n", msg_len);
 		return;
 	}
 
@@ -3805,7 +3808,7 @@ void main_iface_change_fn (
 
 	if (instance->first_run++ == 0) {
 		memb_ring_id_create_or_load (instance, &instance->my_ring_id);
-		instance->totemsrp_log_printf (
+		log_printf (
 			instance->totemsrp_log_level_notice,
 			"Created or loaded sequence id %lld.%s for this ring.\n",
 			instance->my_ring_id.seq,

+ 14 - 0
exec/util.c

@@ -81,3 +81,17 @@ void openais_exit_error (enum e_ais_done err)
 	log_printf (LOG_LEVEL_ERROR, "AIS Executive exiting.\n");
 	exit (1);
 }
+
+char *getSaNameT (SaNameT *name)
+{
+	static char ret_name[300];
+
+	memset (ret_name, 0, sizeof (ret_name));
+	if (name->length > 299) {
+		memcpy (ret_name, name->value, 299);
+	} else {
+
+		memcpy (ret_name, name->value, name->length);
+	}
+	return (ret_name);
+}

+ 1 - 0
exec/util.h

@@ -65,4 +65,5 @@ enum e_ais_done {
 
 void openais_exit_error (enum e_ais_done err);
 
+extern char *getSaNameT (SaNameT *name);
 #endif /* UTIL_H_DEFINED */

+ 2 - 0
exec/vsf_ykd.c

@@ -496,6 +496,8 @@ static int ykd_init (
 		int primary_designated,
 		struct memb_ring_id *ring_id))
 {
+	log_init ("YKD");
+
 	ykd_primary_callback_fn = primary_callback_fn;
 
 	totempg_groups_initialize (