Add a simple log facility.
Refactor all printfs to use log facility.