Use logging module instead of print function.