Add ability to download system logs
This commit is contained in:
parent
5c7a9d0daf
commit
4ca877c1d4
9 changed files with 78 additions and 19 deletions
15
util/systemlogs.py
Normal file
15
util/systemlogs.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
import tarfile
|
||||
import os
|
||||
import cStringIO
|
||||
|
||||
def build_logs_archive(app):
|
||||
""" Builds a .tar.gz with the contents of the system logs found for the given app and returns
|
||||
the binary contents.
|
||||
"""
|
||||
path = app.config['SYSTEM_LOGS_PATH']
|
||||
buf = cStringIO.StringIO()
|
||||
|
||||
with tarfile.open(mode="w:gz", fileobj=buf) as tar:
|
||||
tar.add(path, arcname=os.path.basename(path))
|
||||
|
||||
return buf.getvalue()
|
Reference in a new issue