package ro.badu.utils.debug { import flash.utils.getQualifiedClassName; import flash.utils.getTimer; import mx.utils.ObjectUtil; CONFIG::AIR_LOG { import ro.badu.utils.debug.logger.LogWriter; } /* A simple class which allows you to perform "extensive" traces. @authors : Per Kristian Stoveland - perk.stoveland@gmail.com (original had no package name) Dinu Bogdan Gabriel - badu@badu.ro Usage example: protected function someMethod():void { var myArrayCollection : ArrayCollection = new ArrayCollection(); myArrayCollection.addItem({firstname:"test1" , lastname: "test2"}); myArrayCollection.addItem({firstname:"test3" , lastname: "test4"}); OldTracer.log( this , "someMethod" , myArrayCollection , true); } public static function log( inClass:Object, inMethod:String = "", message:Object=null, isObjectUtilDump : Boolean = false ):void Parameters : inClass - where is the place the trace comes from inMethod - usually a string that you have to complete by hand to illustrate in which method message - the message you want to trace. Can accept complex objects which in combination with isObjectUtilDump= true will use ObjectUtil to dump it all isObjectUtilDump - see above Note : do not forget to set compiler params -define CONFIG::DEBUG true -define CONFIG::AIR_LOG false if you are using it as it is */ public class OldTracer { private static var _useQName:Boolean = true; public static function set useQualifiedClassName( b:Boolean):void { _useQName = b; } public static function log( inClass:Object, inMethod:String = "", message:Object=null, isObjectUtilDump : Boolean = false ):void { if (CONFIG::AIR_LOG) { var _log:LogWriter = new LogWriter(); } try { var className:String = getQualifiedClassName( inClass ); if( !_useQName ) { var start:uint = className.indexOf( "::" ) + 2; className = className.substring( start, className.length ); } } catch( e:Error ) { trace( "Can not get qualified class name for: " + inClass.toString() + " in Tracer." ); return; } var _tracedMessage:String ; _tracedMessage = "[" + getTimer() + "]\t" + className; if( inMethod == "" ) _tracedMessage += "()"; else _tracedMessage += "/" + inMethod + "()"; if (isObjectUtilDump) { if( message != null ) _tracedMessage += "\n" + ObjectUtil.toString(message); } else { if( message != null ) _tracedMessage += " - " + message; } if (CONFIG::AIR_LOG) { _log.log(_tracedMessage); } trace(_tracedMessage); } } }