Skip to content
Dima Kruk edited this page Jan 28, 2013 · 4 revisions

Logging is a language extension, that provides a more functional replacement for the trace operator in the pure ActionScript3. Unlike the classic trace function, the overloaded trace offers a number of simple and powerful tricks:

  • Message formatting.
  • Different verbosity levels.
  • Message numbering.
  • Using tabs for different groups of messages.
  • Using indents for placing emphasis on several lines of code.

Please note, that Logging language extension with improved trace operator is activated on by default in every project of CodeOrchestra.

##Basic Syntax

trace variable1 [, variable 2, …, variableN ]

Output values of all enumerated variables to the Messages window of the editor. Click on a trace message in this window will switch you to a line, that invoked this message.

var a : int = 42; 
var b : String = "Lorem ipsum"; 

trace a, b; //  -> 42, Lorem ipsum

trace values( variable1 [, variable2, …, variableN ] )

More extended syntax, that lets output names and values of all enumerated variables.

var a : int = 42; 
var b : String = "Lorem ipsum"; 

trace values(a, b); //  -> a=42, b=Lorem ipsum

trace [ package, class, method, args ]

Output values of context-sensitive variables that give access to code artifacts.

public function myClass(a : int, b : int, c : String) { 
  trace package; // -> package name 
  trace class;   // -> class name 
  trace method;  // -> method name 
  trace args;    // -> names and values of arguments 
                 // in our case, "args" is equivalent to "values (a, b, c)"
}

##Verbosity Level

debug … / error … / fatal … / info … / trace… / warn …

There are 6 different verbosity levels in the Logging language. Depending on the function chosen, it is possible to underscore difference between a warning and information message, between a fatal error and a nonthreatening debug report. trace, error and warn messages are distinct from each other with three different icons in the application log. Click on such icon will perform a filtering of similar message types.

debug "Hello!"; 
error "Hello!"; 
fatal "Hello!"; 
info "Hello!"; 
trace "Hello!"; 
warn "Hello!";

##Message Numbering

trace[ messageNumber ] …

Each logging message can contain a number prefix. You can place a number or a variable counter inside the square brackets heading to the message.

trace[0] "Hello!"; // -> [0] Hello!
trace[1] "Hello!"; // -> [1] Hello!
trace[2] "Hello!"; // -> [2] Hello!
trace[3] "Hello!"; // -> [3] Hello!

##Tabs and Indents

log-scope( tabName ) { … }

Logging message can be gathered to different tab inside the Messages window. Any code can be surround with a log-scope expression.

log-scope (myTab) { 
  var a : int = 42;
  var b : String = "Lorem ipsum";
  trace values(a, b); // this message appears inside a tab myTab
}
trace values(a, b);  // this message appears outside of a tab myTab

log-indent { … }

Log-indent expression is aimed to place emphasis on several lines of code, indenting them from others.

trace[0] "Hello!";
trace[1] "Hello!";
log-indent { 
  trace[2] "Hello!"; // Messages 2 and 3 will appear
  trace[3] "Hello!"; // with one-symbol left shift
} 
trace[4] "Hello!";
Clone this wiki locally