Simplified logging facilities.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4131 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
package com.threerings.util {
|
||||
|
||||
import mx.logging.ILogger;
|
||||
|
||||
public class Log extends LogDaddy
|
||||
{
|
||||
/** The Logger for this package. */
|
||||
public static var log :ILogger = getLogger("util");
|
||||
|
||||
/** Convenience function. */
|
||||
public static function debug (message :String, ... rest) :void
|
||||
{
|
||||
log.debug(message, rest);
|
||||
}
|
||||
|
||||
/** Convenience function. */
|
||||
public static function info (message :String, ... rest) :void
|
||||
{
|
||||
log.info(message, rest);
|
||||
}
|
||||
|
||||
/** Convenience function. */
|
||||
public static function warning (message :String, ... rest) :void
|
||||
{
|
||||
log.warn(message, rest);
|
||||
}
|
||||
|
||||
/** Convenience function. */
|
||||
public static function logStackTrace (err :Error) :void
|
||||
{
|
||||
log.warn(err.getStackTrace());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
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
|
||||
{
|
||||
return mx.logging.Log.getLogger(pkg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Our static (class) initializer.
|
||||
*/
|
||||
private static function staticInit () :void
|
||||
{
|
||||
var targ :TraceTarget = 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...
|
||||
}
|
||||
|
||||
staticInit(); // call our static initializer
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public class MessageBundle
|
||||
}
|
||||
|
||||
if (reportMissing) {
|
||||
Log.warning("Missing translation message " +
|
||||
Log.getLog(this).warning("Missing translation message " +
|
||||
"[bundle=" + _path + ", key=" + key + "].");
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ public class MessageBundle
|
||||
// if the base key is not found, look to see if we should try to
|
||||
// convert our first argument to an Integer and try again
|
||||
if (msg == null) {
|
||||
Log.warning("Missing translation message " +
|
||||
Log.getLog(this).warning("Missing translation message " +
|
||||
"[bundle=" + _path + ", key=" + key + "].");
|
||||
}
|
||||
|
||||
|
||||
@@ -137,8 +137,8 @@ public class MessageManager
|
||||
rbundle = ResourceBundle.getResourceBundle(fqpath);
|
||||
// }
|
||||
} catch (mre :Error) {
|
||||
Log.warning("Unable to resolve resource bundle " +
|
||||
"[path=" + fqpath + "].");
|
||||
Log.getLog(this).warning("Unable to resolve resource bundle " +
|
||||
"[path=" + fqpath + "].");
|
||||
}
|
||||
|
||||
// if the resource bundle contains a special resource, we'll
|
||||
@@ -157,8 +157,8 @@ public class MessageManager
|
||||
// nothing to worry about
|
||||
|
||||
} catch (t :Error) {
|
||||
Log.warning("Failure instantiating custom message bundle " +
|
||||
"[mbclass=" + mbclass + ", error=" + t + "].");
|
||||
Log.getLog(this).warning("Failure instantiating custom message" +
|
||||
" bundle [mbclass=" + mbclass + ", error=" + t + "].");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,9 @@ public class ObserverList
|
||||
remove(list[ii]);
|
||||
}
|
||||
} catch (err :Error) {
|
||||
Log.warning("ObserverOp choked during notification.");
|
||||
var log :Log = Log.getLog(this);
|
||||
log.warning("ObserverOp choked during notification.");
|
||||
log.logStackTrace(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user