Guarding the logging with a debug flag.