Replace printf logging with appropriate log function