log impl
This commit is contained in:
23
db/models/Log.py
Normal file
23
db/models/Log.py
Normal file
@@ -0,0 +1,23 @@
|
||||
#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,
|
||||
}
|
||||
Reference in New Issue
Block a user