有没有办法向 Flex Air 应用程序添加详细的远程崩溃报告?

发布于 2024-08-23 13:46:44 字数 134 浏览 3 评论 0原文

我很快就会发布我的 Air/Flex 应用程序,但我非常确定 Air 可用的各种平台上可能会出现一些错误。所以我想知道是否有一种方法可以实现一种机制,每次应用程序崩溃时都会向远程服务器发送错误报告,记录错误发生的位置?这样我可能会发现否则会被忽视的错误。

I will be releasing my Air/Flex application soon, but I am pretty sure there are a couple of bugs that may pop up on the various platforms that Air is available for. So I was wondering if there is a way to implement a mechanism, that would send an error report, logging where the error happened, to a remote server each time an app crashes? This way I might catch errors that otherwise would go unnoticed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

俏︾媚 2024-08-30 13:46:44

Flash 10 和 AIR2 现在支持全局错误处理。有关详细信息,请访问:http://help。 adobe.com/en_US/air/reference/html/flash/events/UncaughtErrorEvent.html

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

我已经设置了如下所述的这样一个服务(假设它有一些缺陷,特别是任何人都可以调用它并添加“痕迹”,但你可以添加一些共享秘密并通过 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()

我编写了一个包含这个小测试函数的小 AIR-应用程序,该函数只是使用指定的参数“trace”对应用程序引擎服务进行 POST:ed。

发布到日志记录服务 (ActionScript)

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 日志记录功能

Global error handling is now supported in Flash 10 and AIR2. More info on that here: http://help.adobe.com/en_US/air/reference/html/flash/events/UncaughtErrorEvent.html

Using that kind of functionality to catch uncaught exceptions; you can submit the trace to some web service set up specifically to grab them. Using Google App Engine is excellent for this purpose since it already has a logging feature which grabs all kinds of meta data from the client calling the application. Also, if your logs become huge for some reason - at least you wont have to worry about storing them. Google does that for you :)

I've set up such a service as outlined below (granted it has some flaws, in particular anyone can call it and add "traces", but you could add some shared secret and post over HTTPS to have some tiny measure of security).

App Engine Logging Service

#!/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()

I wrote a little AIR-app containing this little test function which simply POST:ed the app engine service with the parameter "trace" specified.

Posting to the logging service (ActionScript)

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);
}

And finally, this is how it looks in the logs, lots of metadata, and of the trace you caught in your AIR app.

Google App Engine Logging feature

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文