Add logging argument options

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
This commit is contained in:
Hiroshi Miura
2019-09-28 11:41:53 +09:00
parent 1786b69337
commit 886376d81b
5 changed files with 71 additions and 20 deletions

View File

@@ -21,12 +21,12 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import functools
import logging
import os
import py7zr
import requests
import traceback
import xml.etree.ElementTree as ElementTree
from logging import getLogger
from six import StringIO
from multiprocessing.dummy import Pool
from operator import and_
@@ -47,8 +47,13 @@ class QtInstaller:
Installer class to download packages and extract it.
"""
def __init__(self, qt_archives):
def __init__(self, qt_archives, logging=None):
self.qt_archives = qt_archives
if logging:
self.logger = logging
else:
self.logger = getLogger('aqt')
@staticmethod
def retrieve_archive(package, path=None, command=None):
@@ -126,7 +131,7 @@ class QtInstaller:
print("Configuration file generation error: %s" % e.args)
exc_buffer = StringIO()
traceback.print_exc(file=exc_buffer)
logging.error('Error happened when writing configuration files:\n%s', exc_buffer.getvalue())
self.logger.error('Error happened when writing configuration files:\n%s', exc_buffer.getvalue())
raise e
else:
exit(1)