mirror of
https://github.com/huggingface/transformers.git
synced 2025-08-01 18:51:14 +06:00
logging documentation update (#17174)
* logging documentation * style Co-authored-by: Sander Land <sander@chatdesk.com>
This commit is contained in:
parent
8600d770d4
commit
053a80c606
@ -40,29 +40,17 @@ Additionally, some `warnings` can be disabled by setting the environment variabl
|
|||||||
TRANSFORMERS_NO_ADVISORY_WARNINGS=1 ./myprogram.py
|
TRANSFORMERS_NO_ADVISORY_WARNINGS=1 ./myprogram.py
|
||||||
```
|
```
|
||||||
|
|
||||||
Here is an example of how to use `logging` in a module:
|
Here is an example of how to use the same logger as the library in your own module or script:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from transformers.utils import logging
|
from transformers.utils import logging
|
||||||
|
|
||||||
logging.set_verbosity_info()
|
logging.set_verbosity_info()
|
||||||
logger = logging.get_logger(__name__)
|
logger = logging.get_logger("transformers")
|
||||||
logger.info("INFO")
|
logger.info("INFO")
|
||||||
logger.warning("WARN")
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user