Move get_logs to be static method

This commit is contained in:
Matthias 2020-12-06 19:57:48 +01:00
parent 058d40a72c
commit 51fbd0698c
3 changed files with 4 additions and 3 deletions

View File

@ -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

View File

@ -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:]

View File

@ -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: