Logging

Logging#

Some basic logging is implemented through the standard Python logging module.

  1. To enable logging output from all ZOSPy and other modules using logging.basicConfig:

    import logging
    
    logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
    
  2. To enable logging output from all ZOSPy and other modules using a root logger:

    import logging
    
    fmt = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
    sh = logging.StreamHandler()
    sh.setFormatter(fmt)
    sh.setLevel(logging.DEBUG)
    
    logger = logging.getLogger()
    logger.addHandler(sh)
    
  3. To enable logging output from only ZOSPy

    import logging
    
    logging.getLogger("zospy").addHandler(logging.StreamHandler())
    logging.getLogger("zospy").setLevel(logging.INFO)