Global variable for debug options and logging in GAE Python
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.
精彩评论