.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_auto_examples/plot_logging_to_terminal.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr__auto_examples_plot_logging_to_terminal.py: Logging to terminal =================== On this example we show how to make all log messages show in the terminal. .. GENERATED FROM PYTHON SOURCE LINES 9-10 # Imports .. GENERATED FROM PYTHON SOURCE LINES 10-18 .. code-block:: python from uuid import uuid4 from tempfile import gettempdir from os.path import join from aequilibrae.utils.create_example import create_example from aequilibrae import logger import logging import sys .. GENERATED FROM PYTHON SOURCE LINES 19-20 We create the example project inside our temp folder .. GENERATED FROM PYTHON SOURCE LINES 20-23 .. code-block:: python fldr = join(gettempdir(), uuid4().hex) project = create_example(fldr) .. GENERATED FROM PYTHON SOURCE LINES 24-25 With the project open, we can tell the logger to direct all messages to the terminal as well .. GENERATED FROM PYTHON SOURCE LINES 25-30 .. code-block:: python stdout_handler = logging.StreamHandler(sys.stdout) formatter = logging.Formatter("%(asctime)s;%(name)s;%(levelname)s ; %(message)s") stdout_handler.setFormatter(formatter) logger.addHandler(stdout_handler) .. GENERATED FROM PYTHON SOURCE LINES 31-33 .. code-block:: python project.close() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none 2022-03-30 06:32:19,517;aequilibrae;INFO ; Closed project on /tmp/7a4c089b3574449282fe6809caf70406 .. GENERATED FROM PYTHON SOURCE LINES 34-35 **Want to see what you will get?** .. GENERATED FROM PYTHON SOURCE LINES 37-42 .. code-block:: python from PIL import Image import matplotlib.pyplot as plt img = Image.open('plot_logging_to_terminal_image.png') plt.imshow(img) .. image-sg:: /_auto_examples/images/sphx_glr_plot_logging_to_terminal_001.png :alt: plot logging to terminal :srcset: /_auto_examples/images/sphx_glr_plot_logging_to_terminal_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.555 seconds) .. _sphx_glr_download__auto_examples_plot_logging_to_terminal.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_logging_to_terminal.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_logging_to_terminal.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_