Py-StackExchange icon indicating copy to clipboard operation
Py-StackExchange copied to clipboard

How to enable .debug in WebRequestManager?

Open inactivist opened this issue 12 years ago • 4 comments

WebRequestManager has a debug field, which is initialized to False. I see no way to set it == True sans code hacking or class attribute manipulation. Have I missed something?

inactivist avatar Mar 31 '13 14:03 inactivist

This seems to work:

import stackexchange
so = stackexchange.Site(stackexchange.StackOverflow)
stackexchange.web.WebRequestManager.debug = True

... do some stackexchange things here...

-- but requires code diving as it's not part of any published interface -- and operates globally across all API requests.

inactivist avatar Mar 31 '13 14:03 inactivist

I've added a FAQ entry suggesting the technique shown above.

inactivist avatar Mar 31 '13 14:03 inactivist

Thanks a lot; that is indeed the way I have usually enabled it, or through similar code in a REPL session.

I hadn't previously considered it as useful for anything but library debugging, but I suppose it could also be useful for application debugging. Per #24 you opened, I think you are right in that it should be migrated to use the logging module, probably with a logger instance per site.

lucjon avatar Mar 31 '13 15:03 lucjon

It all depends on your roadmap -- as far as I'm concerned, if I expect to use this in a server environment as part of a real app, I'll want proper, configurable logging facilities.

You're the architect, so I'll let you take the lead (especially on #24) but once that starts, I'll jump in as appropriate.

inactivist avatar Mar 31 '13 15:03 inactivist