def parse_url_or_log(url, encoding='utf-8'):
    '''Parse and return a URLInfo.

    This function logs a warning if the URL cannot be parsed and returns
    None.
    '''
    try:
        url_info = URLInfo.parse(url, encoding=encoding)
    except ValueError as error:
        _logger.warning(__(
            _('Unable to parse URL ‘{url}’: {error}.'),
            url=wpull.string.printable_str(url), error=error))
    else:
        return url_info
Parse and return a URLInfo.

    This function logs a warning if the URL cannot be parsed and returns
    None.