mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Refactor API for new activity log format
This commit is contained in:
parent
227d642546
commit
92dfd18dbd
@ -1,3 +1,5 @@
|
||||
import os
|
||||
import json
|
||||
from app.classes.web.base_api_handler import BaseApiHandler
|
||||
|
||||
|
||||
@ -22,9 +24,17 @@ class ApiCraftyLogIndexHandler(BaseApiHandler):
|
||||
raise NotImplementedError
|
||||
|
||||
if log_type == "audit":
|
||||
with open(
|
||||
os.path.join(self.controller.project_root, "logs", "audit.log"),
|
||||
"r",
|
||||
encoding="utf-8",
|
||||
) as f:
|
||||
log_lines = [json.loads(line) for line in f]
|
||||
rev_log_lines = log_lines[::-1]
|
||||
|
||||
return self.finish_json(
|
||||
200,
|
||||
{"status": "ok", "data": self.controller.management.get_activity_log()},
|
||||
{"status": "ok", "data": rev_log_lines},
|
||||
)
|
||||
|
||||
if log_type == "session":
|
||||
|
Loading…
Reference in New Issue
Block a user