At its core, this patch adds a dprint function that wraps print with a conditional on CHIRP_DEBUG. That variable is set by the environment, but it can also be set by a command line option (--debug) in chirp.py. I would like to add that option to chirpw too, but that would require a separate patch that adds proper option parsing.
Thanks, this has been a mess for a long time. I should have done it right early on, but...
IMHO, this really needs to be using the python logging infrastructure, which will let us do a much better job of logging to files by level, generic formatting and timestamping, module stamping, etc.
Just this is probably enough to get started:
# In chirpw, chirp.py, etc import logging
logging.basicConfig(format='%(asctime)-15s %(levelname)s %(message)s') logging.getLogger().setLevel(logging.DEBUG)
# Everywhere else import logging LOG = logging.getLogger(__name__)
...
LOG.debug('blah') LOG.error('foo')
Thanks!
--Dan