I started tinkering with logging and BLE. Now I got this piece of code I took from the bgapi package. I think I kind of understand how it works, but I'd like to see the output in a file or in the workspace. How would I achieve this?
def pipe_logs_to_terminal(self, level=logging.INFO):
term = logging.StreamHandler(sys.stdout)
formatter = logging.Formatter(self._api._serial.portstr + ': %(asctime)s -
%(name)s - %(levelname)s - %(message)s')
term.setFormatter(formatter)
api_logger = logging.getLogger("bgapi")
api_logger.addHandler(term)
api_logger.setLevel(level=level)
logging.StreamHandler(sys.stdout)
to a file instead of stdout. Questions are encouraged to provide a Minimum Complete and Verifiable Example, try to improve yours.