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:
Ray Greenwell
2006-05-19 22:47:44 +00:00
parent 98bbe02560
commit a22ca8b079
39 changed files with 286 additions and 358 deletions
-36
View File
@@ -1,36 +0,0 @@
package com.threerings.crowd {
import mx.logging.ILogger;
import com.threerings.util.LogDaddy;
public class Log extends LogDaddy
{
/** The Logger for this package. */
public static var log :ILogger = getLogger("crowd");
/** 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());
}
}
}
@@ -43,7 +43,6 @@ import com.threerings.util.MessageManager;
import com.threerings.util.Name;
import com.threerings.util.TimeUtil;
import com.threerings.crowd.Log;
import com.threerings.crowd.client.LocationObserver;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.PlaceObject;
@@ -88,7 +87,8 @@ public class ChatDirector extends BasicDirector
_cctx.getLocationDirector().addLocationObserver(this);
if (_bundle == null || _msgmgr == null) {
com.threerings.crowd.Log.warning("Null bundle or message manager given to ChatDirector");
Log.getLog(this).warning(
"Null bundle or message manager given to ChatDirector");
return;
}
var msg :MessageBundle = _msgmgr.getBundle(_bundle);
@@ -906,7 +906,7 @@ public class ChatDirector extends BasicDirector
if (bundle != null && _msgmgr != null) {
var msgb :MessageBundle = _msgmgr.getBundle(bundle);
if (msgb == null) {
com.threerings.crowd.Log.warning(
Log.getLog(this).warning(
"No message bundle available to translate message " +
"[bundle=" + bundle + ", message=" + message + "].");
} else {
@@ -33,7 +33,6 @@ import com.threerings.presents.dobj.ObjectAccessError;
import com.threerings.presents.dobj.Subscriber;
import com.threerings.presents.dobj.SubscriberAdapter;
import com.threerings.crowd.Log;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.LocationCodes;
import com.threerings.crowd.data.PlaceConfig;
@@ -50,19 +49,7 @@ import com.threerings.crowd.util.CrowdContext;
public class LocationDirector extends BasicDirector
implements Subscriber, LocationReceiver
{
/**
* Used to recover from a moveTo request that was accepted but
* resulted in a failed attempt to fetch the place object to which we
* were moving.
*/
// public static interface FailureHandler
// {
// /**
// * Should instruct the client to move to the last known working
// * location (as well as clean up after the failed moveTo request).
// */
// public void recoverFailedMove (int placeId);
// }
private static const log :Log = Log.getLog(LocationDirector);
/**
* Constructs a location director which will configure itself for
@@ -128,7 +115,7 @@ public class LocationDirector extends BasicDirector
{
// make sure the placeId is valid
if (placeId < 0) {
Log.warning("Refusing moveTo(): invalid placeId " + placeId + ".");
log.warning("Refusing moveTo(): invalid placeId " + placeId + ".");
return false;
}
@@ -149,13 +136,13 @@ public class LocationDirector extends BasicDirector
// minute, go ahead and let this new one through in an attempt
// to recover from dropped moveTo requests
if (refuse) {
Log.warning("Refusing moveTo; We have a request outstanding " +
log.warning("Refusing moveTo; We have a request outstanding " +
"[ppid=" + _pendingPlaceId +
", npid=" + placeId + "].");
return false;
} else {
Log.warning("Overriding stale moveTo request " +
log.warning("Overriding stale moveTo request " +
"[ppid=" + _pendingPlaceId +
", npid=" + placeId + "].");
}
@@ -179,7 +166,7 @@ public class LocationDirector extends BasicDirector
var placeId :int = _pendingPlaceId;
_pendingPlaceId = -1;
Log.info("moveTo failed [pid=" + placeId +
log.info("moveTo failed [pid=" + placeId +
", reason=" + reason + "].");
// let our observers know that something has gone horribly awry
@@ -187,7 +174,7 @@ public class LocationDirector extends BasicDirector
};
// issue a moveTo request
Log.info("Issuing moveTo(" + placeId + ").");
log.info("Issuing moveTo(" + placeId + ").");
_lservice.moveTo(_cctx.getClient(), placeId,
new MoveAdapter(success, failure));
return true;
@@ -276,9 +263,9 @@ public class LocationDirector extends BasicDirector
try {
_controller.mayLeavePlace(_plobj);
} catch (e :Error) {
Log.warning("Place controller choked in " +
log.warning("Place controller choked in " +
"mayLeavePlace [plobj=" + _plobj + "].");
Log.logStackTrace(e);
log.logStackTrace(e);
}
}
}
@@ -315,7 +302,7 @@ public class LocationDirector extends BasicDirector
// check whether we should use a custom class loader
_controller = config.createController();
if (_controller == null) {
Log.warning("Place config returned null controller " +
log.warning("Place config returned null controller " +
"[config=" + config + "].");
return;
}
@@ -339,9 +326,9 @@ public class LocationDirector extends BasicDirector
try {
_controller.didLeavePlace(_plobj);
} catch (e :Error) {
Log.warning("Place controller choked in " +
log.warning("Place controller choked in " +
"didLeavePlace [plobj=" + _plobj + "].");
Log.logStackTrace(e);
log.logStackTrace(e);
}
_controller = null;
}
@@ -405,7 +392,7 @@ public class LocationDirector extends BasicDirector
};
var failure :Function = function (
oid :int, cause :ObjectAccessError) :void {
Log.warning("Location director unable to fetch body " +
log.warning("Location director unable to fetch body " +
"object; all has gone horribly wrong" +
"[cause=" + cause + "].");
};
@@ -453,7 +440,7 @@ public class LocationDirector extends BasicDirector
// documentation inherited from interface
public function forcedMove (placeId :int) :void
{
Log.info("Moving at request of server [placeId=" + placeId + "].");
log.info("Moving at request of server [placeId=" + placeId + "].");
if (movePending()) {
// clear out our old place information
@@ -476,9 +463,9 @@ public class LocationDirector extends BasicDirector
try {
_controller.willEnterPlace(_plobj);
} catch (e :Error) {
Log.warning("Controller choked in willEnterPlace " +
log.warning("Controller choked in willEnterPlace " +
"[place=" + _plobj + "].");
Log.logStackTrace(e);
log.logStackTrace(e);
}
}
@@ -491,7 +478,7 @@ public class LocationDirector extends BasicDirector
{
// aiya! we were unable to fetch our new place object; something
// is badly wrong
Log.warning("Aiya! Unable to fetch place object for new location " +
log.warning("Aiya! Unable to fetch place object for new location " +
"[plid=" + oid + ", reason=" + cause + "].");
// clear out our half initialized place info
@@ -533,7 +520,7 @@ public class LocationDirector extends BasicDirector
// public void setFailureHandler (FailureHandler handler)
// {
// if (_failureHandler != null) {
// Log.warning("Requested to set failure handler, but we've " +
// log.warning("Requested to set failure handler, but we've " +
// "already got one. The conflicting entities will " +
// "likely need to perform more sophisticated " +
// "coordination to deal with failures. " +
@@ -0,0 +1,17 @@
package com.threerings.crowd.client {
/**
* Used to recover from a moveTo request that was accepted but
* resulted in a failed attempt to fetch the place object to which we
* were moving.
*/
public interface LocationDirector_FailureHandler
{
/**
* Should instruct the client to move to the last known working
* location (as well as clean up after the failed moveTo request).
*/
function recoverFailedMove (placeId :int) :void;
}
}
@@ -33,7 +33,6 @@ import com.threerings.presents.dobj.EntryRemovedEvent;
import com.threerings.presents.dobj.EntryUpdatedEvent;
import com.threerings.presents.dobj.SetListener;
import com.threerings.crowd.Log;
import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.util.CrowdContext;
@@ -23,7 +23,6 @@ package com.threerings.crowd.client {
import flash.display.DisplayObjectContainer;
import com.threerings.crowd.Log;
import com.threerings.crowd.data.PlaceObject;
/**
@@ -72,9 +71,10 @@ public class PlaceViewUtil
try {
(root as PlaceView)[funct](plobj);
} catch (e :Error) {
Log.warning("Component choked on " + funct + "() " +
var log :Log = Log.getLog(PlaceViewUtil);
log.warning("Component choked on " + funct + "() " +
"[component=" + root + ", plobj=" + plobj + "].");
Log.logStackTrace(e);
log.logStackTrace(e);
}
}
@@ -24,7 +24,6 @@ package com.threerings.crowd.data {
import com.threerings.util.Byte;
import com.threerings.util.Name;
//import com.threerings.presents.Log;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.data.InvocationCodes;
@@ -131,13 +130,9 @@ public class BodyObject extends ClientObject
{
super.readObject(ins);
Log.debug("Reading username");
username = (ins.readObject() as Name);
Log.debug("Reading location");
location = ins.readInt();
Log.debug("Reading status");
status = ins.readByte();
Log.debug("Reading awayMessage");
awayMessage = (ins.readField(String) as String);
}
@@ -32,7 +32,6 @@ import com.threerings.presents.dobj.DSet;
import com.threerings.presents.dobj.DSet_Entry;
import com.threerings.presents.dobj.OidList;
import com.threerings.crowd.Log;
import com.threerings.crowd.chat.data.SpeakMarshaller;
//import com.threerings.crowd.chat.data.SpeakObject;