[Openais] [PATCH] trunk: logsys should accept my priority

Fabio M. Di Nitto fabbione at fabbione.net
Fri Jul 11 06:12:12 PDT 2008


On Fri, 11 Jul 2008, Christine Caulfield wrote:

> Fabio M. Di Nitto wrote:
>> 
>> Hi Steven,
>> 
>> as discussed in a previous thread logsys_config_subsys_set does not allow 
>> to set a lower priority (for example switching from LOG_LEVEL_DEBUG to 
>> LOG_LEVEL_INFO).
>> 
>> This behaviour can be problematic if we ask people to switch debugging on 
>> and then they can't turn it off.
>> 
>> The patch in attachment allows logsys to roll back to whatever priority the 
>> user wants.
>> 
>> Please apply
>> 
>> 
> The problem with that patch is that it's the opposite of the one I posted and 
> breaks (or rather leaves broken) the initialisation code.
>
> If a logging priority is set in the configuration file, then that is set into 
> logsys during config processing. When the lcrso modules are subsequently 
> loaded they will reset the logging level back to their hard-coded default. So 
> the config options are useless.
>
> Chrissie
>

The patch in attachment fixes the problem at the root by not forcing 
priority re-init if the subsystem is already configured.

Please apply

Fabio

--
I'm going to make him an offer he can't refuse.
-------------- next part --------------
Index: exec/logsys.c
===================================================================
--- exec/logsys.c	(revision 1575)
+++ exec/logsys.c	(working copy)
@@ -185,9 +185,6 @@
 			logsys_loggers[i].tags = tags;
 			logsys_loggers[i].priority = priority;
 
-			if (priority > logsys_loggers[i].priority) {
-				logsys_loggers[i].priority = priority;
-			}
 			break;
 		}
 	}
@@ -228,7 +225,7 @@
 			*tags = logsys_loggers[i].tags;
 			*priority = logsys_loggers[i].priority;
 			pthread_mutex_unlock (&logsys_config_mutex);
-			return (0);
+			return i;
 		}
 	}
 
@@ -481,10 +478,6 @@
 
 	logsys_loggers[id].priority = priority;
 
-	if (priority > logsys_loggers[id].priority) {
-		logsys_loggers[id].priority = priority;
-	}
-
 	pthread_mutex_unlock (&logsys_new_log_mutex);
 }
 
Index: exec/logsys.h
===================================================================
--- exec/logsys.h	(revision 1575)
+++ exec/logsys.h	(working copy)
@@ -180,16 +180,29 @@
 #define LOGSYS_DECLARE_NOSUBSYS(priority)				\
 __attribute__ ((constructor)) static void logsys_nosubsys_init (void)	\
 {									\
-	_logsys_nosubsys_set();						\
+	unsigned int pri, tags;						\
+									\
 	logsys_subsys_id =						\
-		_logsys_subsys_create ("MAIN", (priority));		\
+		logsys_config_subsys_get("MAIN", &tags, &pri);		\
+									\
+	if (logsys_subsys_id == -1) {					\
+		_logsys_nosubsys_set();					\
+		logsys_subsys_id =					\
+			_logsys_subsys_create ("MAIN", (priority));	\
+	}								\
 }
 
 #define LOGSYS_DECLARE_SUBSYS(subsys,priority)				\
 __attribute__ ((constructor)) static void logsys_subsys_init (void)	\
 {									\
+	unsigned int pri, tags;						\
+									\
 	logsys_subsys_id =						\
-		_logsys_subsys_create ((subsys), (priority));		\
+		logsys_config_subsys_get((subsys), &tags, &pri);	\
+									\
+	if (logsys_subsys_id == -1)					\
+		logsys_subsys_id =					\
+			_logsys_subsys_create ((subsys), (priority));	\
 }
 
 #define log_printf(lvl, format, args...) do {				\


More information about the Openais mailing list