应用日志表(后台日志监控)
| 159 | |
| 160 | |
| 161 | class AppLog(Base): |
| 162 | """应用日志表(后台日志监控)""" |
| 163 | __tablename__ = "app_logs" |
| 164 | |
| 165 | id = Column(Integer, primary_key=True, autoincrement=True) |
| 166 | level = Column(String(20), nullable=False, index=True) |
| 167 | logger = Column(String(255), nullable=False, index=True) |
| 168 | module = Column(String(255)) |
| 169 | pathname = Column(String(500)) |
| 170 | lineno = Column(Integer) |
| 171 | message = Column(Text, nullable=False) |
| 172 | exception = Column(Text) |
| 173 | created_at = Column(DateTime, default=utcnow_naive, index=True) |
| 174 | |
| 175 | def to_dict(self) -> Dict[str, Any]: |
| 176 | return { |
| 177 | "id": self.id, |
| 178 | "level": self.level, |
| 179 | "logger": self.logger, |
| 180 | "module": self.module, |
| 181 | "pathname": self.pathname, |
| 182 | "lineno": self.lineno, |
| 183 | "message": self.message, |
| 184 | "exception": self.exception, |
| 185 | "created_at": self.created_at.isoformat() if self.created_at else None, |
| 186 | } |
| 187 | |
| 188 | |
| 189 | class OperationAuditLog(Base): |
no outgoing calls