Skip to content

DOC: Improve documentation for set_loglevel #24925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,22 @@ def _ensure_handler():

def set_loglevel(level):
"""
Set Matplotlib's root logger and root logger handler level, creating
the handler if it does not exist yet.
Configure Matplotlib's logging levels.

Matplotlib uses the standard library `logging` framework under the root
logger 'matplotlib'. This is a helper function to:

- set Matplotlib's root logger level
- set the root logger handler's level, creating the handler
if it does not exist yet

Typically, one should call ``set_loglevel("info")`` or
``set_loglevel("debug")`` to get additional debugging information.

Users or applications that are installing their own logging handlers
may want to directly manipulate ``logging.getLogger('matplotlib')`` rather
than use this function.

Parameters
----------
level : {"notset", "debug", "info", "warning", "error", "critical"}
Expand All @@ -263,6 +273,7 @@ def set_loglevel(level):
The first time this function is called, an additional handler is attached
to Matplotlib's root handler; this handler is reused every time and this
function simply manipulates the logger and handler's level.

"""
_log.setLevel(level.upper())
_ensure_handler().setLevel(level.upper())
Expand Down