Download this example as a Jupyter notebook here: https://github.com/pypsa/atlite/examples/logfiles_and_messages.ipynb
Logfiles and messages¶
Atlite uses the
logging library for displaying messages with different purposes.
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”.
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.
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:
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
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)