Skip to content
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

Disable logging? #25

Open
Pikamander2 opened this issue Nov 28, 2020 · 5 comments
Open

Disable logging? #25

Pikamander2 opened this issue Nov 28, 2020 · 5 comments
Milestone

Comments

@Pikamander2
Copy link

Is there a way to turn off logging? A single call to sitemap_tree_for_homepage spits out over 20 messages into the console, most of which are of no concern.

@stefan-djurovic
Copy link

Well, currently there is not.

@sibalzer
Copy link

sibalzer commented May 21, 2021

You can set the logger level to warning to ignore unnecessary messages.

logging.getLogger("usp.fetch_parse").setLevel(logging.WARNING)
logging.getLogger("usp.helpers").setLevel(logging.WARNING)
logging.getLogger("usp.tree").setLevel(logging.WARNING)

@ThibTrip
Copy link

logging.getLogger("usp.fetch_parse").setLevel(logging.WARNING)
logging.getLogger("usp.helpers").setLevel(logging.WARNING)

Thank you for your answer but this does not seem to work 😿.

Example code

import logging
from usp.tree import sitemap_tree_for_homepage

logging.getLogger("usp.fetch_parse").setLevel(logging.WARNING)
logging.getLogger("usp.helpers").setLevel(logging.WARNING)
logging.getLogger("usp.tree").setLevel(logging.WARNING)

sitemap_tree_for_homepage('https://www.siemens.de/')
2021-05-21 11:29:27,202 WARNING usp.helpers [1407409/MainThread]: Request for URL https://www.siemens.de/robots.txt failed: 404 Not Found
2021-05-21 11:29:27,829 WARNING usp.helpers [1407409/MainThread]: Request for URL https://www.siemens.de/sitemap-index.xml.gz failed: 404 Not Found
2021-05-21 11:29:28,443 WARNING usp.helpers [1407409/MainThread]: Request for URL https://www.siemens.de/sitemap_index.xml failed: 404 Not Found
2021-05-21 11:29:29,067 WARNING usp.helpers [1407409/MainThread]: Request for URL https://www.siemens.de/.sitemap.xml failed: 404 Not Found
2021-05-21 11:29:29,694 WARNING usp.helpers [1407409/MainThread]: Request for URL https://www.siemens.de/sitemap/sitemap-index.xml failed: 404 Not Found
2021-05-21 11:29:30,303 WARNING usp.helpers [1407409/MainThread]: Request for URL https://www.siemens.de/sitemap.xml failed: 404 Not Found
...

@sibalzer
Copy link

Thats because you are getting warning messages. If you want to ignore them too you need to set the logging level higher (logging.ERROR or even logging.FATAL). But i wouldn't recommend it.

@Pikamander2
Copy link
Author

Ideally, it would be nice to have an official setting to suppress the output.

@freddyheppell freddyheppell added this to the 0.6 milestone Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants