import json from gradio_client import Client from pgsoft.pgdate.date_utils import beijing def call_logger(log_info, caller, hf_token) -> None: ####################### # logging ####################### calling_start = beijing() print(f"[{calling_start}] logging starts") ################################################# urls = [ "https://hubei-hunan-logger.hf.space", "https://hubei-hunan-logger2.hf.space", ] for url in urls: try: client = Client( url, hf_token=hf_token, verbose=False, ) client.submit(json.dumps(log_info), caller) print(f"[logging to {url}] OK") return None except Exception as e: print(f"[logging to {url}] Failed, {type(e)}: {e}") ################################################# calling_end = beijing() timecost = calling_end.timestamp() - calling_start.timestamp() print(f"[{calling_end}] logging ends, costs {timecost:.2f}s")