[Tutor] How does this work?

Tony Cappellini cappy2112 at gmail.com
Wed Feb 7 19:49:43 CET 2007

> You should be able to make the logging module work with you, it is very
> flexible. You should hook into the logging module. Write a custom
> handler that pushes log methods into your GUI. Add the handler to the
> root logger.

The cmd line app already uses the logging module- this is where the
problem started.

At the moment- due to the author's implementation, I can't pass in
anything to modify ho the logger gets initialized. I have been
thinking about asking him to let me pass in an instance of the logger
to his main(), once I understand how to get the output from the logger
into a string variable

> Right, but the stand-alone stuff can be wrapped with
> if __name__=='__main__':

It already is. The cmd line app was written like this since day 1.
I am now importing it and calling his main() via the module import
import targetapp

targetapp.main([arg1, arg2]) or whatever

> leaving the part you care about available for import in the same module.

> The logging configuration should be in the main code as well, then when
> you import the module you can configure logging the way you want.

I think the hooks for the logging need to be changed, so I can pass
them in or call them.

Ok- now I will ask him to make his app a class

More information about the Tutor mailing list