webbpsf_ext.logging_utils.setup_logging

webbpsf_ext.logging_utils.setup_logging(level='INFO', filename=None, verbose=True)[source]

Setup Logging

Allows selection of logging detail and output locations (screen and/or file). Shamelessly stolen from WebbPSF utils.py.

This is a convenience wrapper to Python’s built-in logging package. By default, this sets up log messages to be written to the screen, but the user can also request logging to a file.

For more advanced log handling, see the Python logging module’s own documentation.

Parameters
  • level (str) – Name of log output to show. Defaults to ‘INFO’, set to ‘DEBUG’ for more extensive messages, or to ‘WARN’ or ‘ERROR’ for fewer.

  • filename (str, optional) – Filename to write the log output to. If not set, output will just be displayed on screen. (Default: None)

Examples

>>> webbpsf_ext.setup_logging(filename='webbpsf_ext_log.txt')

This will save all log messages to ‘webbpsf_ext_log.txt’ in the current directory.

>>> webbpsf_ext.setup_logging(level='WARN')

This will show only WARNING or ERROR messages on screen, and not save any logs to files at all (since the filename argument is None)