擅长:python、mysql、java
<p>实际上,decorator无法检测上下文外的应用程序实例,我使用当前的应用程序解决这个问题:</p>
<p>1.导入方法:<code>from flask import current_app</code></p>
<p>第二。将任何应用程序类附加到当前应用程序:<code>current_app.logger.error('panic !!!')</code></p>
<blockquote>
<p>info @ <a href="http://flask.pocoo.org/docs/api/#flask.current_app" rel="noreferrer">http://flask.pocoo.org/docs/api/#flask.current_app</a></p>
<p>"Points to the application handling the request. This is useful for
extensions that want to support multiple applications running side by
side. This is powered by the application context and not by the
request context, so you can change the value of this proxy by using
the app_context() method."</p>
</blockquote>