Rewrite logging to use Python's logging module