Apr 05, 2010

Quick Tip: Use Terminal to Read Live Traces

On a recent PHP project, I was having trouble with the somewhat ridiculous PHP error handling and Alec, a developer here, pointed me to the terminal "tail" command.  This command keeps a persistent connection open to a file and reads the contents into a terminal window.  Using it I was able to tail the php_error_log file, which gave me a full readout of errors regardless of 17 different ways to set PHP error levels. This technique can also be used for debugging Flash content.

All Flash errors are actually also written to a log file.  For Mac users it can be found at: /Users/username/Library/Preferences/Macromedia/Flash\ Player/Logs/flashlog.txt and for Windows users at: C:\Documents and Settings\username\Application Data\Macromedia\Flash Player\Logs

So why is this interesting?  It's not just when you're debugging that traces are written to this file.  If you visit any website that contains traces, warning, or errors, you'll see this file change.  Effectively, we can monitor traces from live pages.  Pretty cool!  If you've ever used Alessandro Crugnola's FlashTracer extension for Firefox (now depreciated?) it's a very similar functionality.  This might be useful in debugging from live servers, though you'd be better off considering a solution like Arthropod, which we at the Ship are fond of.

The command looks something like this:
tail -f /Users/username/Library/Preferences/Macromedia/Flash\ Player/Logs/flashlog.txt

Note that I'm using the '-f' flag (follow) which keeps the connection open.  Without that, it would just read back the last 50 lines in the file and then stop.

Share this Post


                           

Comments


Charlie Whitney     Apr 06, 2010
Wow, fantastic suggestion everyone. I began just using this when I was in a pinch, but some of these solutions are really elegant and might be worth a permanent switch. It's very easy to love this community.

Ben     Apr 06, 2010
That's an interesting solution. We use SOSMax, a free Java logger. It has several different levels of logging, does remote socket logging, and has a nice regex filtering system so you can look at only the logs you want. Using it in conjunction with flash.mx.ILogger gives you FlashPlayer logs as well.

FlassAri     Apr 06, 2010
Mozilla's extension page has a deprecated version of Alessandro's FlashTracer plugin, for the newest version you can just go directly to FlashTracer's page: http://www.sephiroth.it/firefox/flashtracer/

He also made a firebug plugin which servers the same purpose: http://www.sephiroth.it/firefox/fbtracer/

The extensions are usually up to date on his website.

N10-004     Apr 05, 2010
good post

Mike Creighton     Apr 05, 2010
While the tail command very useful, I'd recommend (since you're on OS X) using Console.app to tail your Flash log file. You get it for free when you install the Apple Developer Tools from your OS X DVD.

Console gives you the ability to filter your log using simple strings in realtime via the handy Filter search text area in the upper-right corner of the app window. You can also use it to highlight your searched text (if you don't want to filter messages). Moreover, you can insert markers so you can have visual breakpoints.

Overall much more useful than tail. And for those of you on Windows who want something similar, I'd recommend the free WinTail app from Bare Metal Software:

http://www.baremetalsoft.com/wintail/

It's not as full-featured as Console.app, but it gets the job done. And they also sell a product called BareTail that's much more on par with Console.app:

http://www.baremetalsoft.com/baretail/

Gabriel Mariani     Apr 05, 2010
I was once a user of FlashTracer, but when it became more trouble than it was worth I developed Flashbug for Firebug. I encourage you to check it out, it has a lot of useful features. Or if you're looking for just a platform independent trace viewer, you should check out .whistler.

http://blog.coursevector.com/whistler
http://blog.coursevector.com/flashbug

Jeff     Apr 05, 2010
Flash Tracer actually just got a rewrite to run in Firebug. Check it out: http://www.sephiroth.it/weblog/archives/2010/03/flashtracer_for_firebug.php

Rachel     Apr 05, 2010
Another alternative I've been using lately is FlashBug which works with Firebug (https://addons.mozilla.org/en-US/firefox/addon/14465), its a tad simpler than using terminal.

Also I believe I saw that there was an update to FlashTracer recently. So though that's been out of commission for awhile it may be back up and running as of late.

manu     Apr 05, 2010
you can also just copy the "tail" line into a file, precede it with #/bin/bash and store that file with chmod +x into your /usr/bin folder with the filename "flashtrace". Next time you won't have to remember that command and can just call "flashtrace" from your terminal"

dafunker     Apr 05, 2010
Yeah, that's a great way to show notifications, errors !
Im using it too, Moreover, we can print colors (via ANSII caracters).

I'm using a class to debug and it use those caracters :
private var _ansi_prefix:String = String.fromCharCode(27);
private var _ansi_green:String = _ansi_prefix + "[1;32m";
private var _ansi_orange:String = _ansi_prefix + "[1;33m";
...

The dailymotion website ( by example, we can look the pink and blue traces via terminal with http://www.dailymotion.com/video/xak7bd_flash-cs5-adobe-keynote_tech )


Speak






Submit »