diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 8e3c2ed54..209525de0 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -1693,3 +1693,6 @@ log: help: Number of lines to display default: 50 type: int + --share: + help: Share the full log using yunopaste + action: store_true diff --git a/locales/en.json b/locales/en.json index 97425a4bd..c6310f6fb 100644 --- a/locales/en.json +++ b/locales/en.json @@ -211,7 +211,7 @@ "log_link_to_log": "Full log of this operation: '{desc}'", "log_help_to_get_log": "To view the log of the operation '{desc}', use the command 'yunohost log display {name}'", "log_link_to_failed_log": "The operation '{desc}' has failed ! To get help, please provide the full log of this operation", - "log_help_to_get_failed_log": "The operation '{desc}' has failed ! To get help, please provide the full log of this operation. It can be obtained with the command 'yunohost log display {name}'", + "log_help_to_get_failed_log": "The operation '{desc}' has failed ! To get help, please share the full log of this operation using the command 'yunohost log display {name} --share'", "log_category_404": "The log category '{category}' does not exist", "log_does_exists": "There is not operation log with the name '{log}', use 'yunohost log list to see all available operation logs'", "log_operation_unit_unclosed_properly": "Operation unit has not been closed properly", diff --git a/src/yunohost/log.py b/src/yunohost/log.py index e9ce97bf8..f079a3894 100644 --- a/src/yunohost/log.py +++ b/src/yunohost/log.py @@ -36,6 +36,7 @@ from sys import exc_info from moulinette import m18n, msettings from moulinette.core import MoulinetteError from moulinette.utils.log import getActionLogger +from moulinette.utils.filesystem import read_file CATEGORIES_PATH = '/var/log/yunohost/categories/' OPERATIONS_PATH = '/var/log/yunohost/categories/operation/' @@ -103,7 +104,7 @@ def log_list(category=[], limit=None): return result -def log_display(path, number=50): +def log_display(path, number=50, share=False): """ Display a log file enriched with metadata if any. @@ -113,6 +114,7 @@ def log_display(path, number=50): Argument: file_name number + share """ # Normalize log/metadata paths and filenames @@ -147,6 +149,17 @@ def log_display(path, number=50): infos["description"] = _get_description_from_name(base_filename) infos['name'] = base_filename + if share: + from yunohost.utils.yunopaste import yunopaste + content = "" + if os.path.exists(md_path): + content += read_file(md_path) + content += "\n============\n\n" + if os.path.exists(log_path): + content += read_file(log_path) + + return yunopaste(content) + # Display metadata if exist if os.path.exists(md_path): with open(md_path, "r") as md_file: