adds debug logging