[enh] Better help for log list action

This commit is contained in:
ljf 2018-06-04 04:04:10 +02:00
parent 89124d4a9f
commit 5676f05dfb
3 changed files with 9 additions and 3 deletions

View file

@ -1614,8 +1614,8 @@ log:
action_help: List logs
api: GET /logs
arguments:
categories:
help: Log categories to display (default operations)
category:
help: Log category to display (default operations), could be operation, history, package, system, access, service or app
nargs: "*"
-l:
full: --limit

View file

@ -206,6 +206,7 @@
"ip6tables_unavailable": "You cannot play with ip6tables here. You are either in a container or your kernel does not support it",
"iptables_unavailable": "You cannot play with iptables here. You are either in a container or your kernel does not support it",
"log_corrupted_md_file": "The yaml metadata file associated with logs is corrupted : '{md_file}'",
"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",
"log_app_removelist": "Remove an application list",

View file

@ -46,7 +46,7 @@ RELATED_CATEGORIES = ['app', 'domain', 'service', 'user']
logger = getActionLogger('yunohost.log')
def log_list(categories=[], limit=None):
def log_list(category=[], limit=None):
"""
List available logs
@ -54,6 +54,9 @@ def log_list(categories=[], limit=None):
limit -- Maximum number of logs
"""
categories = category
# In cli we just display `operation` logs by default
if not categories:
is_api = msettings.get('interface') == 'api'
categories = ["operation"] if not is_api else CATEGORIES
@ -64,6 +67,8 @@ def log_list(categories=[], limit=None):
category_path = os.path.join(CATEGORIES_PATH, category)
if not os.path.exists(category_path):
logger.warning(m18n.n('log_category_404', category=category))
continue
logs = filter(lambda x: x.endswith(METADATA_FILE_EXT), os.listdir(category_path))