mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Merge pull request #1805 from Abperron/enh-2047-log-show-last-x
[enh] Implement 'yunohost log show last' to display the last log file.
This commit is contained in:
commit
48c673478d
2 changed files with 15 additions and 1 deletions
2
share/actionsmap.yml
Normal file → Executable file
2
share/actionsmap.yml
Normal file → Executable file
|
@ -1976,7 +1976,7 @@ log:
|
|||
- display
|
||||
arguments:
|
||||
path:
|
||||
help: Log file which to display the content
|
||||
help: Log file which to display the content. 'last' or 'last-X' selects the last but X log file
|
||||
-n:
|
||||
full: --number
|
||||
help: Number of lines to display
|
||||
|
|
14
src/log.py
Normal file → Executable file
14
src/log.py
Normal file → Executable file
|
@ -173,6 +173,20 @@ def log_show(
|
|||
share
|
||||
"""
|
||||
|
||||
# Set up path with correct value if 'last' or 'last-X' magic keywords are used
|
||||
last = re.match(r"last(?:-(?P<position>[0-9]{1,6}))?$", path)
|
||||
if last:
|
||||
position = 1
|
||||
if last.group("position") is not None:
|
||||
position += int(last.group("position"))
|
||||
|
||||
logs = list(log_list()["operation"])
|
||||
|
||||
if position > len(logs):
|
||||
raise YunohostValidationError(f"There isn't that many logs", raw_msg=True)
|
||||
|
||||
path = logs[-position]["path"]
|
||||
|
||||
if share:
|
||||
filter_irrelevant = True
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue