Skip to content

Commit

Permalink
redirect sqlalchemy echo logger to sslog
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Sep 22, 2024
1 parent c4daad3 commit 9895178
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
24 changes: 24 additions & 0 deletions chii/db/sa.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging.config
import time

from sqlalchemy import (
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions gql/model.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 9895178

Please sign in to comment.