We love choice

Fx{r} is trying to start the Fx{r} Community! Please join our group on Adobe Groups following this link: http://fxr.groups.adobe.com.
Fx{r} is now on Twitter too. Follow us @ twitter.com/fx_r!
«
»

ActionScript, Flex IDE, RIA

Debug/Logging Client-Side – Part 2

Virgil Cristea | 29.10.07 | 2 Comments

Table of contents

  1. Debug/Logging Client-Side – Part 1
  2. Debug/Logging Client-Side – Part 2
Google Buzz

In my previous post I started to talk about how you can see the same trace messages you were used from developing but this time in the “Release”.

This is done with the help of the Log class (mx.logging.Log).

Let’s take a look at some pieces of code (full code can be provided per request).

private var myTarget:ILoggingTarget;
myTarget = new TraceTarget();
Log.addTarget(myTarget);
var myLogger:ILogger = Log.getLogger(category);
myLogger.log(0,message);

The first 2 lines create a variable of type TraceTarget. Then it is added to the loggers list by calling

Log.addTarget(myTarget)

After that all we have to do is log the message:

myLogger.log(0,message);

How can we use this method to send the log output to a remote machine? Simple we have to create our own logger:

package com.qbic.logging
{
import flash.events.Event;
import flash.net.XMLSocket;
 
import mx.logging.LogEvent;
import mx.logging.targets.LineFormattedTarget;
 
internal final class remoteTarget extends LineFormattedTarget
{
   public static var server_ip : String = "localhost";
   public static var server_port : int = 6783;
   private var mySocket : XMLSocket;
   public function remoteTarget()
   {
      // Connect to the socket
   }
 
   public override function logEvent(myLogEvent:LogEvent) : void
   {
      mySocket.send(myLogEvent.message);
   }
}
}

Off course this is just a beginning of the code.

Share and Enjoy:
  • Twitter
  • Google Buzz
  • LinkedIn
  • Google Bookmarks
  • del.icio.us
  • Digg
  • Sphinn
  • blogmarks
  • Reddit
  • StumbleUpon
  • Facebook
  • DZone
  • FriendFeed
  • Yahoo! Buzz
  • Yahoo! Bookmarks
  • Slashdot
  • MySpace
  • Add to favorites




Tags: , , ,

This post was written by Virgil Cristea

Views: 7216

related

2 Comments

have your say

Add your comment below, or trackback from your own site. Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

:

:


«
»