From f9d3ae1084f978c01e47509b25fc9cbd598bfc3c Mon Sep 17 00:00:00 2001 From: BELLAHBIB Ayoub Date: Sun, 17 Mar 2024 18:58:22 +0100 Subject: [PATCH] show_log: support names 'last' and 'last-x' in path Co-authored-by: manor-tile <159947643+manor-tile@users.noreply.github.com> --- share/actionsmap.yml | 2 +- src/log.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) mode change 100644 => 100755 share/actionsmap.yml mode change 100644 => 100755 src/log.py diff --git a/share/actionsmap.yml b/share/actionsmap.yml old mode 100644 new mode 100755 index a98653551..bedf0841c --- a/share/actionsmap.yml +++ b/share/actionsmap.yml @@ -1976,7 +1976,7 @@ log: - display arguments: path: - help: Log file which to display the content + help: Log file which to display the content, or 'last' or 'last-X' to get the log in last-X position -n: full: --number help: Number of lines to display diff --git a/src/log.py b/src/log.py old mode 100644 new mode 100755 index fd7c62635..eb513e545 --- a/src/log.py +++ b/src/log.py @@ -173,6 +173,16 @@ def log_show( share """ + match_path = re.match(r"last(?:-(?P[0-9]{1,6}))?$", path) + + if match_path: + if match_path.group("position") == None: + position = 1 + else: + position = int(match_path.group("position")) + 1 + logs = log_list() + path = list(logs["operation"])[-position]["path"] + if share: filter_irrelevant = True