def setUpClass(cls) -> None:
        cls.moduleName = os.path.splitext(inspect.getfile(cls))[0]
        cls.log = logging.getLogger(cls.__name__)

        # Set logging to file and stdout if the LOG_LEVEL environment variable
        # is set.
        if os.getenv('LOG_LEVEL'):
            # Set up formatter.
            log_fmt = ('{}.%(funcName)s:%(levelname)s:%(asctime)s:'
                       ' %(message)s'.format(cls.__name__))
            formatter = logging.Formatter(log_fmt)

            # Set up the file handler.
            log_file_name = '%s.log' % cls.moduleName
            file_handler = logging.FileHandler(log_file_name)
            file_handler.setFormatter(formatter)
            cls.log.addHandler(file_handler)

            # Set the logging level from the environment variable, defaulting
            # to INFO if it is not a valid level.
            level = logging._nameToLevel.get(os.getenv('LOG_LEVEL'),
                                             logging.INFO)
            cls.log.setLevel(level)
            # set all domains logging
            set_logging_level(level, list(QiskitLogDomains), log_file_name)
Пример #2
0
def set_qiskit_chemistry_logging(level: int, filepath: Optional[str] = None) -> None:
    """Updates the Qiskit chemistry logging with the appropriate logging level

    Args:
        level: minimum severity of the messages that are displayed.
        filepath: file to receive logging data
    """
    set_logging_level(level, [QiskitLogDomains.DOMAIN_CHEMISTRY], filepath)
def set_qiskit_optimization_logging(level: int, filepath: Optional[str] = None) -> None:
    """Updates the Qiskit optimization logging with the appropriate logging level

    Args:
        level: minimum severity of the messages that are displayed.
        filepath: file to receive logging data
    """
    set_logging_level(level, [QiskitLogDomains.DOMAIN_OPTIMIZATION], filepath)
Пример #4
0
def set_qiskit_finance_logging(level: int,
                               filepath: Optional[str] = None) -> None:
    """Updates the Qiskit finance logging with the appropriate logging level.

    Args:
        level: minimum severity of the messages that are displayed.
        filepath: file to receive logging data
    """
    set_logging_level(level, [QiskitLogDomains.DOMAIN_FINANCE], filepath)