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: Only get a certain number of records
|
||||||
"""
|
"""
|
||||||
limit = int(request.args.get('limit', 0)) or None
|
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
|
@require_login
|
||||||
@rpc_catch_errors
|
@rpc_catch_errors
|
||||||
|
@ -645,7 +645,8 @@ class RPC:
|
|||||||
}
|
}
|
||||||
return res
|
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"""
|
"""Returns the last X logs"""
|
||||||
if limit:
|
if limit:
|
||||||
buffer = bufferHandler.buffer[-limit:]
|
buffer = bufferHandler.buffer[-limit:]
|
||||||
|
@ -683,7 +683,7 @@ class Telegram(RPC):
|
|||||||
limit = int(context.args[0]) if context.args else 10
|
limit = int(context.args[0]) if context.args else 10
|
||||||
except (TypeError, ValueError, IndexError):
|
except (TypeError, ValueError, IndexError):
|
||||||
limit = 10
|
limit = 10
|
||||||
logs = self._rpc_get_logs(limit)['logs']
|
logs = RPC._rpc_get_logs(limit)['logs']
|
||||||
msgs = ''
|
msgs = ''
|
||||||
msg_template = "*{}* {}: {} \\- `{}`"
|
msg_template = "*{}* {}: {} \\- `{}`"
|
||||||
for logrec in logs:
|
for logrec in logs:
|
||||||
|
Loading…
Reference in New Issue
Block a user