J.Wang,
There are some more other ways of logging objects. You can use
dump() instead of the older
TraceUtils.traceObject. I believe these are globally available inside the utils module.
// dump(object:Object, depth:uint = 3, duplicates:Boolean = true, constants:Boolean = false, namespaces:Boolean = false, methods:Boolean = false, dates:Boolean = false):Stringtrace(dump(myObject));You can also use
objectToString which creates a nice readable string of an object.
// objectToString(object:*, props:Vector.<String> = null, notEmpty:Boolean = false):Stringtrace(objectToString(myObject, Vector.<String>["name", "id"]));I'm not sure but I guess it's been deprecated to force to use the Log class. This class gives more control if a trace should be send or not. This is useful to quickly setup production-ready applications (you don't want to send debug info in your final app). The messages will also be send to
Yalog using a local connection. You can use the ready for use
yalala which basically is an ready to use (extended) version of Yalog.
These methods metioned above are very specific. That said, you can use the global log function which does the '
trace' for you.
// log (message, object, depth);
log("myObject", myObject, 4);.. Basically the
log is a friendly way to send a message to the
Log class. But of course you can call the Log functions yourself:
Log.addEventListener(handleLogEvent); // handle events locally
Log.showTrace(false); // don't output log messages as traces
Log.debug("This is a debug message", this);
Log.error("This is an error message", this);
Log.info("This is an info message", this);If you extend
CoreObject (or CoreSprite, CoreMovieClip CoreBitmap etc..), you have even more quick access to these functions, because its build-in.
this.logInfo("This is an info message");
this.logDebug("This is an debug message");
this.logError("This is an error message");
this.logStatus("This is an status message");As you can see, there are a lot of ways to give you debug information.
You also noted to add printf-as3. I haven't use this library, but you could take a look at
StringUtils.replaceVars() inside the utils module.
trace(StringUtils.replaceVars("hello, my name is {name}", {name:'Mark'}));
// output: hello, my name is MarkHope that helps.