use python logging module for messages instead of print()

This "if debug" can probably just become ``logger.debug(...)``. That is, the logging system already has a facility for handling this conditional.