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
|
|
|
|
from utils.platform_consts import EVENT_TYPE_GENERAL, EVENT_TYPE_ADMIN, EVENT_TYPE_SERVER
|
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
|
|
|
|
# new post & del post
|
2024-11-19 21:22:01 +08:00
|
|
|
if type in EVENT_TYPE_GENERAL:
|
2024-11-13 21:20:21 +08:00
|
|
|
flag = True
|
|
|
|
log = table(source = "general", message = message)
|
2024-11-19 21:22:01 +08:00
|
|
|
elif type in EVENT_TYPE_ADMIN:
|
2024-11-19 02:19:25 +08:00
|
|
|
flag = True
|
|
|
|
log = table(source = "admin", message = message)
|
2024-11-19 21:22:01 +08:00
|
|
|
elif type in EVENT_TYPE_SERVER:
|
2024-11-19 02:19:25 +08:00
|
|
|
flag = True
|
|
|
|
log = table(source = "server", message = message)
|
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
|
|
|
|
|
|
|
|