-
Ann-Kathrin Margarete Edrich authoredAnn-Kathrin Margarete Edrich authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
initialise_log.py 725 B
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import logging
def save_log(path):
"""
Initialisation of a log file using the python package logging to store
information, warnings and errors
Input:
path: Path where to store the log file
Output:
logger: Logger
"""
path_log = os.path.dirname(path)
logger = logging.getLogger()
logger.setLevel(logging.INFO)
formatter = logging.Formatter(
'%(asctime)s | %(levelname)s | %(message)s')
file_handler = logging.FileHandler(path)
file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(formatter)
logger.addHandler(file_handler)
return logger