Note

Download this example as a Jupyter notebook here: pypsa/atlite

Logfiles and messages#

Atlite uses the logging library for displaying messages with different purposes.

Minimum information#

We recommend that you always use logging when using atlite with information messages enabled.

The simplest way is to

[ ]:
import logging

logging.basicConfig(level=logging.INFO)

This will prompt messagges with the priority level of “information”.

Our recommendation#

[ ]:
import warnings
import logging

warnings.simplefilter("default", DeprecationWarning)
logging.captureWarnings(True)
logging.basicConfig(level=logging.INFO)

Maximum information (aka ‘Information overload’)#

This configuration will nag you about nearly everything there is every time. Use it for debugging.

[ ]:
import warnings
import logging

warnings.simplefilter("always", DeprecationWarning)
logging.captureWarnings(True)
logging.basicConfig(level=logging.DEBUG)

Adjusting the level of detail/verbosity#

Usually recieving information messages is enough verbosity, i.e.

[ ]:
logging.basicConfig(level=logging.INFO)

When debugging your programm you might want to recieve more detailed information on what is going on and include further debugging messages. To do so:

[ ]:
logging.basicConfig(level=logging.DEBUG)

Creating logfiles#

When running automated scripts or for documentation purposes, you might want to redirect and save the logging output in a log file. To do so, simply add the filename argument to your basicConfig call as shown below and substite example.log for your preferred logfile name

[ ]:
logging.basicConfig(filename="example.log", level=logging.INFO)

(Deprecation) warnings#

When features of the programme (or underlying libraries) become obsolete (deprecated), users nowadays usually do not get a warning. (More details on that here)

We recommend you turn on those warnings to get a headsup if you are using features which will be removed in future releases.

To enable the warnings and have the logging library handle them, use the following lines at the beginning of your code

[ ]:
import warnings

warnings.simplefilter("always", DeprecationWarning)
logging.captureWarnings(True)