adding TRANSFORMERS_VERBOSITY env var (#6961)

* introduce TRANSFORMERS_VERBOSITY env var + test + test helpers

* cleanup

* remove helper function
This commit is contained in:
Stas Bekman
2020-09-09 01:08:01 -07:00
committed by GitHub
parent f0fc0aea6b
commit d0963486c1
4 changed files with 163 additions and 4 deletions

View File

@@ -1,15 +1,23 @@
Logging
-------
🤗 Transformers has a centralized logging system, so that you can setup the verbosity of the library easily. To
change the level of verbosity, just use one of the direct setters. For instance, here is how to change the verbosity to
the INFO level.
🤗 Transformers has a centralized logging system, so that you can setup the verbosity of the library easily.
Currently the default verbosity of the library is ``WARNING``.
To change the level of verbosity, just use one of the direct setters. For instance, here is how to change the verbosity to the INFO level.
.. code-block:: python
import transformers
transformers.logging.set_verbosity_info()
You can also use the environment variable ``TRANSFORMERS_VERBOSITY`` to override the default verbosity. You can set it to one of the following: ``debug``, ``info``, ``warning``, ``error``, ``critical``. For example:
.. code-block:: bash
TRANSFORMERS_VERBOSITY=error ./myprogram.py
All the methods of this logging module are documented below, the main ones are
:func:`transformers.logging.get_verbosity` to get the current level of verbosity in the logger and
:func:`transformers.logging.set_verbosity` to set the verbosity to the level of your choice. In order (from the least