开发者

Global variable for debug options and logging in GAE Python

开发者 https://www.devze.com 2023-01-05 01:57 出处:网络
I\'d like a global variable to determine if I\'m in debug mode or not. Is that what __debug__ is for? How do I set/read it on Google App Engine?

I'd like a global variable to determine if I'm in debug mode or not. Is that what __debug__ is for? How do I set/read it on Google App Engine?

If I use logging.debug(), will that automatically be turned off if I don't run the app with debug=True?

application = webapp.WSGIApplication(# ...
                               开发者_如何学Go         debug=True)


__debug__ is built-in constant defined by Python. The docs say this: "This constant is true if Python was not started with an -O option. Assignments to debug are illegal and raise a SyntaxError. See also the assert statement."

The debug=True you pass to webapp.WSGIApplication is completely separate.

Neither of these will affect logging.debug() either. You can use logging.setLevel() to control how logging.debug() is handled.

0

精彩评论

暂无评论...
验证码 换一张
取 消