import logging


def GetLogFromViewUrl(base_log, http_client):
  """Gets a log from it's view url.

  Args:
    base_log(str): View url in the format
      like https://{host}/logs/{project}/{path}
    http_client (FinditHttpClient): http_client to make the request.

  Returns:
    log (str or None): Requested log.
  """
  log_url = '{base_log}?format=raw'.format(base_log=base_log)
  status_code, log, _ = http_client.Get(log_url)

  if status_code != 200 or not log:
    logging.error('Failed to get the log from %s: status_code-%d, log-%s',
                  log_url, status_code, log)
    return None
  return log