Switch logs to use a single comprehension
This commit is contained in:
parent
33b31a2451
commit
e04c22867c
1 changed files with 4 additions and 2 deletions
|
@ -46,15 +46,17 @@ class SuperUserGetLogsForService(ApiResource):
|
||||||
if not service in get_services():
|
if not service in get_services():
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
logs = []
|
||||||
try:
|
try:
|
||||||
with open(app.config['SYSTEM_LOGS_FILE'], 'r') as f:
|
with open(app.config['SYSTEM_LOGS_FILE'], 'r') as f:
|
||||||
logs = f.readlines()
|
logs = [line for line in f if line.find(service + '[') >= 0]
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logger.exception('Cannot read logs')
|
logger.exception('Cannot read logs')
|
||||||
abort(400)
|
abort(400)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'logs': '\n'.join([log for log in logs if log.find(service + '[') >= 0])
|
'logs': '\n'.join(logs)
|
||||||
}
|
}
|
||||||
|
|
||||||
abort(403)
|
abort(403)
|
||||||
|
|
Reference in a new issue