Main

LogBook Archives

February 8, 2008

Say Hello to LogBook

Most Flex developers write perfect code ;). However, every once in a while, a bug appears somewhere in your application that becomes notoriously hard to find. Worse when the bug actually appears on a live web application and you have very poor visibility into whats happening within your application. In such cases, logging application events can be a blessing. As Flex developers may know, Flex has a pretty robust logging framework. However the default logging target is just the trace window and lacking in functionality most developers need. We hope this tool can improve that.

Logbook is a tool that we developed within Comcast Interactive Media for logging messages from our Flex applications. LogBook is a desktop application built using Adobe AIR, so works on both Macs and PCs. This is the first public build of it and we have a list of features we are hoping to add in the coming months. LogBook is released under the MIT Open Source License.

Picture%2010.png


How does it work
The LogBook application listens on a LocalConnection to messages sent from any application. When you launch LogBook, it will prompt you to enter the name of the connection you want to listen to. On the other end, in your Flex application, you must use the LocalConnectionTarget object in the cim.fx.logging.targets package as a logging target. And thats pretty much it. Now all logs will get sent to the LogBook application.

Features
There are quite a number of interesting features in LogBook that make it really useful:

Color coded alerts
LogMessages in the LogBook are color coded from gray for simple debug messages to red indicating fatal messages. This makes them really easy to spot when looking through a large set of log messages.

Level based filtering
The drop down ComboBox quickly lets you select what level you are interested in. For example, when debugging an application if you only care to see warning, error and fatal messages, you can set your level to "Warn" and all messages below that threshold will not be visible.

Logger based filtering
In a typical Flex application you can create a variety of Loggers by calling the Log.getLogger('...') method (see http://livedocs.adobe.com/labs/flex3/langref/mx/logging/Log.html#getLogger()). Each Logger created gets listed in the list on the right hand side of LogBook. By clicking on any logger listed there, you can filter data among the different Loggers that are logging messages letting you isolate messages from classes you are debugging from the larger log files. The list supports multiple selections.

Live Search
Using the text-input at the top of the application lets you filter on text in messages within your logs to quickly find info you are looking for.

Save to file
You can even save the logs into a text file on your machine. Log files are saved as formatted text that is very readable using any text editor.

Text view vs. Grid view
While most of the time, the grid view works to view log messages, you can even switch to text view if for example you want to copy paste a certain part of the log message. Once again, the text view is cleanly formatted to be readable.

Open source
The LogBook is released under the open source MIT license which means you are welcome to take the source code and build on top of it if you wish. However, we encourage you to submit feature requests and code that we can integrate into the core LogBook application so that evolution of this application benefits the entire Flex developer community.
All code is housed on the Google Code site and bugs and feature requests will be listed there as well.

Download LogBook
Download the LocalConnection based Logging class here. To use this, see the "Using LogBook" section of this post.

Using LogBook

Once you have installed LogBook, launch it and you will be prompted to enter the name of the localConnection you want it to listen to. The example below broadcasts messages out on a channel named _test. Enter _test in the text input. Now in the widget below, put any message in the text input, choose the level you want to send the message as and hit send. In your application, you will immediately see the message appear in the main view. Add a few more messages and play around with the filtering functions in LogBook.

The source code for the widget below can be downloaded from here.

To enable LogBook logging in your application, all you have to do is include the cim.fx.logging.targets.LocalConnectionTarget in your classpath and create a new LocalConnectionTarget object initializing it with the name of your communication channel. Once thats set as your Logger, you should be good to go.
You can use the source code of this widget as a starting point to get into LogBook.

About LogBook

This page contains an archive of all entries posted to The CIM Flash Team Blog in the LogBook category. They are listed from oldest to newest.

General is the previous category.

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

Powered by
Movable Type 3.35