From 70cc9a651bffc0aa77aaf3ae05ecbff18cb7d740 Mon Sep 17 00:00:00 2001 From: peter delvaux Date: Tue, 31 Jul 2012 16:35:19 +0200 Subject: [PATCH 1/3] added logging to javascript console Added a function so you can log to the javascript console. To view this console, in chrome: view > development > javascript console (ctrl + alt + j) also added a line that shows a message if the function can't find any properties to trace. --- src/uk/msfx/utils/tracing/core/TrCore.as | 32 +++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/uk/msfx/utils/tracing/core/TrCore.as b/src/uk/msfx/utils/tracing/core/TrCore.as index 8867ab6..373e71b 100644 --- a/src/uk/msfx/utils/tracing/core/TrCore.as +++ b/src/uk/msfx/utils/tracing/core/TrCore.as @@ -2,6 +2,9 @@ * Tr.ace() by MSFX Matt Stuttard Parker * Version 2.0 * 10.06.2012 + * + * proposition by Peter Delvaux + * 31.07.2012 * * Copyright (c) MSFX Matt Stuttard Parker * @@ -31,6 +34,7 @@ **/ package uk.msfx.utils.tracing.core { + import flash.external.ExternalInterface; import flash.text.TextField; import flash.ui.Keyboard; import flash.utils.getQualifiedClassName; @@ -234,6 +238,8 @@ package uk.msfx.utils.tracing.core // start trace for Object out(prefix + "Begin Object Trace", user, withinClass, arrayAndObjectLinebreaks); + // a count variable, if no properties were found, you can display a message. + var count:uint; // loop over object tracing each property for (var p:* in output) { @@ -254,7 +260,13 @@ package uk.msfx.utils.tracing.core { out(prefix + "- [" + p + "] => " + output[p], user, withinClass); } - + count++; + } + + if(count == 0){ + // no properties where found. + out(prefix + "- No properties where found in: ", user, withinClass, arrayAndObjectLinebreaks); + out(prefix + "- " + output, user, withinClass, arrayAndObjectLinebreaks); } // end trace for Object @@ -305,6 +317,11 @@ package uk.msfx.utils.tracing.core // trace the users output trace(traceStr + output); + // if there is an external interface, log to the javascript console. + if(ExternalInterface.available){ + ExternalInterface.call("console.log", traceStr + output); + } + // update log _log += ((traceStr + output) + String.fromCharCode(Keyboard.ENTER)); @@ -317,6 +334,11 @@ package uk.msfx.utils.tracing.core // otherwise just trace every users output trace(traceStr + output); + // if there is an external interface, log to the javascript console. + if(ExternalInterface.available){ + ExternalInterface.call("console.log", traceStr + output); + } + // update log //_log += ((traceStr + output) + "\n"); _log += ((traceStr + output) + String.fromCharCode(Keyboard.ENTER)); @@ -329,6 +351,10 @@ package uk.msfx.utils.tracing.core if (_useLineBreaks) { trace(""); + // if there is an external interface, log a linebreak to the javascript console. + if(ExternalInterface.available){ + ExternalInterface.call("console.log", ""); + } // update log _log += "\n"; @@ -341,6 +367,10 @@ package uk.msfx.utils.tracing.core if (endWithLineBreak) { trace(""); + // if there is an external interface, log a linebreak to the javascript console. + if(ExternalInterface.available){ + ExternalInterface.call("console.log", ""); + } // update log _log += "\n"; From 99b2fa8ef4b2ca647cd71eb31ef2773c031492a3 Mon Sep 17 00:00:00 2001 From: peter delvaux Date: Tue, 31 Jul 2012 16:37:34 +0200 Subject: [PATCH 2/3] added markup added some markup to the readme file. --- README.txt | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/README.txt b/README.txt index c4321ef..87b7375 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -Tr.ace() is a library for formatting and managing trace statements within AS3. +# Tr.ace() is a library for formatting and managing trace statements within AS3. Tr.ace() is a static Class that uses the Singleton design pattern so you only need to define it's settings once within your application and you're all set. @@ -16,24 +16,19 @@ New in version 2.0 is the TrConsole allowing you to view your traces within a co The main functions are: -- Tr.ace(...) -- For managing standard trace statements +### Tr.ace(...) +For managing standard trace statements +### Tr.aceArray(...) +For formatting Arrays when traced -- Tr.aceArray(...) -- For formatting Arrays when traced +### Tr.aceObject(...) +For formatting Objects when traced +### Tr.aceMulti(...) +For formatting multiple arguments -- Tr.aceObject(...) -- For formatting Objects when traced +[Please view the docs for more information](http://docs.msfx.co.uk/as3/trace/) -- Tr.aceMulti(...) -- For formatting multiple arguments - - -Please view the docs for more information - http://docs.msfx.co.uk/as3/trace/ - - -MSFX Matt Stuttard Parker -http://msfx.co.uk \ No newline at end of file +[MSFX Matt Stuttard Parker](http://msfx.co.uk) \ No newline at end of file From b642410ab69f8e40606723ec30512770b2c2e3a0 Mon Sep 17 00:00:00 2001 From: pjetr Date: Tue, 31 Jul 2012 17:41:07 +0300 Subject: [PATCH 3/3] Update README.txt rollback --- README.txt | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/README.txt b/README.txt index 87b7375..c4321ef 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -# Tr.ace() is a library for formatting and managing trace statements within AS3. +Tr.ace() is a library for formatting and managing trace statements within AS3. Tr.ace() is a static Class that uses the Singleton design pattern so you only need to define it's settings once within your application and you're all set. @@ -16,19 +16,24 @@ New in version 2.0 is the TrConsole allowing you to view your traces within a co The main functions are: -### Tr.ace(...) -For managing standard trace statements +- Tr.ace(...) +- For managing standard trace statements -### Tr.aceArray(...) -For formatting Arrays when traced -### Tr.aceObject(...) -For formatting Objects when traced +- Tr.aceArray(...) +- For formatting Arrays when traced -### Tr.aceMulti(...) -For formatting multiple arguments +- Tr.aceObject(...) +- For formatting Objects when traced -[Please view the docs for more information](http://docs.msfx.co.uk/as3/trace/) -[MSFX Matt Stuttard Parker](http://msfx.co.uk) \ No newline at end of file +- Tr.aceMulti(...) +- For formatting multiple arguments + + +Please view the docs for more information - http://docs.msfx.co.uk/as3/trace/ + + +MSFX Matt Stuttard Parker +http://msfx.co.uk \ No newline at end of file