[Chicago] from x import * but reference it by x.myfunc?

John Quigley jquigley at jquigley.com
Mon Apr 28 17:34:08 CEST 2008


Lukasz Szybalski wrote:
> How do I use loging in file x.py?

The semantics of the logging module are similar in nature to that of log4j.  When you first configure the logging module (in your case with basicConfig()), that configuration becomes "sticky" via module data in 'logging'.  You'll not have to configure logging elsewhere in the same application unless you want to alter behavior.

Each source file that needs to perform logging will need to import the logging module.  'log' variables behave in the standard way, and are either global or lexical.  Within any lexical block, if you want to log, you'll need to either acquire a global variable (if one exists within that source file) with 'global log,' make use of a class data member, or you'll have to generate another logger via logging.getLogger('myLexicalBlock').

Hope this helps.

- John Quigley


More information about the Chicago mailing list