René's URL Explorer Experiment


Title: Use of logging in matplotlib · Issue #13264 · matplotlib/matplotlib · GitHub

Open Graph Title: Use of logging in matplotlib · Issue #13264 · matplotlib/matplotlib

X Title: Use of logging in matplotlib · Issue #13264 · matplotlib/matplotlib

Description: I think the use of logging in matplotlib is not right. Unfortunately the official logging documentation is not quite comprehensive. I'll try to explain in the following how I understand that logging should be used. TLDR: I propose to jus...

Open Graph Description: I think the use of logging in matplotlib is not right. Unfortunately the official logging documentation is not quite comprehensive. I'll try to explain in the following how I understand that loggin...

X Description: I think the use of logging in matplotlib is not right. Unfortunately the official logging documentation is not quite comprehensive. I'll try to explain in the following how I understand that lo...

Opengraph URL: https://github.com/matplotlib/matplotlib/issues/13264

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Use of logging in matplotlib","articleBody":"I think the use of logging in matplotlib is not right.\r\n\r\nUnfortunately the official logging documentation is not quite comprehensive. I'll try to explain in the following how I understand that logging should be used.\r\n\r\n**TLDR: I propose to just remove `matplotlib._set_logger_verbose_level()` and all logging issues are gone. - Maybe add a bit of documentation how to use logging, but that's really not matplotlib specific.**\r\n\r\n## How logging should be used in simple cases\r\nIn the minimal case, libraries do only define a logger and call the respective `info()`, `error()` etc. functions on that logger.\r\n\r\n~~~\r\n_log = logging.getLogger(__name__)\r\n~~~\r\n\r\nIn this case, the library does not care about handling at all. IMO this is generally good practice as the library will issue messages, but it will not care which will be delivered or where they will go to (stdout, file, ...). That's the task of the code using the library:\r\n\r\n- if the programmer does not care about logging at all, [logging.lastResort](https://docs.python.org/3/library/logging.html#logging.lastResort) is used, which is a StreamHandler to stderr. This makes sure the messages go somewhere even without configuration (note: this was introduced in 3.2).\r\n\r\n- if the programmer wants to control the logging, the simple way is [logging.basicConfig()](https://docs.python.org/3/library/logging.html#logging.basicConfig). This is sufficent to redirect output to files, set the global log level etc.\r\n\r\n## How matplotlib uses logging\r\n\r\n### Former times\r\n\r\nThere has been some argument parsing magic, so that passing `--verbose` to a script using matplotlib could be used to control matplotlib's logging. This has been removed because it's too magical and can badly interfere with the argument handling of a script.\r\n\r\n### Now\r\n\r\nCurrently, there is only `matplotlib._set_logger_verbose_level()`.\r\n\r\nIf unused (default) the processes work as described above for loggging in simple cases.\r\n\r\nThe function binds a new StreamHandler (named *console* in the code) to `_log` and controls the level of the handler. This works ok for the case when the matplotlib-using programmer does not configure any logging himself: The messages are sent to *console*. `logging.lastResort` is not used. However, if logging `basicConfig()` is used, we have two handlers: *console* plus the one from the config, as can be seen when running\r\n\r\n~~~\r\nimport matplotlib\r\nimport logging\r\nlogging.basicConfig()\r\nmatplotlib._set_logger_verbose_level('helpful')\r\nmatplotlib._log.info('test')\r\n~~~\r\n\r\nThis outputs the message twice\r\n~~~\r\ntest\r\nINFO:matplotlib:test\r\n~~~\r\n\r\nluckily `_set_logger_verbose_level()` is private and should not be used currently.\r\n\r\n### Future\r\n\r\nThe proposal in #13129 is making `_set_logger_verbose_level()` indirectly public through some convenience functions. *IMHO this is the wrong way to go as described above*.\r\n\r\nWhat we should do is just remove `_set_logger_verbose_level()`. It's standard use casescan be handled using `logging.basicConfig()`. e.g.\r\n\r\n- redirecting to file: `logging.basicConfig(filename='errors.log')\r\n- setting the level: `logging.basicConfig(level='debug')\r\n\r\n`logging.basicConfig()` is actually more general, e.g.\r\n- specifying the output format\r\n- choosing between append and overwrite for a file.\r\n- using another handler\r\n- etc.\r\n\r\nThere's one special case that we do not cover: Logging matplotlibs output somewhere else that other logging output. That was possible / the case for `_set_logger_verbose_level()`. Not sure if it was by design or just accidentially. If a user really needs that, he has to attach a handler to the matplotlib logger (but also maybe set `_log.propagate = False`. We could add a convenience function for this, but IMHO this is rather an advance usage and it should be sufficient to make the matplotlib logger accessible.","author":{"url":"https://github.com/timhoffm","@type":"Person","name":"timhoffm"},"datePublished":"2019-01-22T21:08:26.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":17},"url":"https://github.com/13264/matplotlib/issues/13264"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:205f33af-cea3-e815-54b2-619e1ac527ab
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB338:1826AA:6E2A0D:92C93D:6A518EA6
html-safe-nonce4d0e89ac42594aacb4e5c0ba3aaecbd07360431ce2a33673c749f09aaca96ac7
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMzM4OjE4MjZBQTo2RTJBMEQ6OTJDOTNEOjZBNTE4RUE2IiwidmlzaXRvcl9pZCI6IjkxMjI1MTQ2ODMxMzExNzA0NzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac22223d7cd3914c952bdfe7135deff2a08d6718579a764ac62cc09e8d1171d489
hovercard-subject-tagissue:401954424
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/13264/issue_layout
twitter:imagehttps://opengraph.githubassets.com/49196d179e58717081241fbd8cf7dad1db5cacdaba339c01995746d3f528bba9/matplotlib/matplotlib/issues/13264
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/49196d179e58717081241fbd8cf7dad1db5cacdaba339c01995746d3f528bba9/matplotlib/matplotlib/issues/13264
og:image:altI think the use of logging in matplotlib is not right. Unfortunately the official logging documentation is not quite comprehensive. I'll try to explain in the following how I understand that loggin...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernametimhoffm
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
turbo-cache-controlno-preview
go-importgithub.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git
octolytics-dimension-user_id215947
octolytics-dimension-user_loginmatplotlib
octolytics-dimension-repository_id1385122
octolytics-dimension-repository_nwomatplotlib/matplotlib
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1385122
octolytics-dimension-repository_network_root_nwomatplotlib/matplotlib
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7aed05249554b889eb33d002851a973eebcc7e91
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/matplotlib/matplotlib/issues/13264#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F13264
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F13264
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=matplotlib%2Fmatplotlib
Reloadhttps://github.com/matplotlib/matplotlib/issues/13264
Reloadhttps://github.com/matplotlib/matplotlib/issues/13264
Reloadhttps://github.com/matplotlib/matplotlib/issues/13264
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/13264
matplotlib https://github.com/matplotlib
matplotlibhttps://github.com/matplotlib/matplotlib
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/13264
Notifications https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Fork 8.4k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Star 23k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Code https://github.com/matplotlib/matplotlib
Issues 1.1k https://github.com/matplotlib/matplotlib/issues
Pull requests 409 https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security and quality 0 https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
Code https://github.com/matplotlib/matplotlib
Issues https://github.com/matplotlib/matplotlib/issues
Pull requests https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security and quality https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
Use of logging in matplotlibhttps://github.com/matplotlib/matplotlib/issues/13264#top
v3.1.0https://github.com/matplotlib/matplotlib/milestone/35
https://github.com/timhoffm
timhoffmhttps://github.com/timhoffm
on Jan 22, 2019https://github.com/matplotlib/matplotlib/issues/13264#issue-401954424
logging.lastResorthttps://docs.python.org/3/library/logging.html#logging.lastResort
logging.basicConfig()https://docs.python.org/3/library/logging.html#logging.basicConfig
#13129https://github.com/matplotlib/matplotlib/pull/13129
v3.1.0https://github.com/matplotlib/matplotlib/milestone/35
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.