| Package | uk.msfx.utils.tracing |
| Class | public class Tr |
| Inheritance | Tr Object |
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.
With Tr.ace() you can manage all your output statements, restricting or ignoring your applications traces to specific users and/or even specific Classes. Or you can toggle tracing off entirely.
The output using Tr.ace() can also be formatted with timestamps, linebreaks, the name of the user tracing, the Class the trace resides within and can be automatically copied to the clipboard.
For those using FlashDevelop you can prefix your username with "0:", "1:", "2:", "3:", or "4:" to trace in a different colour within the FlashDevelop output console, as shown with the 'FLASH_DEVELOP' username included.
UPDATE 1.1: The Tr.ace() library has been extended to feature Tr.aceArray(...) and Tr.aceObject(...), two functions to neatly format Arrays and Objects within the output console.
UPDATE 1.2: The Tr.ace() library has been extended again to feature Tr.aceMulti(...), a function to trace an unlimited number of arguments all on one line.
| Property | Defined By | ||
|---|---|---|---|
| arrayAndObjectLinebreaks : Boolean [static]
Toggle whether a line break will be added at the beginning and end of a Tr.aceArray() or Tr.aceObject() call. | Tr | ||
| copyToClipboard : Boolean [static]
Toggle whether the output is automatically updated to the clipboard. | Tr | ||
| ignoreClasses : Array [static]
An Array of Classes (Class) that you wish the output to ignore
Example:
To ignore the output from only your Main class you would use the following:
Tr.ignoreClasses = [ClassName1];
or to ignore from multiple classes
Tr.ignoreClasses = [ClassName1, ClassName2];
| Tr | ||
| ignoreUsers : Array [static]
An Array of Users (String) that you wish the output to ignore
Example:
To ignore the output from the DEFAULT user you would use the following:
Tr.ignoreUsers = [Tr.DEFAULT];
or to ignore from multiple users
Tr.ignoreUsers = [Tr.DEFAULT, TR.MATT];
| Tr | ||
| off : Boolean [static]
Toggle whether the output is on or off
| Tr | ||
| restrictToClasses : Array [static]
An Array of Classes (Class) that you wish the output to be restricted to. | Tr | ||
| restrictToUsers : Array [static]
An Array of users (Strings) that you wish the output to be restricted to. | Tr | ||
| useLineBreaks : Boolean [static]
Toggle whether the output (and clipboard if toggled on) has line breaks inbetween each trace. | Tr | ||
| useTimeStamp : Boolean [static]
Toggle whether each trace feautures a timestamp (HH:MM:SS:MS). | Tr | ||
| Method | Defined By | ||
|---|---|---|---|
Tr()
Static Class, Unused Constructor. | Tr | ||
ace(output:*, user:String, withinClass:*):void [static]
Function to trace to the output console. | Tr | ||
aceArray(output:Array, user:String, withinClass:*):void [static]
Function to trace the elements of an Array to the output console, in a neatly formatted manner. | Tr | ||
aceMulti(user:String, withinClass:*, ... values):void [static]
Function to trace multiple values out to the console. | Tr | ||
aceObject(output:Object, user:String, withinClass:*):void [static]
Function to trace the properties of an Object to the output console, in a neatly formatted manner. | Tr | ||
| Constant | Defined By | ||
|---|---|---|---|
| DEFAULT : String = default [static]
Default User
| Tr | ||
| FLASH_DEVELOP : String = 3:flashdevelop [static]
Flash Develop Example User
Prefixed with "3:" so the output will be red within the FlashDevelop output console.
| Tr | ||
| MATT : String = matt [static]
Author
| Tr | ||
| arrayAndObjectLinebreaks | property |
arrayAndObjectLinebreaks:BooleanToggle whether a line break will be added at the beginning and end of a Tr.aceArray() or Tr.aceObject() call.
public static function get arrayAndObjectLinebreaks():Boolean public static function set arrayAndObjectLinebreaks(value:Boolean):void| copyToClipboard | property |
copyToClipboard:BooleanToggle whether the output is automatically updated to the clipboard.
public static function get copyToClipboard():Boolean public static function set copyToClipboard(value:Boolean):void| ignoreClasses | property |
ignoreClasses:ArrayAn Array of Classes (Class) that you wish the output to ignore
Example:
To ignore the output from only your Main class you would use the following:
Tr.ignoreClasses = [ClassName1];
or to ignore from multiple classes
Tr.ignoreClasses = [ClassName1, ClassName2];
public static function get ignoreClasses():Array public static function set ignoreClasses(value:Array):void| ignoreUsers | property |
ignoreUsers:ArrayAn Array of Users (String) that you wish the output to ignore
Example:
To ignore the output from the DEFAULT user you would use the following:
Tr.ignoreUsers = [Tr.DEFAULT];
or to ignore from multiple users
Tr.ignoreUsers = [Tr.DEFAULT, TR.MATT];
public static function get ignoreUsers():Array public static function set ignoreUsers(value:Array):void| off | property |
off:BooleanToggle whether the output is on or off
public static function get off():Boolean public static function set off(value:Boolean):void| restrictToClasses | property |
restrictToClasses:ArrayAn Array of Classes (Class) that you wish the output to be restricted to.
Example:
To restrict the output from only your Main class you would use the following:
Tr.restrictToClasses = [ClassName1];
or to restrict to multiple classes
Tr.restrictToClasses = [ClassName1, ClassName2];
public static function get restrictToClasses():Array public static function set restrictToClasses(value:Array):void| restrictToUsers | property |
restrictToUsers:ArrayAn Array of users (Strings) that you wish the output to be restricted to.
Example:
To restrict the output from the DEFAULT user you would use the following:
Tr.restrictToUsers = [Tr.DEFAULT];
To restrict to multiple users you would simply do this:
Tr.restrictToUsers = [Tr.DEFAULT, Tr.MATT];
NB: I suggest you add your username(s) to this class rather than entering a String each time (removing the risk of typos).
public static function get restrictToUsers():Array public static function set restrictToUsers(value:Array):void| useLineBreaks | property |
useLineBreaks:BooleanToggle whether the output (and clipboard if toggled on) has line breaks inbetween each trace.
public static function get useLineBreaks():Boolean public static function set useLineBreaks(value:Boolean):void| useTimeStamp | property |
useTimeStamp:BooleanToggle whether each trace feautures a timestamp (HH:MM:SS:MS).
public static function get useTimeStamp():Boolean public static function set useTimeStamp(value:Boolean):void| Tr | () | Constructor |
public function Tr()Static Class, Unused Constructor.
| ace | () | method |
public static function ace(output:*, user:String, withinClass:*):voidFunction to trace to the output console.
Examples:
Tr.ace("This is a trace statement", Tr.MATT, ClassName);
Tr.ace(4 + 21 + variableName, Tr.YOUR_USERNAME, AnotherClassName);
Tr.ace("without the username or classname");
NB: The Tr.DEFAULT user will be used if no username is entered.
Parameters
output:* — The output that you wish to trace to the console
| |
user:String — The name of the user tracing the output
| |
withinClass:* — The name of the Class the output is being traced from
|
| aceArray | () | method |
public static function aceArray(output:Array, user:String, withinClass:*):voidFunction to trace the elements of an Array to the output console, in a neatly formatted manner.
Examples:
Tr.aceArray(["array", "test", 101, true], Tr.MATT, ClassName);
var dummyArray:Array = ["array", "test", 101, true];
Tr.aceArray(dummyArray, Tr.YOUR_USERNAME, AnotherClassName);
Tr.aceArray(["without", "username or", "classname"]);
NB: The Tr.DEFAULT user will be used if no username is entered.
Parameters
output:Array — The Array that you wish to trace to the console
| |
user:String — The name of the user tracing the output
| |
withinClass:* — The name of the Class the output is being traced from
|
| aceMulti | () | method |
public static function aceMulti(user:String, withinClass:*, ... values):voidFunction to trace multiple values out to the console.
The User and Class are requested first since nothing can preceed '...values'.
Example:
Tr.aceMulti(Tr.DEFAULT, ClassName, "string to trace", 1.2 + 4.5, ["array", "to", "trace"]);
Parameters
user:String — The name of the user tracing the output
| |
withinClass:* — The name of the Class the output is being traced from
| |
... values — The values that you wish to trace to the console
|
| aceObject | () | method |
public static function aceObject(output:Object, user:String, withinClass:*):voidFunction to trace the properties of an Object to the output console, in a neatly formatted manner.
Examples:
Tr.aceObject({"a" : 1, "b" : 2, "c" : 3], Tr.MATT, ClassName);
var dummyObject:Object = {"array test" : [1, 2, 3], "numbers" : 123.456, "obj" : {"a" : 1, "b" : 2, "c" : 3} };
Tr.aceArray(dummyObject, Tr.DEFAULT, AnotherClassName);
NB: The Tr.DEFAULT user will be used if no username is entered.
Parameters
output:Object — The Object that you wish to trace to the console
| |
user:String — The name of the user tracing the output
| |
withinClass:* — The name of the Class the output is being traced from
|
| DEFAULT | Constant |
public static const DEFAULT:String = defaultDefault User
| FLASH_DEVELOP | Constant |
public static const FLASH_DEVELOP:String = 3:flashdevelopFlash Develop Example User
Prefixed with "3:" so the output will be red within the FlashDevelop output console.
| MATT | Constant |
public static const MATT:String = mattAuthor