From bc4b43f8492c3fbfeaf95ce7eab7e676a84665e1 Mon Sep 17 00:00:00 2001 From: Sander Land <48946947+sanderland@users.noreply.github.com> Date: Mon, 16 May 2022 22:47:28 +0200 Subject: [PATCH] logging documentation update (#17174) * logging documentation * style Co-authored-by: Sander Land --- docs/source/en/main_classes/logging.mdx | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/docs/source/en/main_classes/logging.mdx b/docs/source/en/main_classes/logging.mdx index 3137be805cadc4..9d4432a7290d0f 100644 --- a/docs/source/en/main_classes/logging.mdx +++ b/docs/source/en/main_classes/logging.mdx @@ -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