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()