niming_backend/utils/logger.py
2024-11-19 15:29:01 +00:00

21 lines
480 B
Python

from utils import pgclass
from utils.dbhelper import db
from utils.platform_consts import EVENT_TYPE
def logger(type, message):
table = pgclass.SQLlog
flag = False
for etl in EVENT_TYPE:
if type in EVENT_TYPE[etl]:
flag = True
log = table(source = etl, message = message)
break
# session.add
if flag:
with db.getsession() as session:
session.add(log)
session.commit()