Initial commit: 000-platform project skeleton
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
31
backend/app/models/logs.py
Normal file
31
backend/app/models/logs.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""日志相关模型"""
|
||||
from datetime import datetime
|
||||
from sqlalchemy import Column, BigInteger, String, Integer, Text, JSON, Enum, TIMESTAMP
|
||||
from ..database import Base
|
||||
|
||||
|
||||
class PlatformLog(Base):
|
||||
"""统一日志表"""
|
||||
__tablename__ = "platform_logs"
|
||||
|
||||
id = Column(BigInteger, primary_key=True, autoincrement=True)
|
||||
trace_id = Column(String(36))
|
||||
tenant_id = Column(BigInteger)
|
||||
user_id = Column(BigInteger)
|
||||
app_code = Column(String(50), nullable=False)
|
||||
log_type = Column(Enum('request', 'error', 'app', 'biz', 'audit'), nullable=False)
|
||||
level = Column(Enum('debug', 'info', 'warn', 'error', 'fatal'), default='info')
|
||||
category = Column(String(100))
|
||||
message = Column(Text, nullable=False)
|
||||
context = Column(JSON)
|
||||
method = Column(String(10))
|
||||
path = Column(String(500))
|
||||
status_code = Column(Integer)
|
||||
duration_ms = Column(Integer)
|
||||
error_type = Column(String(100))
|
||||
stack_trace = Column(Text)
|
||||
action = Column(String(100))
|
||||
target_type = Column(String(50))
|
||||
target_id = Column(String(100))
|
||||
log_time = Column(TIMESTAMP, nullable=False)
|
||||
created_at = Column(TIMESTAMP, default=datetime.now)
|
||||
Reference in New Issue
Block a user