VWED_server/data/models/tasklog.py

52 lines
2.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
任务日志模型
对应vwed_tasklog表
"""
import datetime
from sqlalchemy import Column, String, Integer, DateTime, Index
from sqlalchemy.dialects.mysql import LONGTEXT
from data.models.base import BaseModel
class VWEDTaskLog(BaseModel):
"""
任务日志模型
对应vwed_tasklog表
功能:记录任务执行过程中的详细日志信息,用于监控和调试
"""
__tablename__ = 'vwed_tasklog'
__table_args__ = (
Index('idx_vwed_tasklog_task_id', 'task_id'),
Index('idx_vwed_tasklog_task_record_id', 'task_record_id'),
Index('idx_vwed_tasklog_level', 'level'),
Index('idx_vwed_tasklog_created_at', 'created_at'),
Index('idx_vwed_tasklog_parent_log_id', 'parent_log_id'),
Index('idx_vwed_tasklog_iteration_index', 'iteration_index'),
Index('idx_vwed_tasklog_block_record_id', 'block_record_id'),
Index('idx_vwed_tasklog_log_type', 'log_type'),
{
'mysql_engine': 'InnoDB',
'mysql_charset': 'utf8mb4',
'mysql_collate': 'utf8mb4_general_ci',
'info': {'order_by': 'created_at DESC'}
}
)
id = Column(String(255), primary_key=True, nullable=False, comment='日志记录ID')
level = Column(Integer, comment='日志级别1: 信息, 3: 错误等)')
message = Column(LONGTEXT, comment='日志消息内容')
task_block_id = Column(String(255), comment='任务块名称(name字段)')
task_id = Column(String(255), comment='对应的任务定义ID')
task_record_id = Column(String(255), comment='对应的任务执行记录ID')
parent_log_id = Column(String(255), comment='父日志ID,用于建立层级关系')
iteration_index = Column(Integer, comment='迭代索引,记录是第几次循环(从0开始)')
block_record_id = Column(String(255), comment='关联的块执行记录ID')
log_type = Column(String(50), comment='日志类型: iteration_start(迭代开始), iteration_end(迭代结束), block_execution(块执行), branch_execution(分支执行)')
def __repr__(self):
return f"<VWEDTaskLog(id='{self.id}', level='{self.level}')>"