From 0a5bf3d021680def73a024a211501e07b4fc5c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 8 Nov 2021 10:01:38 +0100 Subject: [PATCH] Fix dump_script_log_extract_for_debugging : We want to catch the last exit in the logs, not the first one. --- src/yunohost/log.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/yunohost/log.py b/src/yunohost/log.py index d73a62cd0..b4f8e181b 100644 --- a/src/yunohost/log.py +++ b/src/yunohost/log.py @@ -753,8 +753,16 @@ class OperationLogger(object): filters = [re.compile(f_) for f_ in filters] lines_to_display = [] - for line in lines: + # The logs may contain multiple ynh_exit_properly (backup + upgrade e.g) + # We want to get the last one. + rev_lines = reversed(lines) + for line in rev_lines: + if line.endswith("+ ynh_exit_properly") or " + ynh_die " in line: + lines_to_display.append(line) + break + + for line in rev_lines: if ": " not in line.strip(): continue @@ -768,10 +776,10 @@ class OperationLogger(object): lines_to_display.append(line) - if line.endswith("+ ynh_exit_properly") or " + ynh_die " in line: + if len(lines_to_display) > 20: break - elif len(lines_to_display) > 20: - lines_to_display.pop(0) + + lines_to_display.reverse() logger.warning( "Here's an extract of the logs before the crash. It might help debugging the error:"