Skip to content

Commit 4a46291

Browse files
committed
add logging in the doc
1 parent 4c1ca1b commit 4a46291

File tree

3 files changed

+76
-1
lines changed

3 files changed

+76
-1
lines changed

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,4 @@ The documentation is organized in five parts:
7373
package_reference/loading_methods
7474
package_reference/main_classes
7575
package_reference/builder_classes
76+
package_reference/logging_methods
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Logging methods
2+
----------------------------------------------------
3+
4+
`nlp` tries to be very transparent and explicit about it's inner working bt this can be quite verbose at some time.
5+
A series of logging methods let you easily adjust the level of logging of the whole library.
6+
7+
Functions
8+
~~~~~~~~~~~~~~~~~~~~~
9+
10+
.. autofunction:: nlp.logging.get_verbosity
11+
12+
.. autofunction:: nlp.logging.set_verbosity
13+
14+
.. autofunction:: nlp.logging.set_verbosity_info
15+
16+
.. autofunction:: nlp.logging.set_verbosity_warning
17+
18+
.. autofunction:: nlp.logging.set_verbosity_debug
19+
20+
.. autofunction:: nlp.logging.set_verbosity_error
21+
22+
.. autofunction:: nlp.logging.disable_default_handler
23+
24+
.. autofunction:: nlp.logging.enable_default_handler
25+
26+
.. autofunction:: nlp.logging.disable_propagation
27+
28+
.. autofunction:: nlp.logging.enable_propagation
29+
30+
.. autofunction:: nlp.logging.get_logger
31+
32+
Levels
33+
~~~~~~~~~~~~~~~~~~~~~
34+
35+
.. autodata:: nlp.logging.CRITICAL
36+
37+
.. autodata:: nlp.logging.DEBUG
38+
39+
.. autodata:: nlp.logging.ERROR
40+
41+
.. autodata:: nlp.logging.FATAL
42+
43+
.. autodata:: nlp.logging.INFO
44+
45+
.. autodata:: nlp.logging.NOTSET
46+
47+
.. autodata:: nlp.logging.WARN
48+
49+
.. autodata:: nlp.logging.WARNING
50+

src/nlp/utils/logging.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def _reset_library_root_logger() -> None:
7676

7777
def get_logger(name: Optional[str] = None) -> logging.Logger:
7878
"""Return a logger with the specified name.
79-
This function is not supposed to be directly accessed by library users.
79+
This function can be used in dataset and metrics scripts.
8080
"""
8181

8282
if name is None:
@@ -115,18 +115,42 @@ def set_verbosity(verbosity: int) -> None:
115115

116116

117117
def set_verbosity_info():
118+
"""Set the level for the HuggingFace Transformers's root logger to INFO.
119+
120+
This will display most of the logging information and tqdm bars.
121+
122+
Shortcut to ``nlp.logging.set_verbosity(nlp.logging.INFO)``
123+
"""
118124
return set_verbosity(INFO)
119125

120126

121127
def set_verbosity_warning():
128+
"""Set the level for the HuggingFace Transformers's root logger to WARNING.
129+
130+
This will display only the warning and errors logging information (no tqdm bars).
131+
132+
Shortcut to ``nlp.logging.set_verbosity(nlp.logging.WARNING)``
133+
"""
122134
return set_verbosity(WARNING)
123135

124136

125137
def set_verbosity_debug():
138+
"""Set the level for the HuggingFace Transformers's root logger to DEBUG.
139+
140+
This will display all the logging information and tqdm bars.
141+
142+
Shortcut to ``nlp.logging.set_verbosity(nlp.logging.DEBUG)``
143+
"""
126144
return set_verbosity(DEBUG)
127145

128146

129147
def set_verbosity_error():
148+
"""Set the level for the HuggingFace Transformers's root logger to ERROR.
149+
150+
This will display only the errors logging information (no tqdm bars).
151+
152+
Shortcut to ``nlp.logging.set_verbosity(nlp.logging.ERROR)``
153+
"""
130154
return set_verbosity(ERROR)
131155

132156

0 commit comments

Comments
 (0)