Allow logging functions to be passed in.

Give any users of the optimize api the ability to pass in logging functions, so that it doesn't automatically go to the console.

The user gives an object with properties `log`, `warn` and `status`, each a function.

The spinner has been updated to provide these functions, and the code updated to use them.