I recently configured my app to use the new AppStats feature of GAE. However, while debugging it, the extremely verbose logging from AppStats is annoying & I'd like to dis开发者_高级运维able it while I'm debugging and then turn it back on later. Surely there is a single line I can add to or modify in a config file that will let me do this.
See the configuring appstats docs: configuration is performed by creating your own appengine_config.py
in your app's root directory. Best documentation of what you can do in that config file is the sample one supplied with your SDK, which you can also look at here. To disable stats, if you're using Django, just comment out the line
google.appengine.ext.appstats.recording.AppStatsDjangoMiddleware
in your Diango settings.py
file; if you're not using Django, in the function that should be in your appengine_config.py
file and read
def webapp_add_wsgi_middleware(app):
from google.appengine.ext.appstats import recording
app = recording.appstats_wsgi_middleware(app)
return app
just comment out the first two lines of the body, so it reads instead
def webapp_add_wsgi_middleware(app):
# from google.appengine.ext.appstats import recording
# app = recording.appstats_wsgi_middleware(app)
return app
If you insist on it being a single-line change, you can avoid commenting the from
statement -- per se, it's innocuous, though it may microscopically slow you down (which is why I'd comment it out even though innocuous;-).
I know this is old, but how about this:
Add a config.py where you define the DEBUG flag (or if you have it defined elsewhere, even better). And then:
from config import DEBUG
def webapp_add_wsgi_middleware(app):
if not DEBUG:
from google.appengine.ext.appstats import recording
app = recording.appstats_wsgi_middleware(app)
return app
EDIT: Advantage of this method is you can use the same debug flag elsewhere in your app.
精彩评论