In your Task code, if you importlsstDebug then call:
debug=lsstDebug.Info(__name__)
(with __name__ being the name of the current Task), you are given a “debug object”.
By default that will simply give you a False for any attribute you access.
Thus:
The task user will customize the behaviour of debug to meet his/her particular needs by redefining the Info function to return an object that returns non-False values for certain combinations of __name__ and attribute.
With this in place, the code above produces different results:
>>> debug=lsstDebug.Info(__name__)# __name__ selects the current task>>> debug.displayTrue
Then you can write your task to optionally enable a display (or whatever) by doing something like:
ifdebug.display:afwDisplay.getDisplay()....else:self.log.debug("I would show you a pretty picture here if you enabled debugging.")
Refer to the task documentation and look for “debug variables” to discover what debugging options are available for existing Tasks.
Your goal is to customize the behaviour of debug to meet your particular needs by redefining the lsstDebug.Info function to return an object that returns non-False values for certain combinations of __name__ and attribute.
In order to load your specific debugging configuration, create a debug.py in a directory that is already in your PYTHONPATH or a new directory that you add to your PYTHONPATH, and put something like this in it:
That should enable debugging the display attribute when you are running inside lsst.meas.astrom.astrometry, and disable it elsewhere.
Of course, you can also return arbitrarily more complex objects, doing things like specifying the frame to display on etc.
You must use the --debug command line argument to ask a command line task to import your debug.py file.