简体   繁体   English

调试选项的全局变量和GAE Python中的日志记录

[英]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? 这是__debug__的用途吗? How do I set/read it on Google App Engine? 如何在Google App Engine上设置/阅读它?

If I use logging.debug() , will that automatically be turned off if I don't run the app with debug=True ? 如果我使用logging.debug() ,如果我没有使用debug=True运行应用程序,会自动关闭吗?

application = webapp.WSGIApplication(# ...
                                        debug=True)

__debug__ is built-in constant defined by Python. __debug__是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." 文档说:“如果Python没有使用-O选项启动,则此常量为真。 调试的赋值是非法的并引发SyntaxError。另请参见assert语句。”

The debug=True you pass to webapp.WSGIApplication is completely separate. debug=True传递给webapp.WSGIApplication是完全独立的。

Neither of these will affect logging.debug() either. 这些都不会影响logging.debug() You can use logging.setLevel() to control how logging.debug() is handled. 您可以使用logging.setLevel()来控制logging.debug()的处理方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM