niming_backend/utils/logger.py

20 lines
469 B
Python
Raw Normal View History

2024-12-09 03:24:22 +08:00
from utils import pgclass, dbhelper
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-12-09 03:24:22 +08:00
with dbhelper.db.getsession() as session:
2024-11-19 21:22:01 +08:00
session.add(log)
session.commit()
2024-11-13 21:20:21 +08:00