mirror of
https://github.com/huggingface/transformers.git
synced 2025-08-02 03:01:07 +06:00
logger doc
This commit is contained in:
parent
041fdc4a7e
commit
41168a49ce
@ -33,14 +33,37 @@ TRANSFORMERS_VERBOSITY=error ./myprogram.py
|
|||||||
```
|
```
|
||||||
|
|
||||||
Additionally, some `warnings` can be disabled by setting the environment variable
|
Additionally, some `warnings` can be disabled by setting the environment variable
|
||||||
`TRANSFORMERS_NO_ADVISORY_WARNINGS` to a true value, like *1*. This will disable any warning that is logged using
|
`TRANSFORMERS_NO_ADVISORY_WARNINGS` to a true value, like _1_. This will disable any warning that is logged using
|
||||||
[`logger.warning_advice`]. For example:
|
[`logger.warning_advice`]. For example:
|
||||||
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
TRANSFORMERS_NO_ADVISORY_WARNINGS=1 ./myprogram.py
|
TRANSFORMERS_NO_ADVISORY_WARNINGS=1 ./myprogram.py
|
||||||
```
|
```
|
||||||
|
|
||||||
|
It follows an usage example:
|
||||||
|
|
||||||
|
```python
|
||||||
|
from transformers.utils import logging
|
||||||
|
|
||||||
|
logging.set_verbosity_info()
|
||||||
|
logger = logging.get_logger(__name__)
|
||||||
|
logger.info("INFO")
|
||||||
|
logger.warning("WARN")
|
||||||
|
```
|
||||||
|
|
||||||
|
Above, a `logger` instance is created from `logging.get_logger(__name__)`. If you want to use `logging` in a script, you shouldn't pass `__name__` to `logging.get_logger`. For example:
|
||||||
|
|
||||||
|
```python
|
||||||
|
from transformers.utils import logging
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
logging.set_verbosity_info()
|
||||||
|
# leave it empy or use a string
|
||||||
|
logger = logging.get_logger()
|
||||||
|
logger.info("INFO")
|
||||||
|
logger.warning("WARN")
|
||||||
|
```
|
||||||
|
|
||||||
All the methods of this logging module are documented below, the main ones are
|
All the methods of this logging module are documented below, the main ones are
|
||||||
[`logging.get_verbosity`] to get the current level of verbosity in the logger and
|
[`logging.get_verbosity`] to get the current level of verbosity in the logger and
|
||||||
[`logging.set_verbosity`] to set the verbosity to the level of your choice. In order (from the least
|
[`logging.set_verbosity`] to set the verbosity to the level of your choice. In order (from the least
|
||||||
@ -54,7 +77,7 @@ verbose to the most verbose), those levels (with their corresponding int values
|
|||||||
- `transformers.logging.INFO` (int value, 20): reports error, warnings and basic information.
|
- `transformers.logging.INFO` (int value, 20): reports error, warnings and basic information.
|
||||||
- `transformers.logging.DEBUG` (int value, 10): report all information.
|
- `transformers.logging.DEBUG` (int value, 10): report all information.
|
||||||
|
|
||||||
By default, `tqdm` progress bars will be displayed during model download. [`logging.disable_progress_bar`] and [`logging.enable_progress_bar`] can be used to suppress or unsuppress this behavior.
|
By default, `tqdm` progress bars will be displayed during model download. [`logging.disable_progress_bar`] and [`logging.enable_progress_bar`] can be used to suppress or unsuppress this behavior.
|
||||||
|
|
||||||
## Base setters
|
## Base setters
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user