.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_auto_examples/other_applications/plot_logging_to_terminal.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr__auto_examples_other_applications_plot_logging_to_terminal.py: .. _logging_to_terminal: Logging to terminal =================== In this example, we show how to make all log messages show in the terminal. .. GENERATED FROM PYTHON SOURCE LINES 11-12 Imports .. GENERATED FROM PYTHON SOURCE LINES 12-19 .. code-block:: Python from uuid import uuid4 from tempfile import gettempdir from os.path import join from aequilibrae.utils.create_example import create_example import logging import sys .. GENERATED FROM PYTHON SOURCE LINES 21-22 We create the example project inside our temp folder .. GENERATED FROM PYTHON SOURCE LINES 22-26 .. code-block:: Python fldr = join(gettempdir(), uuid4().hex) project = create_example(fldr) logger = project.logger .. GENERATED FROM PYTHON SOURCE LINES 27-28 With the project open, we can tell the logger to direct all messages to the terminal as well .. GENERATED FROM PYTHON SOURCE LINES 28-33 .. code-block:: Python stdout_handler = logging.StreamHandler(sys.stdout) formatter = logging.Formatter("%(asctime)s;%(levelname)s ; %(message)s") stdout_handler.setFormatter(formatter) logger.addHandler(stdout_handler) .. GENERATED FROM PYTHON SOURCE LINES 34-35 .. code-block:: Python project.close() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.123 seconds) .. _sphx_glr_download__auto_examples_other_applications_plot_logging_to_terminal.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_logging_to_terminal.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_logging_to_terminal.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_