Commit 64959046 authored by Thomas Bernhart's avatar Thomas Bernhart
Browse files

Improve logging setup

parent 0dc8ee84
......@@ -29,16 +29,30 @@ def _normalize_file_extension(original_file_name):
return file_ext_mapping.get(k=ext.lower(), default=ext.lower())
def _create_logger(name, logfile):
# configure logger:
logger = logging.getLogger(name)
logger.setLevel(logging.DEBUG)
logging_formatter = logging.Formatter('%(asctime)s | %(name)s | %(levelname)s: %(message)s')
logging_streamh = logging.StreamHandler()
logging_streamh.setLevel(logging.ERROR)
logging_streamh.setFormatter(logging_formatter)
logging_fh = logging.FileHandler(logfile)
logging_fh.setLevel(logging.INFO)
logging_fh.setFormatter(logging_formatter)
logger.addHandler(logging_streamh)
logger.addHandler(logging_fh)
return logger
def foxml_export(objectstore_path, output_path, recordsets_csv_file):
if not path.exists(output_path):
makedirs(output_path)
# configure logger:
logger = logging.getLogger("foxml_export")
logger.setLevel(logging.ERROR)
logging_fh = logging.FileHandler(path.join(output_path, "foxml_export.log"))
logging_fh.setLevel(logging.INFO)
logger.addHandler(logging_fh)
logger = _create_logger("foxml_export", path.join(output_path, "foxml_export.log"))
recordset_id_mapper = RecordSetIdMapper(recordsets_csv_file)
......@@ -75,12 +89,7 @@ def foxml_export(objectstore_path, output_path, recordsets_csv_file):
def media_export(record_set_path, datastreamstore_path, http_files_path, rtmp_files_path):
# configure logger:
logger = logging.getLogger("media_export")
logger.setLevel(logging.ERROR)
logging_fh = logging.FileHandler(path.join(record_set_path, "media_export.log"))
logging_fh.setLevel(logging.INFO)
logger.addHandler(logging_fh)
logger = _create_logger("media_export", path.join(record_set_path, "media_export.log"))
for foxml_path in listdir(record_set_path):
logger.debug("Exporting media files for file: '" + foxml_path + "'")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment