<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def log_url (self, url_data):
 """ Put invalid url in blacklist, delete valid url from blacklist. """

        key = (url_data.parent_url, url_data.cache_url)
        key = repr(key)
        if key in self.blacklist:
            if url_data.valid:
                del self.blacklist[key]
            else:
                self.blacklist[key] += 1
        else:
            if not url_data.valid:
                self.blacklist[key] = 1