def add_events(id, level, message, dealt=False): event = Events() event.cid = id event.info = message event.time = datetime.datetime.now() event.type = level event.deal_status = 1 if dealt else 0 session.add(event) session.commit()
def add_events(chart, level, message): if level not in (CONST_LEVEL_WARNING, CONST_LEVEL_CRITICAL): return type = 0 if level == CONST_LEVEL_WARNING else 0 event = Events() event.cid = chart.id event.info = message event.time = datetime.datetime.now() event.type = type event.deal_status = 0 # not dealed session.add(event) session.flush()