Skip to content

Commit

Permalink
logging documentation update (huggingface#17174)
Browse files Browse the repository at this point in the history
* logging documentation

* style

Co-authored-by: Sander Land <sander@chatdesk.com>
  • Loading branch information
2 people authored and elusenji committed Jun 12, 2022
1 parent e84f753 commit bc4b43f
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions docs/source/en/main_classes/logging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,17 @@ Additionally, some `warnings` can be disabled by setting the environment variabl
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
from transformers.utils import logging

logging.set_verbosity_info()
logger = logging.get_logger(__name__)
logger = logging.get_logger("transformers")
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
[`logging.get_verbosity`] to get the current level of verbosity in the logger and
Expand Down

0 comments on commit bc4b43f

Please sign in to comment.