[docs]defsetup_logs(folder:str):""" General command to setup system wide logging. Two logs are setup, a core log and a harware log. The hardware logs records everything releated to the hardware interfaces whilst the core logs records all the analysis and related modules. """# Here we set up the logging format. This will be the same for every loggerformatter=logging.Formatter('%(asctime)s [%(name)s] - %(levelname)s: %(message)s')autoDEER_log=logging.getLogger('autoDEER')interface_log=logging.getLogger('interface')logHandler_core=handlers.TimedRotatingFileHandler(os.path.join(folder,'autoDEER.log'),when='D',backupCount=4)logHandler_core.setFormatter(formatter)autoDEER_log.setLevel(logging.INFO)autoDEER_log.addHandler(logHandler_core)QTHandler=QtLogHandler()QTHandler.setFormatter(DictFormater())autoDEER_log.addHandler(QTHandler)logHandler_hardware=handlers.TimedRotatingFileHandler(os.path.join(folder,'interface.log'),when='D',backupCount=4)logHandler_hardware.setFormatter(formatter)interface_log.setLevel(logging.INFO)interface_log.addHandler(logHandler_hardware)interface_log.addHandler(QTHandler)
[docs]defchange_log_level(core='INFO',interface='INFO'):""" Change the log level of the core and hardware loggers. Parameters ---------- core : str The log level for the core logger. interface : str The log level for the hardware logger. """logging.getLogger('autoDEER').setLevel(core)logging.getLogger('autoDEER').info(f'Level set to {core}')logging.getLogger('interface').setLevel(interface)logging.getLogger('interface').info(f'Level set to {interface}')