diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 9dfb4a499..98357702b 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -505,6 +505,14 @@ app: full: --sql help: Initial SQL file + ### app_debug() + debug: + action_help: Display all debug informations for an application + api: GET /apps//debug + arguments: + app: + help: App name + ### app_makedefault() makedefault: action_help: Redirect domain root to an app diff --git a/lib/yunohost/app.py b/lib/yunohost/app.py index 688f8a4f7..57f7676fc 100644 --- a/lib/yunohost/app.py +++ b/lib/yunohost/app.py @@ -39,6 +39,8 @@ import subprocess from moulinette.core import MoulinetteError from moulinette.utils.log import getActionLogger +from .service import service_log + logger = getActionLogger('yunohost.app') repo_path = '/var/cache/yunohost/repo' @@ -722,6 +724,29 @@ def app_clearaccess(auth, apps): app_ssowatconf(auth) +def app_debug(app): + """ + Display debug informations for an app + + Keyword argument: + app + """ + with open(apps_setting_path + app + '/manifest.json') as f: + manifest = json.loads(f.read()) + + return { + 'name': manifest['id'], + 'label': manifest['name'], + 'services': [{ + "name": x, + "logs": [{ + "file_name": y, + "file_content": "\n".join(z), + } for (y, z) in sorted(service_log(x).items(), key=lambda x: x[0])], + } for x in sorted(manifest.get("services", []))] + } + + def app_makedefault(auth, app, domain=None): """ Redirect domain root to an app