/** * Logging Flex and AS3 projects with Firebug * * @author Jens Krause [www.websector.de] * @date 04/21/07 * @see http://www.websector.de/blog/2007/04/21/logging-flex-2-and-as-3-apps-with-firebug-and-thunderbolt/ * @source http://flash-thunderbolt.googlecode.com/svn/trunk/as3/ * */ package org.osflash.thunderbolt { import flash.external.ExternalInterface; import flash.utils.describeType; import flash.utils.getQualifiedClassName; import flash.utils.getDefinitionByName; /** * */ public class Logger { public static const LOG: String = "log"; public static const INFO: String = "info"; public static const WARN: String = "warn"; public static const ERROR: String = "error"; private static const MAX_DEPTH: int = 255; private static var depth: int; private static var logLevel: String; /** * Calls Firebugs command line API to write log information * * @param msg log Message * @param obj log object */ public static function trace (msg: String = null, obj:Object = null): void { depth = 0; // // log description logLevel = (msg != null) ? Logger.getLogLevel(msg) : Logger.LOG; var txtMessage: String = (msg != null && msg.length>= 3) ? msg.slice(2) : ""; var logMsg: String = logLevel.toUpperCase() + ": " + txtMessage; ExternalInterface.call("console." + logLevel, logMsg); // // log object if (obj) Logger.logProperties(obj); } /** * Logs nested instances and properties * * @param logObj log object * @param id short description of log object */ private static function logProperties (logObj: *, id: String = null): void { ++ depth; var propID: String = id || ""; if (depth