Added proper logging.
It is now possible for the library user to define how logging should
work, rather than just printing to stdout.