Log based on debug flag