2010-03-01 36 views

回答

2

Flash 10和AIR2现在支持全局错误处理。更多的信息在这里:http://help.adobe.com/en_US/air/reference/html/flash/events/UncaughtErrorEvent.html

使用这种功能捕捉未捕获的异常;您可以将跟踪提交给专门设置的某个Web服务以抓取它们。使用Google App Engine非常适合此目的,因为它具有记录功能,可以从调用应用程序的客户端获取各种元数据。另外,如果你的日志由于某种原因变得很大 - 至少你不必担心存储它们。谷歌为你做:)

我已经建立了如下所述的服务(授予它有一些缺陷,特别是任何人都可以调用它并添加“痕迹”,但你可以添加一些共享的秘密和帖子通过HTTPS获得一些微小的安全措施)。

App Engine的记录服务

#!/usr/bin/env python 

from google.appengine.ext import webapp 
from google.appengine.ext.webapp import util 

class MainHandler(webapp.RequestHandler): 

    def post(self): 
     import logging 

     if self.request.get('trace'): 
      logging.error(self.request.get('trace')) #Adds a row to GAE:s own logs :) 
      self.response.out.write('trace logged') 
     else: 
      set_status(501) 

    def get(self): 
    """ Kill this function when done testing """ 
     test_form = """ 
      <form action="/" method="POST"> 
       <textarea name="trace"></textarea> 
       <input type="submit"> 
      </form>""" 

     self.response.out.write(test_form) 

def main(): 
    application = webapp.WSGIApplication([('/', MainHandler)], 
            debug=False) 
    util.run_wsgi_app(application) 

if __name__ == '__main__': 
    main() 

我写了包含这个小测试功能,只需POST一点AIR-应用:教育署指定的参数 “跟踪” 的App Engine服务。

发布到日志服务(动作脚本)

private function postToLogger(event:MouseEvent):void 
{ 
    var service:HTTPService = new HTTPService(); 

    var parameters:Object = {'trace': "omg something went wrong"}; 
    service.url = "https://YOURSUPERSIMPLELOGGINGSERVICE.APPSPOT.COM"; 
    service.method = HTTPRequestMessage.POST_METHOD; 
    service.resultFormat = HTTPService.RESULT_FORMAT_E4X; 
    service.addEventListener("result", onSuccess); 
    service.addEventListener("fault", onError); 
    service.send(parameters); 
} 

最后,这是它的外观在日志中,大量的元数据,以及跟踪的你在你的AIR应用程序捕获。

Google App Engine Logging feature

+0

甜! Google App Engine规则! – PEZ 2010-03-09 07:22:09

相关问题