[Freeipa-devel] [PATCH] jderose 041 Fix logging

Jason Gerard DeRose jderose at redhat.com
Mon Feb 8 19:51:17 UTC 2010


On Mon, 2010-02-08 at 11:38 -0500, Rob Crittenden wrote:
> Jason Gerard DeRose wrote:
> > I lied one, more.
> > 
> > Rob, I see you changed how the log level on the root logger is set in
> > API.bootstrap()... unfortunately, under the server and CLI, the result
> > is that the root logger always stays at its default level of
> > logging.WARNING, so none of our info() nor debug() messages are going
> > into the server log nor out to stderr (even with --debug).
> > 
> > My solution is to unconditionally set the root logger to logging.DEBUG,
> > the most verbose we use, and then configure the levels on individual
> > handlers as appropriate (which we already do).
> > 
> > Rob, I know you make this change because of problems with logging from
> > the installer, so can you see if still works the way you want it to with
> > this patch?  By the way, are you setting up your own logging handler in
> > the installer, or using the ones configured in API.bootstrap()?
> > 
> > Anyway, we really shouldn't release our alpha with broken logging.  Not
> > nice to our brave and helpful testers.  ;)
> 
> Jason, I think we can instead test for len(log.handlers) == 0 to 
> determine if we have already configured a file handler for it. Can you 
> confirm this? So if there are no handlers configured we set the log 
> level, otherwise we skip it.
> 
> rob

The logging levels range in numeric value from 0 (NOTSET) to 50
(CRITICAL).  Setting the the root logger to log level DEBUG (10) doesn't
actually change the effective level (in our case) because the effective
level at a given handler is max(logger.level, handler.level).

API.bootstrap() by default sets the stderr handler to WARNING (30) and
the file handler to INFO (20).  --verbose sets the stderr handler to
INFO.  --debug sets both the stderr and file handlers to DEBUG (10).

Anyway, would it be possible to have the installer use the same file
handler that API.bootstrap() sets up?  You can change what log file is
used like this:

    api.env.log = '/the/installer/log.txt'
    api.bootstrap()
    api.finalize()

Would that work?  I'm open to tweaking API.bootstrap() as needed so we
can have a uniform logging setup.










More information about the Freeipa-devel mailing list