[chirp_devel] [PATCH 3/4] Simplify and centralize debugging messages (#2343)

Dan Smith
Mon Feb 23 15:23:54 PST 2015


> 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
Url : http://intrepid.danplanet.com/pipermail/chirp_devel/attachments/20150223/058d786e/attachment-0001.bin 


More information about the chirp_devel mailing list