Change from using a bunch of debug if statements to using the logging module.