Added logging with --debug flag.