8000 ENH: add a user-freindly verbose interface · matplotlib/matplotlib@1bcf4f4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1bcf4f4

Browse files
committed
ENH: add a user-freindly verbose interface
1 parent 2b86111 commit 1bcf4f4

File tree

2 files changed

+55
-8
lines changed

2 files changed

+55
-8
lines changed

lib/matplotlib/__init__.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,35 @@ def _check_versions():
207207
sys.argv = ['modpython']
208208

209209

210-
_verbose_msg = """\
211-
matplotlib.verbose is deprecated;
212-
Command line argument --verbose-LEVEL is deprecated.
213-
This functionality is now provided by the standard
214-
python logging library. To get more (or less) logging output:
215-
import logging
216-
logger = logging.getLogger('matplotlib')
217-
logger.set_level(logging.INFO)"""
210+
def verbose(level='debug'):
211+
"""
212+
Shortcut to set the debugging level of the logging module.
213+
214+
Parameters
215+
----------
216+
level : str or bool
217+
If True set logging level to "DEBUG" for matplotlib module.
218+
If FALSE set logging level to "WARNING" for matplotlib module (this
219+
is the default level if ``verbose`` is not called). If a string, must
220+
be one of ['warning', 'info', 'debug'], in order of increasing
221+
verbosity.
222+
223+
Notes
224+
-----
225+
This is the same as the standard python `logging` module::
226+
227+
import logging
228+
229+
_log = logging.getLogger(__name__)
230+
_log.setLevel(logging.DEBUG) # or logging.WARNING, logging.INFO
231+
232+
"""
233+
234+
if level is True:
235+
level = 'debug'
236+
if level is False:
237+
level = 'warning'
238+
_set_logger_verbose_level(level_str=level)
218239

219240

220241
def _set_logger_verbose_level(level_str='silent', file_str='sys.stdout'):

lib/matplotlib/pyplot.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,6 +1997,32 @@ def colormaps():
19971997
return sorted(cm.cmap_d)
19981998

19991999

2000+
def verbose(level='debug'):
2001+
"""
2002+
Shortcut to set the debugging level of the logging module.
2003+
2004+
Parameters
2005+
----------
2006+
level : str or bool
2007+
If True set logging level to "DEBUG" for matplotlib module.
2008+
If FALSE set logging level to "WARNING" for matplotlib module (this
2009+
is the default level if ``verbose`` is not called). If a string, must
2010+
be one of ['warning', 'info', 'debug'], in order of increasing
2011+
verbosity.
2012+
2013+
Notes
2014+
-----
2015+
This is the same as the standard python `logging` module::
2016+
2017+
import logging
2018+
2019+
_log = logging.getLogger(__name__)
2020+
_log.setLevel(logging.DEBUG) # or logging.WARNING, logging.INFO
2021+
2022+
"""
2023+
matplotlib.verbose(level=level)
2024+
2025+
20002026
def _setup_pyplot_info_docstrings():
20012027
"""
20022028
Generates the plotting docstring.

0 commit comments

Comments
 (0)
0