[Openais] Logging patch.

Steven Dake sdake at mvista.com
Thu Oct 28 14:32:57 PDT 2004


On Thu, 2004-10-28 at 12:11, Daniel Stodden wrote:
> On Thu, 2004-10-28 at 07:41 -0700, Mark Haverkamp wrote:
> > On Thu, 2004-10-28 at 14:04 +0200, Daniel Stodden wrote:
> > > 
> > > hi.
> > > 
> > > this is a comparatively massive one, left for discussion:
> > > 
> > > ChangeSet at 1.96.1.1, 2004-10-28 12:24:18+02:00, dns at somacoma.net
> > > 
> > >   Changed logging interface, fixing a stack corruption bug with the
> > > varargs
> > >   usage in print.c
> > > 
> > >   main.c:
> > >     Started replacing calls to log_printf in main() with ais_log() calls
> > > for
> > >     demonstration/testing purposes.
> > >   print.h:
> > >     Replaced internal_log_printf() with two new functions: ais_log() and
> > > ais_logv().
> > >     Old functions are left for backwards compatibility.
> > >     Added macros ais_error/notice/warning/debug.
> > >     Define LOG_SERVICE to 0 if not defined in the including source file.
> > >   print.c:
> > 
> > I have a question about ais_log_setup.  Is it OK to call ais_error
> > inside of the setup function?  I'm guessing that the default values make
> > it just output to stderr if setup hasn't completed properly.
> 
> should be allowed, imho.
> 
> stderr is what's happening right now. I left this all like it used to
> be. I wasn't sure whether steve had any particular way to solve this in
> mind. Besides, it's okay like it is. I was more concerned about the
> varargs and string formatting stuff.
> 
> In my opinion, ais_log_setup() should not be meant as a "mandatory
> init()" which has to be called before anything else can log. maybe it
> should be renamed to ais_log_config() or similar to make that clear.
> 

The code in bk should log to syslog (if a socket can be opened to the
log service) and stderr with errors before/during log_setup.  After
log_setup is complete, the new configuration will be enforced (which
could turn off syslog logging).  I guessed people wouldn't mind both
logs and someone surely will want one or the other so both it was :)

After looking at Daniel's changed code, this behavior appears to be the
same albiet a little cleaner.

Daniel if you want to change ais_log_setup to ais_log_config, that makes
sense..  its a better name.

Regards
-steve

> if an ais_init() is ever needed (i.e. initial logs cannot be setup
> statically), it should not be able to fail more complicated that through
> an assert(). the hen-and-egg problems can be easily avoided by sticking
> to stderr as you said.
> 
> ever seen a daemon which complains about syntax errors in a static
> configuration file to _syslog_ and then quits? i've got two or three of
> those in my init.d/.
> one bad example is slapd. terrible idea, really.
> 
> regards,
> daniel




More information about the Openais mailing list