« Fan 4.2.1 Launched : Save videos to watch later | Main | NCAA Fan a Slam Dunk! »

LogBook, now for pure Actionscript 3 projects

A while back we released LogBook, an AIR based application for logging messages from Flex applications. The feedback from the project has been great and the team is constantly working to add features to LogBook. However, as we used LogBook within CIM, we kept hitting a couple of issues with the Flex logging framework. One of the main issues was that not all projects we work on are Flex based. A lot of times we work on pure AS3 projects and sometimes even Flash CS3 projects. Using the Flex logging framework here was not really an option. One main reason for the problems was the dependency of the logging framework on other members of the Flex framework, most notably the ResourceBundle dependency. In AS3 projects in Flex Builder, including the ResourceBundle swc seems to fix this but that completely doesn't work in Flash CS3.

Before adopting the Flex framework, within CIM we had our own internally developed frameworks (the AS2 version called Flashcore and the new AS3 version called Pyro. More news on Pyro in a few days as well so stay tuned). The framework had a completely developed logging implementation as well, which is really close to the Flex logging framework (both of ours and Flex's logging implementation was inspired by the logging frameworks in Java, most notably Log4J). Today we finally finished the LogBook console for the CIM logging framework and released it all into the LogBook SVN repository.

Like the Flex logging framework, the main class here is a class named Logger as well. However, unlike the Flex logging framework, you do not request the Logger for an ILogger instance. Instead sending logging messages here is as easy as calling one of the static methods on the Logger class. For example, for logging messages that are at the Fatal level, you call Logger.fatal() method. The first parameter to any of the logging messages is the reference to the source of the message itself and the second is the message you want to log.

Similar to the concept of Logging Targets (implementing the Flex ILoggingTarget interface) in Flex, our logging classes use a concept of Logging Consoles, implementing an IConsole interface. Out of the box, you get the TraceConsole and the LogBookConsole (There are a couple of other consoles as well that are not completely tested yet, like a Flex component based on TitleWindow that can float within the application). So at the start of your application's init phase, create a console and set it as the console for Logger.

So at startup, do:


var console:LogBookConsole = new LogBookConsole('_localconnectionname');
Logger.console = console;

thats it, now you can send messages to LogBook by calling:


Logger.info(this, "Something crazy happened");
Logger.fatal(this, "KaBoom");
Logger.warn(this, "Dont say you haven't been warned");

Hope this helps. The CIM logging framework swc can be found on the featured downloads on the CIM Logbook project. Just include the swc in your application's build path. The documentation can be found here and the source code can be found here.

Feedback is welcome, and if you are willing to help extend the libraries, drop us a message here.

Cheers.

Comments (5)

airlocker:

I couldn't get info/warn/error levels to work, only fatal would show in the console. Then I used setLevel(0) and it works perfectly now. Thanks!

var console:LogBookConsole = new LogBookConsole('_localconnectionname');
Logger.console = console;
Logger.setLevel(0);

Logger.info(this, "Something crazy happened");
Logger.fatal(this, "KaBoom");
Logger.warn(this, "Dont say you haven't been warned");

Hi, this looks awesome! I must be crazy, but I can't see to get it to work in my own project. I'm trying it on a Flash CS3 project (as3), and I dropped the SWC file here:

"/Applications/Adobe Flash CS3/Configuration/ActionScript 3.0/Classes/"

My actual code looks like this:

import net.comcast.logging.*;
import net.comcast.logging.consoles.*;

var console:LogBookConsole = new LogBookConsole('_localconnectionname');
Logger.console = console;
Logger.info(this,"Ready to go!");

But as soon as I try to compile, I get this error:

VerifyError: Error #1014: Class net.comcast.logging.consoles::LogBookConsole could not be found.

at global$init()

Any ideas? :) Thanks!


Nicolas,

I have just added Flash CS3 support to the LogBook / CIMLogging framework. Here are the steps to work with LogBook in Flash cs3:

1) Download CIM_Logging_1.3.swc (or higher) from http://cimlogbook.googlecode.com

2) Move the swc to your /Applications/Adobe Flash CS3/Configuration/Components directory (or windows equivalent)

3) Launch Flash and open the components window

4) Drop the Logging and the LogBookConsole components to the stage (they are not visible, I still have to create a visual icon for them)

5) Use the steps above to work with LogBook

Let me know if this doesn't work for you

You are amazing! Thanks, this works great!

-Nick

arpit:

:). You are welcome. Good luck !

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on April 2, 2008 11:55 AM.

The previous post in this blog was Fan 4.2.1 Launched : Save videos to watch later.

The next post in this blog is NCAA Fan a Slam Dunk!.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.35