|
From: Kevin A. <al...@se...> - 2001-12-13 21:26:48
|
> From: Magnus Lie Hetland
> >
> > I still like the idea of just referencing functions in the log
> module and
> I
> > think I'll go ahead and try that out. Then you could just do:
> >
> > import log
> >
> > log.info(" interval is up...")
>
> +1
>
> > since info would be setup to do the right thing.
As a simple test, I added the following code to log.py below the class
definitions, but before the unit tests.
log = Log().getInstance()
def info(*args): log.info(*args)
Then in the worldclock.py sample, I added
import log
and commented out the other Log code to make sure there was no interference.
The worldclock code changed from
self.log.info("updating image ", url)
to
log.info("updating image ", url)
This seems to work just fine. The module defines the single instance of the
Log class and global functions (global to the module) are defined for each
class method. The rest of the framework and any samples that want to use
logging don't care about the implementation, the syntax is simple, and no
capabilities are lost as far as I can tell except subclassing Log.
I'm no Python language expert, so if I'm missing something, please clue me
in.
ka
|