From: Kevin A. <al...@se...> - 2001-12-13 02:10:08
|
I brought up the singleton issue because I decided I wanted to start using logging on a more regular basis rather than adding and then removing/commenting print statements all over the place, which is my typical messy solution. I started to look at the Log class which I hadn't used in a while and decided the log.Log.getInstance() syntax was a bit awkward. Here's an example from some of Jeff's code: log.Log.getInstance().warning("WidgetLoader.installEventBindings: " + "no event bindings at all: " + moduleName) The worldclock.py sample syntax is cleaner, but that is because it keeps a reference to the instance: # Enable logging self.log = Log.getInstance() # self.log.enable() # Normally we enable only ERROR and WARNING messages self.log.enableLevels( [ Log.ERROR, Log.WARNING, Log.DEBUG, Log.INFO ] ) ... self.log.info( " interval is up..." ) That won't work for log statements we want to scatter throughout the framework. Remember that the logging level and whether a log file is generated can be set, so the log statements shouldn't burden normal execution of an application or produce any output unless requested. This seems like a good time to revisit the logging issue as we standardize our singleton class. There should be much more diagnostic output in the framework, but I would like to pick a longer-term solution before starting to add log statements throughout the code. Could we just have a variable in the module file such as: log = Log.getInstance() and then use from PythonCardPrototype.log import log That seems like it should work. Does anyone have suggestions or feature requests for our logging classes? Are there any "standard" Python logging solutions I'm overlooking? I found log4p (based on log4j at SF http://sourceforge.net/projects/log4p/ http://log4p.sourceforge.net/ but no files have been released yet. ka |