ultimate-sitemap-parser icon indicating copy to clipboard operation
ultimate-sitemap-parser copied to clipboard

Library interferes with application logging configuration

Open dsoprea opened this issue 5 years ago • 10 comments

Because of this:

https://github.com/mediacloud/ultimate-sitemap-parser/blob/68d1ccdd573be16cdfadc7f071c088642182bff1/usp/fetch_parse.py#L43

and this:

https://github.com/mediacloud/ultimate-sitemap-parser/blob/68d1ccdd573be16cdfadc7f071c088642182bff1/usp/log.py#L36-L43

this library almost always ends-up configuring the logging of the calling application in ways not often desired. It's usually not appropriate to unconditionally print logging to the screen. Can you please remove the code (shown above) where it's adding handlers if no handlers already exists?

Also, this module is overriding all of the built-in logging functionality unnecessarily. It could just use the logging object directly (e.g. _LOGGING = logging.getLogger(__name__)), but that's just a side comment.

I'm currently having to do this to squash your output:

import usp.fetch_parse
import usp.objects.sitemap

logging.getLogger('usp.fetch_parse').handlers = []
logging.getLogger('usp.helpers').handlers = []

dsoprea avatar Nov 19 '20 23:11 dsoprea

Could you do it in a PR?

On Fri, Nov 20, 2020, 01:41 Dustin Oprea [email protected] wrote:

Because of this:

https://github.com/mediacloud/ultimate-sitemap-parser/blob/68d1ccdd573be16cdfadc7f071c088642182bff1/usp/fetch_parse.py#L43

and this:

https://github.com/mediacloud/ultimate-sitemap-parser/blob/68d1ccdd573be16cdfadc7f071c088642182bff1/usp/log.py#L36-L43

this library almost always ends-up reconfiguring the logging of the calling application. Because it's running as soon as the module is imported, it's configuring the logging before the host application has a chance to. That aside, a package/library should just be using the logging, not configuring the logging. That's the responsible of the front-end scripts/application. It's disruptive, otherwise. It's usually not appropriate to unconditionally print logging to the screen.

Can you please remove the code (shown above) where it's adding handlers to the current logging config if no handlers already exists?

Also, this module is overriding all of the built-in logging functionality unnecessarily. It could just use the logging object directly (e.g. _LOGGING = logging.getLogger(name)), but that's just a side comment.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mediacloud/ultimate-sitemap-parser/issues/23, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABMNPKHPULO2DGHQ72II73SQWUJHANCNFSM4T4CCXLA .

pypt avatar Nov 20 '20 04:11 pypt

Sure. I just wanted to see if you'd respond, first.

https://github.com/mediacloud/ultimate-sitemap-parser/pull/24

dsoprea avatar Nov 20 '20 06:11 dsoprea

Bump

dsoprea avatar Nov 22 '20 07:11 dsoprea

Bump

dsoprea avatar Nov 23 '20 02:11 dsoprea

A bit busy this week, I'll try to get to it soon though.

On Mon, Nov 23, 2020 at 4:56 AM Dustin Oprea [email protected] wrote:

Bump

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mediacloud/ultimate-sitemap-parser/issues/23#issuecomment-731901848, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABMNPN36KVPEJV5DWEVRSTSRHFOTANCNFSM4T4CCXLA .

-- Linas Valiukas www.mediacloud.org

pypt avatar Nov 23 '20 12:11 pypt

I was busy too, yet I made time for an extremely simple PR.

dsoprea avatar Nov 23 '20 19:11 dsoprea

Bump.

dsoprea avatar Nov 27 '20 21:11 dsoprea

Bump.

dsoprea avatar Nov 28 '20 10:11 dsoprea

Bump.

dsoprea avatar Nov 29 '20 04:11 dsoprea

Hey @pypt - We need this change in our app too. Do you have a rough idea of when the change will be added?

Pikamander2 avatar Dec 11 '20 11:12 Pikamander2