mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
limit logs to a number
This commit is contained in:
parent
ddbe11035d
commit
a2935dc44b
1 changed files with 3 additions and 3 deletions
|
@ -376,7 +376,7 @@ def service_log(name, number=50):
|
||||||
for log_path in log_list:
|
for log_path in log_list:
|
||||||
# log is a file, read it
|
# log is a file, read it
|
||||||
if log_path == "systemd":
|
if log_path == "systemd":
|
||||||
result[log_path] = _get_journalctl_logs(name)
|
result[log_path] = _get_journalctl_logs(name, int(number))
|
||||||
continue
|
continue
|
||||||
elif not os.path.isdir(log_path):
|
elif not os.path.isdir(log_path):
|
||||||
result[log_path] = _tail(log_path, int(number)) if os.path.exists(log_path) else []
|
result[log_path] = _tail(log_path, int(number)) if os.path.exists(log_path) else []
|
||||||
|
@ -1050,9 +1050,9 @@ def manually_modified_files():
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
def _get_journalctl_logs(service):
|
def _get_journalctl_logs(service, number="all"):
|
||||||
try:
|
try:
|
||||||
return subprocess.check_output("journalctl -xn -u %s" % service, shell=True)
|
return subprocess.check_output("journalctl -xn -u {0} -n{1}".format(service, number), shell=True)
|
||||||
except:
|
except:
|
||||||
import traceback
|
import traceback
|
||||||
return "error while get services logs from journalctl:\n%s" % traceback.format_exc()
|
return "error while get services logs from journalctl:\n%s" % traceback.format_exc()
|
||||||
|
|
Loading…
Add table
Reference in a new issue