incubator-flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Heidegger>
Subject Trace & Log
Date Thu, 19 Jan 2012 17:37:34 GMT
Hello dear mailinglist,

I have been tinkering and thinking and working on logging for quite a 
while now. Comparing it to other systems there is a big issue with 
logging in flash that could be dealt with elegantly by the compiler: 
Location. Many people in fact use logging systems just have some sort of 
orientation as to where their trace statements  are. In many systems 
(including Flex logging system) you'd have to write things like 
getLogger("...") to create a location-like identifier that is somewhat 
performing fast. This approach lacks the method name and line number of 
that log statement. Now: you could work around that creating errors to 
get the line number but that is a _lot_ of overhead (creating an error 
object and analyzing the stack-trace for every trace statement).

Well, as its a legacy method I suggest to create a compiler feature that 
passes the file and line-number or any other property to a method using 

[Inject(param="file", value="caller.file.uri")]
[Inject(param="lineNumber", value="caller.file.line")]
function log(message: String, file:String, lineNumber: uint) {}

now if somewhere we have code like:

log("hello world");

the compiler automatically fills the other strings with the meta 
information of this logging point. This way logging systems could 
efficiently use the files location and maybe a lot of other information 
about the caller like f.ex. the describeType result for the caller.

What do you think about this approach? Would you be interested in 
something like that? Maybe you know of other use cases where this might 
proof useful?


View raw message