
.. 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 <sphx_glr_download__auto_examples_other_applications_plot_logging_to_terminal.py>`
        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-20

.. code-block:: Python


    # Imports
    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 22-28

.. code-block:: Python


    # We create the example project inside our temp folder
    fldr = join(gettempdir(), uuid4().hex)
    project = create_example(fldr)
    logger = project.logger








.. GENERATED FROM PYTHON SOURCE LINES 29-30

With the project open, we can tell the logger to direct all messages to the terminal as well

.. GENERATED FROM PYTHON SOURCE LINES 30-35

.. 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 36-37

.. code-block:: Python

    project.close()








.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 0.116 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 <plot_logging_to_terminal.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: plot_logging_to_terminal.py <plot_logging_to_terminal.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: plot_logging_to_terminal.zip <plot_logging_to_terminal.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
