Merge pull request #136 from coreos-inc/syslogviewfix

Fix logs view in superuser panel
This commit is contained in:
Jake Moshenko 2015-07-15 18:22:23 -04:00
commit c64e490059
2 changed files with 7 additions and 5 deletions

View file

@ -204,8 +204,8 @@ class DefaultConfig(object):
# System logs.
SYSTEM_LOGS_PATH = "/var/log/"
SYSTEM_SERVICE_LOGS_PATH = "/var/log/%s/current"
SYSTEM_SERVICES_PATH = "conf/init/"
SYSTEM_LOGS_FILE = "/var/log/syslog"
SYSTEM_SERVICES_PATH = "conf/init/service/"
# Services that should not be shown in the logs view.
SYSTEM_SERVICE_BLACKLIST = []

View file

@ -50,15 +50,17 @@ class SuperUserGetLogsForService(ApiResource):
if not service in get_services():
abort(404)
logs = []
try:
with open(app.config['SYSTEM_SERVICE_LOGS_PATH'] % service, 'r') as f:
logs = f.read()
with open(app.config['SYSTEM_LOGS_FILE'], 'r') as f:
logs = [line for line in f if line.find(service + '[') >= 0]
except Exception as ex:
logger.exception('Cannot read logs')
abort(400)
return {
'logs': logs
'logs': '\n'.join(logs)
}
abort(403)