Logging with SOS max and FlashDevelop 3.

SOS max is one of the best log output viewers around. It works with anything able to send XML through socket connection. Using special markup you can send different type log messages and define new one. SOS max shows them in colors of your choice and allows to log only specific type of messages depending on settings  (i.e. trace, info, warning, error, fatal).  It's not really practical to write correct XML messages by hand. Thanks to Sönke Rodhe there is a good solution for Flex to minimize the chance of getting carpal tunnel syndrome due to extra typing hours. But it  doesn't work out of the box with pure Actionscript 3.0.

Here are 4 simple steps to get you going with SOS and Flash Develop 3.

1. Download SOS MAX.

2. Download sosloggingtarget.swc

3. Add sosloggingtarget.swc to your project library paths. Don't forget to right click sosloggingtarget.swc and "Add to Library".

4. Code example. Read the comments.

package
{
	import flash.events.Event;
	import mx.logging.Log; // Needed
	import mx.logging.ILogger; // Needed
	import com.soenkerohde.logging.SOSLoggingTarget; // Needed

	import flash.display.MovieClip;

	public class App extends MovieClip
	{
		private static const logger:ILogger = Log.getLogger("App");
                //Needed. "App" is so called category name.
                //You can include it into log messages.
                //Use it to see what part of your code log text is coming from.
		public function App()
		{
			super();
			var logging_target:SOSLoggingTarget = new SOSLoggingTarget();
                        // Create new logging target - used to configure logger
			// Next four values are false by default.
                        // That's not useful. Let's change 'em.
			logging_target.includeCategory = true;
                        // Include category name in log.
			logging_target.includeDate = true;
                        // Include date.
			logging_target.includeLevel = true;
                        // Use message types. In case of false all the messages will be treated as "info".
			logging_target.includeTime = true;
                        // Include time in log.
			Log.addTarget(logging_target);
                        // Setup configuration.

			logger.debug("debug"); // Example of debug message
			logger.info("info"); // Example of info message
			logger.warn("warn"); // Example of warn message
			logger.error("error"); // Example of error message
			logger.fatal("fatal"); // Example of fatal message

			logger.info("This is a multi-line log examplenwith a second line.");
                        // Example of multi-line foldable message

		}

	}

}

Here goes the output:

soslog

Nice logging!

2 Comments to Logging with SOS max and FlashDevelop 3.

  1. January 21, 2009 at 5:33 am | Permalink

    Hi Nikita,
    you can leave out step 3 since the user does not need the source code. So you only have to add sosloggingtarget.swc to your projects library.

Leave a Reply

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Categories