[Openais] How to enable debug output ?

Steven Dake sdake at redhat.com
Mon Sep 4 23:27:26 PDT 2006


Hans,

Looks good
regards
-steve
On Fri, 2006-09-01 at 12:13 +0200, Hans Feldt wrote:
> Committed revision 1234.
> 
> Hans Feldt wrote:
> > New patch with:
> > - print.c changes as before
> > - man page updates
> > - openais.conf updates
> > 
> > Please note that the name of the log file has been changed so that it 
> > has a suffix: openais.log
> > 
> > Fabien, is this better?
> > 
> > Regards,
> > Hans
> > 
> > Hans Feldt wrote:
> > 
> >> Fabien THOMAS wrote:
> >>
> >>>
> >>>> Yes the main debug directive seems to be broken. I will look into  
> >>>> that. But you don't want that. Write a logger directive instead to  
> >>>> get logs for the service you want instead.
> >>>>
> >>>
> >>> What is the purpose of the main debug switch now ?
> >>
> >>
> >>
> >> Not much, its floods standard out with totem printouts. I guess its 
> >> there for backwards compatibility.
> >>
> >>
> >>> I think a sample in the default config or in the man page will help  
> >>> to understand the system.
> >>
> >>
> >>
> >> OK, I can put in my AMF section into conf/openais.conf
> >>
> >>
> >>> ident: it is not really clear that you must put the module name here  
> >>> (checkpoint=CKPT for example)
> >>
> >>
> >>
> >> Current man page text:
> >>
> >> "        ident  This specifies the identity (name) for which logging 
> >> is specified. This directive is required."
> >>
> >> How can this be improved? Maybe:
> >>
> >> "ident    This specifies the identity (name) for which logging is 
> >> specified. This is the name used by a service in the log_init () call. 
> >> E.g. 'CKPT'. This directive is required."
> >>
> >>
> >>> tags: The doc state enter|return but in the code its enter|leave.
> >>
> >>
> >>
> >> oops
> >>
> >>
> >> Will update and send a new patch.
> >>
> >> Regards,
> >> Hans
> >>
> >>
> >>> Now it works with the following config
> >>>
> >>> logger {
> >>>    ident: CKPT
> >>>    debug: on
> >>>    tags: enter|leave
> >>> }
> >>>
> >>> The output is really useful ;)
> >>>
> >>> Fabien
> >>>
> >>>
> >>>> /Hans
> >>>>
> >>>>
> >>>> Fabien THOMAS wrote:
> >>>>
> >>>>
> >>>>>> No. Just configure in openais.conf. See man page for the file,  
> >>>>>> it  should explain what you need.
> >>>>>>
> >>>>>
> >>>>> in the man page i've found two things the main debug directive  
> >>>>> that  is set to off by default in the sample config file
> >>>>> and the logger directive.
> >>>>> On my version setting the main debug to "on" does not display  
> >>>>> message  with LOG_LEVEL_DEBUG what is the correct way to display
> >>>>> this type of message ?
> >>>>> For me there is something wrong: me, the doc, the code :)
> >>>>> Fabien
> >>>>
> >>>>
> >>>>
> >>>>
> >>>
> >>
> >> _______________________________________________
> >> Openais mailing list
> >> Openais at lists.osdl.org
> >> https://lists.osdl.org/mailman/listinfo/openais
> >>
> > 
> > 
> > ------------------------------------------------------------------------
> > 
> > Index: exec/print.c
> > ===================================================================
> > --- exec/print.c	(revision 1233)
> > +++ exec/print.c	(working copy)
> > @@ -55,6 +55,7 @@
> >  #include <syslog.h>
> >  #include <stdlib.h>
> >  #include <pthread.h>
> > +#include <signal.h>
> >  
> >  #include "print.h"
> >  #include "totemip.h"
> > @@ -105,11 +106,7 @@
> >  
> >   	for (i = 0; i < MAX_LOGGERS; i++) {
> >  		if (strcmp (loggers[i].ident, ident) == 0) {
> > -			loggers[i].tags |= tags;
> > -			if (level > loggers[i].level) {
> > -				loggers[i].level = level;
> > -			}
> > -			break;
> > +			goto done;
> >  		}
> >  	}
> >  
> > @@ -125,8 +122,8 @@
> >  		}
> >  	}
> >  
> > -	assert(i < MAX_LOGGERS);
> > -
> > +done:
> > +	assert (i < MAX_LOGGERS);
> >  	return i;
> >  }
> >  
> > @@ -181,7 +178,6 @@
> >  	int i = 0;
> >  	int len;
> >  	struct log_data log_data;
> > -	unsigned int res = 0;
> >  
> >  	assert (id < MAX_LOGGERS);
> >  
> > @@ -238,15 +234,18 @@
> >  	if (log_data.log_string == NULL) {
> >  		goto drop_log_msg;
> >  	}
> > -	
> > +
> > +#ifndef DEBUG
> >  	if (log_setup_called) {
> > -		res = worker_thread_group_work_add (&log_thread_group, &log_data);
> > +		int res = worker_thread_group_work_add (&log_thread_group, &log_data);
> >  		if (res == 0) {
> >  			dropped_log_entries = 0;
> >  		} else {
> >  			dropped_log_entries += 1;
> >  		}
> > -	} else {
> > +	} else
> > +#endif
> > +	{
> >  		log_printf_worker_fn (NULL, &log_data);	
> >  	}
> >  
> > @@ -262,21 +261,36 @@
> >  {
> >  	assert (ident != NULL);
> >  
> > -	/*
> > -	** do different things before and after log_setup() has been called
> > -	*/
> > -	if (log_setup_called) {
> > +	if (logmode & LOG_MODE_DEBUG) {
> > +		return logger_init (ident, TAG_LOG, LOG_LEVEL_DEBUG, 0);
> > +	} else {
> >  		return logger_init (ident, TAG_LOG, LOG_LEVEL_INFO, 0);
> > -	} else {
> > -		return logger_init (ident, ~0, LOG_LEVEL_DEBUG, 0);
> >  	}
> >  }
> >  
> > +#ifdef PRINT_DEBUG
> > +static void sigusr2_handler (int num)
> > +{
> > +	int i;
> > +
> > +	for (i = 0; i < MAX_LOGGERS; i++) {
> > +		if (strlen (loggers[i].ident) > 0) {
> > +			printf("ident: %6s, tags: %08x, level: %d\n",
> > +				loggers[i].ident, loggers[i].tags, loggers[i].level);
> > +		}
> > +	}
> > +}
> > +#endif
> > +
> >  int log_setup (char **error_string, struct main_config *config)
> >  {
> >  	int i;
> >  	static char error_string_response[512];
> >  
> > +#ifdef PRINT_DEBUG
> > +	signal (SIGUSR2, sigusr2_handler);
> > +#endif
> > +
> >  	if (config->logmode & LOG_MODE_FILE) {
> >  		log_file_fp = fopen (config->logfile, "a+");
> >  		if (log_file_fp == 0) {
> > @@ -298,14 +312,14 @@
> >  	}
> >  
> >  	/*
> > -	** reinit all loggers that has initialised before log_setup() was called.
> > +	** reinit level for all loggers that has initialised
> > +	** before log_setup() was called.
> >  	*/
> >  	for (i = 0; i < MAX_LOGGERS; i++) {
> > -		loggers[i].tags = TAG_LOG;
> > -		if (config->logmode & LOG_MODE_DEBUG) {
> > -			loggers[i].level = LOG_LEVEL_DEBUG;
> > -		} else {
> > -			loggers[i].level = LOG_LEVEL_INFO;
> > +		if (strlen (loggers[i].ident) > 0) {
> > +			if (config->logmode & LOG_MODE_DEBUG) {
> > +				loggers[i].level = LOG_LEVEL_DEBUG;
> > +			}
> >  		}
> >  	}
> >  
> > Index: conf/openais.conf
> > ===================================================================
> > --- conf/openais.conf	(revision 1229)
> > +++ conf/openais.conf	(working copy)
> > @@ -13,11 +13,17 @@
> >  }
> >  
> >  logging {
> > +	fileline: off
> >  	to_stderr: yes
> >  	to_file: yes
> > -	logfile: /tmp/ais
> > +	logfile: /tmp/openais.log
> >  	debug: off
> >  	timestamp: on
> > +	logger {
> > +		ident: AMF
> > +		debug: on
> > +		tags: enter|leave|trace1|trace2|trace3|trace4|trace6
> > +	}
> >  }
> >  
> >  amf {
> > Index: man/openais.conf.5
> > ===================================================================
> > --- man/openais.conf.5	(revision 1229)
> > +++ man/openais.conf.5	(working copy)
> > @@ -419,20 +419,35 @@
> >  .TP
> >  to_syslog
> >  These specify the destination of logging output. Any combination of
> > -these options may be specified.
> > +these options may be specified. Valid options are
> > +.B yes
> > +and
> > +.B no.
> >  
> > +The default is syslog and stderr.
> > +
> > +
> >  .TP
> >  logfile
> > -If the logoutput: file directive is set, this option specifies where the
> > -log file is written to.
> > +If the 
> > +.B to_file
> > +directive is set to
> > +.B yes
> > +, this option specifies the pathname of the log file.
> >  
> > -The default is syslog.
> > +No default.
> >  
> >  .TP
> >  debug
> > -This specifies whether debug output is logged.  This is generally a bad idea, 
> > -unless there is some specific bug or problem that must be found in the
> > -executive.  Set the value to on to debug, off to turn of debugging.
> > +This specifies whether debug output is logged for all services.  This is
> > +generally a bad idea, unless there is some specific bug or problem that must be
> > +found in the executive. Set the value to 
> > +.B on
> > +to debug, 
> > +.B off
> > +to turn off debugging. If enabled, individual loggers can be disabled using a
> > +.B logger
> > +directive.
> >  
> >  The default is off.
> >  
> > @@ -469,7 +484,9 @@
> >  
> >  .TP
> >  ident
> > -This specifies the identity (name) for which logging is specified. This directive is required.
> > +This specifies the identity (name) for which logging is specified. This is the
> > +name used by a service in the log_init () call. E.g. 'CKPT'. This directive is
> > +required.
> >  
> >  .TP
> >  debug
> > @@ -485,7 +502,7 @@
> >  in order to enable tracing using tags.
> >  Values are specified using a vertical bar as a logical OR separator:
> >  
> > -enter|return|trace1|trace2|trace3|...
> > +enter|leave|trace1|trace2|trace3|...
> >  
> >  The default is none.
> >  
> > 
> > 
> > ------------------------------------------------------------------------
> > 
> > _______________________________________________
> > Openais mailing list
> > Openais at lists.osdl.org
> > https://lists.osdl.org/mailman/listinfo/openais
> 
> _______________________________________________
> Openais mailing list
> Openais at lists.osdl.org
> https://lists.osdl.org/mailman/listinfo/openais




More information about the Openais mailing list