Pulled in log logic from dirtyadapter.