from logging import Logger import logging from typing import cast from tudelft_utilities_logging.Reporter import Reporter # initialize the logging, otherwise it seems not to work properly logging.basicConfig() class ReportToLogger ( Reporter ): ''' dumps the reported messages into a log file with the given name. This really tries hard to avoid any writing to stdout/stderr, because those are used for the communicatino to the party. ''' def __init__(self, logname:str): ''' @param logname the name for the Logger ''' super().__init__() self._logger:Logger = logging.getLogger(logname) def log(self, level:int , msg:str, thrown: BaseException=None) -> None: # We use the internal function, the only way to include our exception... self._logger._log(level=level, msg=msg, args=[], exc_info=thrown,\ stack_info=True if thrown else False)