Allow debug flag to be a function.