Move debug log interaction to own function