Logs a message only once.

def log_once(log_func, msg, *args, **kwargs):
  """"Logs a message only once."""
  if msg not in _LOG_ONCE_SEEN:
    log_func(msg, *args, **kwargs)
    # Key on the message, ignoring args. This should fit most use cases.
    _LOG_ONCE_SEEN.add(msg)