This commit is contained in:
tursom 2024-10-11 11:27:55 +08:00
parent ba387e09ab
commit 536c7bb23e
2 changed files with 12 additions and 3 deletions

View File

@ -118,7 +118,7 @@ class MyHandler(FileSystemEventHandler):
requests.post("http://turntf:18846/notify", json={"msg": msg})
if __name__ == "__main__":
def main():
path = "logs"
event_handler = MyHandler()
observer = Observer()
@ -131,3 +131,7 @@ if __name__ == "__main__":
except KeyboardInterrupt:
observer.stop()
observer.join()
if __name__ == "__main__":
main()

View File

@ -9,6 +9,7 @@ import time
from typing import *
import aiohttp
import live_status_ntf
import redis_util as redis
import blivedm
@ -61,6 +62,8 @@ def on_room_changed(new_room_ids):
async def main():
threading.Thread(target=live_status_ntf.main, daemon=True).start()
global TEST_ROOM_IDS
flush_files()
@ -140,12 +143,14 @@ def init_session():
class JsonlLogger(blivedm.BaseHandler):
def _global_callback(self, client: ws_base.WebSocketClientBase, message: dict):
if client.room_id not in log_files:
log_files[client.room_id] = open(f"logs/{client.room_id}.jsonl", "a", encoding="utf-8")
log_files[client.room_id] = open(
f"logs/{client.room_id}.jsonl", "a", encoding="utf-8")
if "cmd" in message and message["cmd"] == "PREPARING":
message["timestamp"] = int(time.time())
log_files[client.room_id].write(f"{json.dumps(message, separators=(',', ':'), ensure_ascii=False)}\n")
log_files[client.room_id].write(
f"{json.dumps(message, separators=(',', ':'), ensure_ascii=False)}\n")
# set log level to INFO