package logging { import serialize.*; import logserver.*; public class LogUtils { public static var s:Serializer = new DefaultSerializer(); private static function logVal(val): void { switch (typeof val) { case "boolean": WriteLog.log("Boolean value = " + val); break; case "number": WriteLog.log("Number value = " + val); break; case "string": WriteLog.log("String value = " + val); break; case "string": WriteLog.log("Xml value = " + val); break; case "object": if (val is Array) { WriteLog.log("Array valaue"); for (var i:uint = 0; i < val.length; i++) { WriteLog.log("element = " + i + " value = " + logVal(val[i])); } } else { WriteLog.log("Object value"); val.serializeSelf(s); s.reset() } break; } } public static function logVar(varName:String, val:*) { //WriteLog.initialize(); WriteLog.log("Logging variable " + varName); logVal(val); //WriteLog.dispose(); } public static function logFCallEntry(fName:String, ...args) { //WriteLog.initialize(); WriteLog.log("Start logging objects at function ENTRY: " + fName) for (var i:uint = 0; i < args.length; i++) { logVal(args[i]); } //WriteLog.dispose(); } public static function logFCallExit(fName:String, fRes, ...args) { WriteLog.initialize(); WriteLog.log("Start logging objects at function EXIT: " + fName) for (var i:uint = 0; i < args.length; i++) { logVal(args[i]); } //WriteLog.dispose(); } public static function logIf(branch:Boolean, cond:String) { if (branch) { trace ("THEN branch was taken: " + cond + " = TRUE"); } else { trace ("ELSE branch was taken: "+ cond + " = FALSE"); } } public static function logWhile(iterCount:int) { trace("ITERATION #"+iterCount); } } } // public static function logIf_(branch:Boolean, ...args) { // var log_message:String = ""; // if branch { // log_message = "THEN branch was taken: "; // } // else { // log_message = "ELSE branch was taken: "; // } // for (var i:uint = 0; i < args.length; i++) { // log_message += args[i] + ":" + (typeof (args[i]) + ","); // } // } //