From bb8b1b052df4d90a86b993616dc0c70249523fb9 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sun, 17 Nov 2019 16:29:12 +0100 Subject: [PATCH] Using /var/log/daemon.log or /var/log/syslog is pointless, these files logs many different things. Instead, we shall always return the logs from journalctl --- data/hooks/conf_regen/01-yunohost | 6 ++++++ data/templates/yunohost/services.yml | 12 ++++-------- locales/en.json | 1 - src/yunohost/service.py | 8 ++++---- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/data/hooks/conf_regen/01-yunohost b/data/hooks/conf_regen/01-yunohost index f22de7a53..7b9644c2a 100755 --- a/data/hooks/conf_regen/01-yunohost +++ b/data/hooks/conf_regen/01-yunohost @@ -101,6 +101,12 @@ for service, conf in new_services.items(): if conffiles: services[service]['conffiles'] = conffiles + # Remove legacy /var/log/daemon.log and /var/log/syslog from log entries + # because they are too general. Instead, now the journalctl log is + # returned by default which is more relevant. + if "log" in services[service]: + if services[service]["log"] in ["/var/log/syslog", "/var/log/daemon.log"]: + del services[service]["log"] if updated: with open('/etc/yunohost/services.yml-new', 'w') as f: diff --git a/data/templates/yunohost/services.yml b/data/templates/yunohost/services.yml index 351120a7d..540224f3a 100644 --- a/data/templates/yunohost/services.yml +++ b/data/templates/yunohost/services.yml @@ -2,10 +2,8 @@ nginx: log: /var/log/nginx test_conf: nginx -t needs_exposed_ports: [80, 443] -avahi-daemon: - log: /var/log/daemon.log -dnsmasq: - log: /var/log/daemon.log +avahi-daemon: {} +dnsmasq: {} fail2ban: log: /var/log/fail2ban.log dovecot: @@ -29,8 +27,7 @@ ssh: metronome: log: [/var/log/metronome/metronome.log,/var/log/metronome/metronome.err] needs_exposed_ports: [5222, 5269] -slapd: - log: /var/log/syslog +slapd: {} php7.0-fpm: log: /var/log/php7.0-fpm.log test_conf: php-fpm7.0 --test @@ -39,8 +36,7 @@ yunohost-api: yunohost-firewall: need_lock: true test_status: iptables -S | grep "^-A INPUT" | grep " --dport" | grep -q ACCEPT -nslcd: - log: /var/log/syslog +nslcd: {} glances: null nsswitch: null ssl: null diff --git a/locales/en.json b/locales/en.json index 7cdd6b667..6a6f629b4 100644 --- a/locales/en.json +++ b/locales/en.json @@ -544,7 +544,6 @@ "service_disabled": "The '{service:s}' service was turned off", "service_enable_failed": "Could not turn on the service '{service:s}'\n\nRecent service logs:{logs:s}", "service_enabled": "The '{service:s}' service was turned off", - "service_no_log": "No logs to display for the service '{service:s}'", "service_regen_conf_is_deprecated": "'yunohost service regen-conf' is deprecated! Please use 'yunohost tools regen-conf' instead.", "service_remove_failed": "Could not remove the service '{service:s}'", "service_removed": "'{service:s}' service removed", diff --git a/src/yunohost/service.py b/src/yunohost/service.py index 0125fd7e4..f43d7cca5 100644 --- a/src/yunohost/service.py +++ b/src/yunohost/service.py @@ -395,10 +395,7 @@ def service_log(name, number=50): if name not in services.keys(): raise YunohostError('service_unknown', service=name) - if 'log' not in services[name]: - raise YunohostError('service_no_log', service=name) - - log_list = services[name]['log'] + log_list = services[name].get('log', []) log_type_list = services[name].get('log_type', []) if not isinstance(log_list, list): @@ -408,6 +405,9 @@ def service_log(name, number=50): result = {} + # First we always add the logs from journalctl / systemd + result["journalctl"] = _get_journalctl_logs(name, int(number)).splitlines() + for index, log_path in enumerate(log_list): log_type = log_type_list[index]