diff --git a/chii/db/sa.py b/chii/db/sa.py index 255d3e8..556f014 100644 --- a/chii/db/sa.py +++ b/chii/db/sa.py @@ -1,3 +1,4 @@ +import logging.config import time from sqlalchemy import ( @@ -59,6 +60,29 @@ def get(T, *where, order=None): return s +if config.debug: + # redirect echo logger to sslog + logging.config.dictConfig( + { + "version": 1, + "handlers": { + "sslog": { + "class": "sslog.InterceptHandler", + "level": "DEBUG", + } + }, + "loggers": { + "": {"level": "INFO", "handlers": ["sslog"]}, + "sqlalchemy.engine.Engine": { + "level": "INFO", + "handlers": ["sslog"], + "propagate": False, + }, + }, + } + ) + + def sync_session_maker(): engine = create_engine( config.MYSQL_SYNC_DSN, diff --git a/gql/model.py b/gql/model.py index 0493edc..b406d05 100644 --- a/gql/model.py +++ b/gql/model.py @@ -1,8 +1,7 @@ -from dataclasses import dataclass +from typing import TypedDict -@dataclass(kw_only=True) -class CollectTimeline: +class CollectTimeline(TypedDict): id: int action: int user_id: int