Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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(# ...
                                        debug=True)
like image 969
Nick Heiner Avatar asked Jun 27 '10 18:06

Nick Heiner


1 Answers

__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.

like image 110
David Underhill Avatar answered Oct 14 '22 09:10

David Underhill