added log viewer
This commit is contained in:
@@ -5,10 +5,21 @@ from models.database import Database
|
||||
|
||||
class LogService:
|
||||
@staticmethod
|
||||
def createlog(username, description, additional_information, suspicious):
|
||||
def create_log(username, description, additional_information, suspicious):
|
||||
now = datetime.now()
|
||||
date_string = now.strftime("%d-%m-%Y")
|
||||
time_string = now.strftime("%H:%M:%S")
|
||||
new_log = Log(Database.connection, None, username, date_string, time_string, description, additional_information, suspicious)
|
||||
|
||||
new_log.save()
|
||||
|
||||
@staticmethod
|
||||
def get_latest_logs():
|
||||
cur = Database.connection.cursor()
|
||||
cur.execute("SELECT * FROM logs ORDER BY id DESC LIMIT 100;")
|
||||
rows = cur.fetchall()
|
||||
logs = []
|
||||
for row in rows:
|
||||
log = Log(Database.connection)._set_row_values(row)
|
||||
logs.append(log)
|
||||
return logs
|
Reference in New Issue
Block a user