Change print messages to log messages