Wraps the warning logging logic in a helper function