Is it possible to save logs of Trace somewhere, so that I can look up traces for players?
1 Answer
Yes, but for that you need a logger function instead of trace(). By the way, if you compile your SWF in release mode, no traces will happen. Say like this one:
private static var COMPLETE_LOG:String=''; public static function log(...args):void { var i:int; var s:String='\n'; for (i=0;i<args.length;i++) { if (i>0) s+=' '; s+=args[i].toString(); } COMPLETE_LOG+=s; } Use log() instead of trace() to capture traces you need. And then say upload that COMPLETE_LOG somewhere.
4 Comments
Mark Topper
So I should just upload a file called COMPLETE_LOG? And I can't see where I should enter the directory for it..
Vesper
It's not a file, it's a String variable that will contain all your logs. Flash does not automatically save files anywhere, only on user demand. To upload, you need a mechanism to accept such uploads first, and the solution will depend on this.
Mark Topper
Thanks a lot. But I found a method to post informations to a PHP file, and was thinking of just doing such, and then I will just send all 'trace's to the PHP and let it save it.. Isn't that a good idea aswell? Or would this be a bad idea?
Vesper
Basically correct. You send a request with one of the parameters be this string (UUencode it or unescape to make it parsable by PHP), and process it on the server as a complete set of traces. If you need real-time trace sending, do that instead of logging into a local variable.