2010-03-01 38 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

相關問題