Monthly Archives: June 2010

TrazzlePublisher.

If you use as3logger to standardize your AS3 logging needs, I’ve got something for you.

At Falanxia we’ve been using SOS Max Logger by PowerFlasher, but recently I’ve found a great new supplement, which I think is a great leap forward: Trazzle. Let me copy paste few features we love here:

  • Bitmap logging
  • Performance monitoring
  • Multiple Log Levels
  • TextMate support

For us just the Bitmap logging feature was a reason to switch. In case we logged events just via SOS Max, there would be a need to rewrite all logger calls, and it would be a somewhat painful and completely useless experience. Since we use the as3logger approach, it was really easy to add a small Trazzle wrapper. And there was no need to rewrite anything in our sources.

Here’s the source:

/*
 * Falanxia Utilitaris.
 *
 * Copyright (c) 2010 Falanxia (http://falanxia.com)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.falanxia.utilitaris.logger {
    import com.falanxia.utilitaris.utils.*;
    import com.nesium.logging.*;

    import de.dev_lab.logging.*;
    import de.dev_lab.logging.publisher.*;

    import flash.display.*;



    /**
     * The {@code String} publisher outputs the Log to a Trazzle.
     * See more info about Trazzle here:
     * http://www.nesium.com/products/trazzle
     *
     * @author Vaclav Vancura @ Falanxia a.s. vaclav@falanxia.com
     * @author Falanxia (http://falanxia.com, @falanxia)
     * @since 1.0
     */
    public class TrazzlePublisher implements IPublisher {


        private static var _trazzle:TrazzleLogger;



        /**
         * Constructor.
         */
        public function TrazzlePublisher(stageReference:Stage, appName:String) {
            if(_trazzle == null) {
                _trazzle = new TrazzleLogger();
                _trazzle.setParams(stageReference, appName);
            }
        }



        /**
         * Outputs the message to the {@code String}.
         * @param logLevel Log level
         * @param object Message
         */
        public function publish(logLevel:int, object:*, ...additional):void {
            var prefix:String;

            switch(logLevel) {
                case Logger.DEBUG:
                    prefix = "d ";
                    break;

                case Logger.INFO:
                    prefix = "i ";
                    break;

                case Logger.WARN:
                    prefix = "w ";
                    break;

                case Logger.ERROR:
                    prefix = "e ";
                    break;

                case Logger.FATAL:
                    prefix = "f ";
                    break;

                default:
                    prefix = "";
            }

            if(object == null) object = "[null]";

            _trazzle.log(prefix + String(object), 4);
        }



        /**
         * Clear.
         * Trazzle has no clear method, so it's just a placeholder.
         */
        public function clear():void {
        }



        /**
         * Destructor.
         */
        public function destroy():void {
            clear();
        }



        /* ★ SETTERS & GETTERS ★ */


        /**
         * Get Trazzle reference.
         * @return Reference to Trazzle
         */
        public static function get trazzle():TrazzleLogger {
            return _trazzle;
        }
    }
}

Of course you need as3logger de.dev_lab.logging.Logger class.

All you need now is just an initialization of the logger:

Logger.addPublisher(new TrazzlePublisher(stage, "My application name"));

And you can log as you logged before:

Logger.debug("Debug message");
Logger.info("Info message");
Logger.warn("Warning message");
Logger.error("Error message");
Logger.fatal(Math.random() * 1000);

If you want to call Trazzle for any reason (e.g. to log a Bitmap), you can use:

var myBitmapData = new BitmapData(100, 100);
myBitmapData.noise(Math.random() * 1000);
TrazzlePublisher.trazzle.logBitmapData(myBitmapData);

Or to invoke a beep and show a performance window:

TrazzlePublisher.trazzle.beep();
TrazzlePublisher.trazzle.startPerformanceMonitoring();

You can fork or watch the Gist for this class here on Git.

Bzoonk
Use arrow keys to go to the bar, drink beer and run to the toilet before time is out. How many beers could you stand? This is the first game by the Falanxia team I currently work with.
Year:
2010
Client:
Falanxia
See it live at apps.facebook.com

IntelliJ IDEA Refactoring Updates.

As you may know, IntelliJ IDEA employs one of the best refactoring features you can meet in an IDE. Now the beta version 9.0.3 EAP adds something what amused me so much, that I decided to mock a small strip below.

It’s easy: when you have a variable expression you want to extract, you can use “Introduce Variable” refactoring feature. Now I noticed the last EAP is even able to find ALL similar expressions and replace them at once. Click the image below to understand what I am talking about.


IntelliJ IDEA 9.0.3 Introduce Variable features Click the image to see the full resolution mockup.

I really dig IntelliJ IDEA. And even I am 7/24 user, I still find new features which blow me away. If you’re unhappy with your current ActionScript IDE of choice, you should try IDEA today.