niming_backend/utils/logger.py

21 lines
480 B
Python
Raw Normal View History

2024-11-14 13:03:00 +08:00
from utils import pgclass
2024-11-19 21:22:01 +08:00
from utils.dbhelper import db
2024-11-19 23:29:01 +08:00
from utils.platform_consts import EVENT_TYPE
2024-11-13 21:20:21 +08:00
2024-11-19 21:22:01 +08:00
def logger(type, message):
2024-11-13 21:20:21 +08:00
table = pgclass.SQLlog
flag = False
2024-11-19 23:29:01 +08:00
for etl in EVENT_TYPE:
if type in EVENT_TYPE[etl]:
flag = True
log = table(source = etl, message = message)
break
2024-11-13 21:20:21 +08:00
# session.add
if flag:
2024-11-19 21:22:01 +08:00
with db.getsession() as session:
session.add(log)
session.commit()
2024-11-13 21:20:21 +08:00