Added an option to set a logging function

By default, a null logger is used, and nothing is printed to anywhere.