diff --git a/doc/devel/coding_guide.rst b/doc/devel/coding_guide.rst index 2b156cedca05..fe7769909368 100644 --- a/doc/devel/coding_guide.rst +++ b/doc/devel/coding_guide.rst @@ -215,7 +215,7 @@ If an end-user of Matplotlib sets up `logging` to display at levels more verbose than ``logging.WARNING`` in their code with the Matplotlib-provided helper:: - plt.set_loglevel("debug") + plt.set_loglevel("DEBUG") or manually with :: diff --git a/doc/devel/troubleshooting.rst b/doc/devel/troubleshooting.rst index 74ce81b2da00..e57cfcb92bd6 100644 --- a/doc/devel/troubleshooting.rst +++ b/doc/devel/troubleshooting.rst @@ -23,7 +23,7 @@ mode:: git clean -xfd git pull python -m pip install -v . > build.out - python -c "from pylab import *; set_loglevel('debug'); plot(); show()" > run.out + python -c "from pylab import *; set_loglevel('DEBUG'); plot(); show()" > run.out and post :file:`build.out` and :file:`run.out` to the `matplotlib-devel `_ diff --git a/doc/install/index.rst b/doc/install/index.rst index 3e6452eb2f41..6ac79cc8c133 100644 --- a/doc/install/index.rst +++ b/doc/install/index.rst @@ -179,7 +179,7 @@ development environment such as :program:`IDLE` which add additional complexities. Open up a UNIX shell or a DOS command prompt and run, for example:: - python -c "from pylab import *; set_loglevel('debug'); plot(); show()" + python -c "from pylab import *; set_loglevel('DEBUG'); plot(); show()" This will give you additional information about which backends Matplotlib is loading, version information, and more. At this point you might want to make diff --git a/doc/users/faq.rst b/doc/users/faq.rst index c6bbc5ca8d87..d13625ec9907 100644 --- a/doc/users/faq.rst +++ b/doc/users/faq.rst @@ -367,7 +367,7 @@ provide the following information in your e-mail to the `mailing list * Matplotlib provides debugging information through the `logging` library, and a helper function to set the logging level: one can call :: - plt.set_loglevel("info") # or "debug" for more info + plt.set_loglevel("INFO") # or "DEBUG" for more info to obtain this debugging information. diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 03d288efe342..e9eba105c5e1 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -292,8 +292,8 @@ def set_loglevel(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. + 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 @@ -301,8 +301,12 @@ def set_loglevel(level): Parameters ---------- - level : {"notset", "debug", "info", "warning", "error", "critical"} - The log level of the handler. + level : {"NOTSET", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"} + The log level as defined in `Python logging levels + `__. + + For backwards compatibility, the levels are case-insensitive, but + the capitalized version is preferred in analogy to `logging.Logger.setLevel`. Notes ----- diff --git a/lib/matplotlib/typing.py b/lib/matplotlib/typing.py index 440d888c20f4..899013f27bde 100644 --- a/lib/matplotlib/typing.py +++ b/lib/matplotlib/typing.py @@ -93,7 +93,7 @@ CapStyleType: TypeAlias = CapStyle | Literal["butt", "projecting", "round"] """Line cap styles. See :doc:`/gallery/lines_bars_and_markers/capstyle`.""" -LogLevel: TypeAlias = Literal["notset", "debug", "info", "warning", "error", "critical"] +LogLevel: TypeAlias = Literal["NOTSET", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] """Literal type for valid logging levels accepted by `set_loglevel()`.""" CoordsBaseType = Union[