This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/data/archivedlogs.py

38 lines
1 KiB
Python
Raw Normal View History

import logging
from util.registry.gzipinputstream import GzipInputStream
from flask import send_file, abort
from data.userfiles import DelegateUserfiles, UserfilesHandlers
2014-09-08 20:43:17 +00:00
JSON_MIMETYPE = 'application/json'
logger = logging.getLogger(__name__)
2014-09-08 20:43:17 +00:00
class LogArchive(object):
def __init__(self, app=None, distributed_storage=None):
2014-09-08 20:43:17 +00:00
self.app = app
if app is not None:
self.state = self.init_app(app, distributed_storage)
2014-09-08 20:43:17 +00:00
else:
self.state = None
def init_app(self, app, distributed_storage):
location = app.config.get('LOG_ARCHIVE_LOCATION')
path = app.config.get('LOG_ARCHIVE_PATH', None)
2014-09-08 20:43:17 +00:00
handler_name = 'web.logarchive'
2014-09-08 20:43:17 +00:00
2016-04-15 17:51:54 +00:00
log_archive = DelegateUserfiles(app, distributed_storage, location, path,
handler_name=handler_name)
2014-09-08 20:43:17 +00:00
# register extension with app
app.extensions = getattr(app, 'extensions', {})
app.extensions['log_archive'] = log_archive
return log_archive
2014-09-08 20:43:17 +00:00
def __getattr__(self, name):
return getattr(self.state, name, None)