Provide option to specify a log callback instead of using console.error

Needed this for my own use. Merge if you like.