|
From: Kevin A. <al...@se...> - 2001-12-13 23:39:40
|
I moved readAndEvalFile() to util.py. Future generic functions and methods
can go in that module.
I went ahead and changed log and config modules to use "global" module
functions for
the Log() and Configuration() classes. Now to use the logging functionality
you just import log and then use one of the function below like
log.info('hello log world')
log.py looks like:
log = Log()
def enable(): log.enable()
def disable(): log.disable()
def enablelevels(levels): log.enablelevels(levels)
def disablelevels(levels): log.disablelevels(levels)
def error(*args): log.error(*args)
def warning(*args): log.warning(*args)
def debug(*args): log.debug(*args)
def info(*args): log.info(*args)
config.py looks like:
config = Configuration()
def getOption(name): return config.getOption(name)
def setOption(name, value): config.setOption(name, value)
def getLogFileName(): return config.getLogFileName()
def saveConfig(): config.saveConfig()
I also changed the path returned by getLogFileName to always use the
application directory (sys.argv[0]) to avoid log files being created in many
different directories while the app is running.
The cvs checkin is below so you can see which files were impacted. If any of
these changes seem inherently wrong, we can always go back to the old method
or try something else, but I like how this works.
ka
---
changed filename for configuration so that the log file is always
placed in the application directory
added util.py which contains readAndEvalFile
updated the other modules and samples to use this new form
CVS: ----------------------------------------------------------------------
CVS: Enter Log. Lines beginning with `CVS:' are removed automatically
CVS:
CVS: Committing in .
CVS:
CVS: Modified Files:
CVS: binding.py config.py debug.py event.py log.py model.py res.py
CVS: samples/addresses/addresses.py
CVS: samples/resourceEditor/resourceEditor.py
CVS: samples/searchexplorer/searchexplorer.py
CVS: samples/textRouter/textRouter.py samples/turtle/turtle.py
CVS: samples/worldclock/worldclock.py
CVS: Added Files:
CVS: util.py
CVS: ----------------------------------------------------------------------
|