-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ENH: add a user-friendly verbose interface #13129
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -120,10 +120,16 @@ provide the following information in your e-mail to the `mailing list | |||||
|
||||||
python -c "from logging import *; basicConfig(level=DEBUG); from pylab import *; plot(); show()" | ||||||
|
||||||
If you want to trigger logging in a script, it can be done with helper | ||||||
functions:: | ||||||
|
||||||
If you want to put the debugging hooks in your own code, then the | ||||||
most simple way to do so is to insert the following *before* any calls | ||||||
to ``import matplotlib``:: | ||||||
import matplotlib.pyplot as plt | ||||||
plt.set_loglevel(level='info') # or plt.set_loglevel(level='debug') | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
See above. |
||||||
|
||||||
|
||||||
If you want to put full debugging hooks in your own code, including | ||||||
debug information when matplotlib starts up, then the way to do so is to | ||||||
insert the following *before* any calls to ``import matplotlib``:: | ||||||
|
||||||
import logging | ||||||
logging.basicConfig(level=logging.DEBUG) | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
:orphan: | ||
|
||
New methods for verbose logging | ||
------------------------------- | ||
|
||
If more debugging information is required, the user can call | ||
the `.pyplot.set_loglevel` method. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,14 +207,35 @@ def _check_versions(): | |
sys.argv = ['modpython'] | ||
|
||
|
||
_verbose_msg = """\ | ||
matplotlib.verbose is deprecated; | ||
Command line argument --verbose-LEVEL is deprecated. | ||
This functionality is now provided by the standard | ||
python logging library. To get more (or less) logging output: | ||
import logging | ||
logger = logging.getLogger('matplotlib') | ||
logger.set_level(logging.INFO)""" | ||
def set_loglevel(level='info'): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need a default? Just from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I disagree with this. The only reason it is ambiguous is you suggested we change the name from verbose 😉 The naive user posting on stack overflow is not going to know the names of the logging levels so having an interface where they don’t have to pass an argument is desirable. |
||
""" | ||
Shortcut to set the logging level of the logging module. | ||
|
||
Parameters | ||
---------- | ||
level : str or bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO there is no natural mapping from bool to log levels. I would discard the bool option. |
||
If True set logging level to "INFO" for matplotlib module. | ||
If FALSE set logging level to "WARNING" for matplotlib module (this | ||
is the default level if ``set_loglevel`` is not called). If a string, | ||
must be one of ['warning', 'info', 'debug'], in order of increasing | ||
verbosity. | ||
|
||
Notes | ||
----- | ||
This is the same as the standard python `logging` module:: | ||
|
||
import logging | ||
|
||
_log = logging.getLogger(__name__) | ||
_log.setLevel(logging.INFO) # or logging.WARNING, logging.INFO | ||
|
||
""" | ||
|
||
if level is True: | ||
level = 'info' | ||
if level is False: | ||
level = 'warning' | ||
_set_logger_verbose_level(level_str=level.lower()) | ||
|
||
|
||
def _set_logger_verbose_level(level_str='silent', file_str='sys.stdout'): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there is only one parameter and the function name already tells it, I propose the canonical way of using this is with a positional parameter.