Logging test — Python documentation

Note

Click here to download the full example code

# Logging test

    import logging
    import sys

    def _create_logger(name=None):
        logger = logging.getLogger(name=name)
        logger.setLevel(logging.INFO)
        sh = logging.StreamHandler(sys.stdout)
        sh.setLevel(logging.INFO)
        logger.addHandler(sh)
        return logger

    logger = _create_logger("first_logger")
    logger.info("is in the same cell")

Out:

    is in the same cell

    logger.info("is not in the same cell")

Out:

    is not in the same cell

Total running time of the script: ( 0 minutes 0.002 seconds)

Gallery generated by Sphinx-Gallery