On 20/01/2012 04:32, Alex Harui wrote:
Martin, what problem or problems are you trying to solve?
My long-term thoughts on logging was that if the framework was more granular,
you would swap in
loggable versions of the granules when and where you needed them.
I guess I repeat myself but however: The problem is that you have to
identify which granules are which. Right now we have 3 options:
1) retrieve a logger instance with getLogger(category) that granulates
on class basis. Its obvious that this granulation can only granulate to
the class level not per level method.
2) granulate by asking the user to provide it on each statement, this is
tedious and users simply skip it.
log("my message", "com.mypackage.MyClass");
3) granulate by using a error and analyzing the stack trace. Which is
obviously
function log() {
if( debug_player ) {
var e: Error = new Error();
// get granule by stacktrace, just works in debug player, just works
}
}
Now: if we had the compiler injected data of the callers location (file
and line number) we could granulate very fast with a lookup and/or a
simple string operation. Down to the method level, which important for
bug tracking. And to top it all off, it would work in
non-debug-players. As simple as a trace statement but as powerful as
complex logging.
In general, I don't like code baked even if it has a minimal cost.Eventually it
all adds up. And I don't like littering code with metadata.
The injection of data that is fixed from the time of compilation (not
before) is a reasonable thing to be added to a compiler. Why? Because it
bloats code a lot more if it has to be by hand (seeing all the log =
Log.getLogger() statements). In general I think AS3 can become a
thinner, faster and easier to use language with this construct, as any
workaround to the problematic of compilation data results in a lot of code.
yours
Martin.