Added Log facilities like we're used to, and discovered a host of

new wacky things (and possible compiler bugs) on the way.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3888 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-02-24 01:28:55 +00:00
parent ac6e897905
commit 76ae4d5f5a
17 changed files with 195 additions and 56 deletions
+10
View File
@@ -7,6 +7,16 @@ public class ClassUtil
return flash.util.getQualifiedClassName(obj).replace("::", ".");
}
public static function shortClassName (obj :Object) :String
{
var s :String = flash.util.getQualifiedClassName(obj);
var dex :int = s.lastIndexOf(".");
if (dex != -1) {
s = s.substring(dex);
}
return s.replace("::", ".");
}
public static function getClass (obj :Object) :Class
{
return flash.util.getClassByName(getClassName(obj));
+40
View File
@@ -0,0 +1,40 @@
package com.threerings.util {
import mx.logging.ILogger;
import mx.logging.LogEventLevel;
import mx.logging.targets.TraceTarget;
/**
* Jesus Horseradish Christ. I wanted to just call this class Log, but
* other classes that don't even import it are getting confused between
* this and the subclasses with the same name. It's possible that this
* is some wacky compiler bug.
*/
public class LogDaddy
{
/**
* Retrieve the Logger for the specified package name, and ensure
* that our log target is set up.
*/
public static function getLogger (pkg :String) :ILogger
{
if (_targ == null) {
// goddamn I wish we could just have static initializers
_targ = new TraceTarget();
_targ.filters = ["*"];
_targ.level = LogEventLevel.DEBUG;
mx.logging.Log.addTarget(_targ);
// we could do some stuff here: set up different targets
// with different log levels...
}
return mx.logging.Log.getLogger(pkg);
}
/** The logging target for all packages. Needed only because we
* cannot have static initializers, so we need to know in getLogger
* if we've set up the target yet or not. */
private static var _targ :TraceTarget;
}
}