Move get_logs to be static method
This commit is contained in:
parent
058d40a72c
commit
51fbd0698c
@ -388,7 +388,7 @@ class ApiServer(RPC):
|
||||
limit: Only get a certain number of records
|
||||
"""
|
||||
limit = int(request.args.get('limit', 0)) or None
|
||||
return jsonify(self._rpc_get_logs(limit))
|
||||
return jsonify(RPC._rpc_get_logs(limit))
|
||||
|
||||
@require_login
|
||||
@rpc_catch_errors
|
||||
|
@ -645,7 +645,8 @@ class RPC:
|
||||
}
|
||||
return res
|
||||
|
||||
def _rpc_get_logs(self, limit: Optional[int]) -> Dict[str, Any]:
|
||||
@staticmethod
|
||||
def _rpc_get_logs(limit: Optional[int]) -> Dict[str, Any]:
|
||||
"""Returns the last X logs"""
|
||||
if limit:
|
||||
buffer = bufferHandler.buffer[-limit:]
|
||||
|
@ -683,7 +683,7 @@ class Telegram(RPC):
|
||||
limit = int(context.args[0]) if context.args else 10
|
||||
except (TypeError, ValueError, IndexError):
|
||||
limit = 10
|
||||
logs = self._rpc_get_logs(limit)['logs']
|
||||
logs = RPC._rpc_get_logs(limit)['logs']
|
||||
msgs = ''
|
||||
msg_template = "*{}* {}: {} \\- `{}`"
|
||||
for logrec in logs:
|
||||
|
Loading…
Reference in New Issue
Block a user