setup_logging

webbpsf.setup_logging(level='INFO', filename=None)[source]

Allows selection of logging detail and output locations (screen and/or file)

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

Editing the WebbPSF config file to set autoconfigure_logging = True (and any of the logging settings you wish to persist) instructs WebbPSF to apply your settings on import. (This is not done by default in case you have configured logging yourself and don’t wish to overwrite your configuration.)

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

Parameters:
levelstr

Name of log output to show. Defaults to ‘INFO’, set to ‘DEBUG’ for more extensive messages, or to ‘WARN’ or ‘ERROR’ for fewer.

filenamestr, optional

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

Examples

>>> webbpsf.setup_logging(filename='webbpsflog.txt')

This will save all log messages to ‘webbpsflog.txt’ in the current directory. If you later start another copy of webbpsf in a different directory, that session will also write to ‘webbpsflog.txt’ in that directory. Alternatively you can specify a fully qualified absolute path to save all your logs to one specific file.

>>> webbpsf.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)