« RIA Developer Camp
» Add CSS style to a component

ActionScript, Flex IDE, RIA

Debug/Logging Client-Side - Part 2

29.10.07 | Comment?

Table of contents

  1. Debug/Logging Client-Side - Part 1
  2. Debug/Logging Client-Side - Part 2

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.

Popularity: 34%

Share and Enjoy:
  • Technorati
  • StumbleUpon
  • del.icio.us
  • NewsVine
  • Reddit
  • Digg
  • Furl
  • co.mments
  • blogmarks
  • Slashdot
  • DZone
  • Taggly
  • YahooMyWeb
  • connotea
  • Webride




Tags: , , ,

This post was written by Virgil Cristea

Views: 1294

related

popular

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>

:

:


« RIA Developer Camp
» Add CSS style to a component