24 lines
764 B
Python
24 lines
764 B
Python
#db/models/Log.py
|
|
from sqlalchemy import Column, Integer, String, DateTime, Text
|
|
from db.models import Base
|
|
import datetime
|
|
|
|
|
|
class Log(Base):
|
|
__tablename__ = 'log'
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
level = Column(String(50), nullable=False)
|
|
message = Column(Text, nullable=False)
|
|
timestamp = Column(DateTime, default=datetime.datetime.utcnow, nullable=False)
|
|
extra = Column(Text, nullable=True)
|
|
application = Column(String(50), nullable=False)
|
|
def to_dict(self):
|
|
return {
|
|
"id": self.id,
|
|
"level": self.level,
|
|
"message": self.message,
|
|
"timestamp": self.timestamp,
|
|
"extra": self.extra,
|
|
"application": self.application,
|
|
}
|