开发环境中的App引擎不打印日志

时间:2016-01-03 06:34:44

标签: python-2.7 google-app-engine

我正在尝试在Google App引擎的本地环境中打印日志。它似乎应该如此,但我仍然无法打印日志。需要一些帮助吗?

我需要在标准控制台上输出此输出。

import webapp2
from google.appengine.api import urlfetch
from Webx import WebxClass
import json
import logging

class SearchHandler(webapp2.RequestHandler):

    def __init__(self,*args, **kwargs):
        super(SearchHandler,self).__init__(*args, **kwargs)
        self.result=[]
        self.searchPortals = [WebxClass()]
        self.asa = []
    def handleCallBack(self,rpc,portalObject):
        try:
            rr = rpc.get_result()
            if rr.status_code == 200:
                if isinstance(portalObject, WebxClass):
                    resultList=portalObject.getResultList(rr.content)
                    self.result.extend(resultList)
        except urlfetch.DownloadError:
            self.result = 'Error while fetching from portal - ' + portalObject.getName()

    def getSearchResult(self):
        rpcs=[]
        searchKeyword=self.request.get('searchString')
        logging.error("------------------------------")
        for portal in self.searchPortals:
            rpc = urlfetch.create_rpc(deadline=5)
            rpc.callback = lambda: self.handleCallBack(rpc, portal)
            urlfetch.make_fetch_call(rpc, portal.getSearchURL(searchKeyword))
            rpcs.append(rpc)

        for rpc in rpcs:
            rpc.wait()

        self.response.status_int = 200
        self.response.headers['Content-Type'] = 'application/json'
        self.response.headers.add_header("Access-Control-Allow-Origin", "*")
        self.response.write(json.dumps(self.result))

app = webapp2.WSGIApplication([
                               webapp2.Route(r'/search', methods=['GET'], handler='Torrent.SearchHandler:getSearchResult')
                               ], debug=True)

def main():
    logging.getLogger().setLevel(logging.DEBUG)
    logging.debug("------------------------------")
    app.run()

if __name__ == '__main__':
    main()

0 个答案:

没有答案