Switch to new samskivert logging API.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5134 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2008-05-27 19:25:38 +00:00
parent 821760366f
commit 919112cf88
80 changed files with 440 additions and 573 deletions
+2 -28
View File
@@ -21,8 +21,7 @@
package com.threerings.crowd;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.samskivert.util.Logger;
/**
* Contains a reference to the log object used by the Crowd services.
@@ -30,30 +29,5 @@ import java.util.logging.Logger;
public class Log
{
/** We dispatch our log messages through this logger. */
public static Logger log =
Logger.getLogger("com.threerings.narya.crowd");
/** Convenience function. */
public static void debug (String message)
{
log.fine(message);
}
/** Convenience function. */
public static void info (String message)
{
log.info(message);
}
/** Convenience function. */
public static void warning (String message)
{
log.warning(message);
}
/** Convenience function. */
public static void logStackTrace (Throwable t)
{
log.log(Level.WARNING, t.getMessage(), t);
}
public static Logger log = Logger.getLogger("com.threerings.crowd");
}
@@ -49,7 +49,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.CrowdCodes;
@@ -63,6 +62,8 @@ import com.threerings.crowd.chat.data.TellFeedbackMessage;
import com.threerings.crowd.chat.data.UserMessage;
import com.threerings.crowd.chat.data.UserSystemMessage;
import static com.threerings.crowd.Log.log;
/**
* The chat director is the client side coordinator of all chat related services. It handles both
* place constrained chat as well as direct messaging.
@@ -148,7 +149,7 @@ public class ChatDirector extends BasicDirector
// register our default chat handlers
if (_bundle == null || _msgmgr == null) {
Log.warning("Null bundle or message manager given to ChatDirector");
log.warning("Null bundle or message manager given to ChatDirector");
return;
}
registerCommandHandlers();
@@ -1001,7 +1002,7 @@ public class ChatDirector extends BasicDirector
if (bundle != null && _msgmgr != null) {
MessageBundle msgb = _msgmgr.getBundle(bundle);
if (msgb == null) {
Log.warning("No message bundle available to translate message " +
log.warning("No message bundle available to translate message " +
"[bundle=" + bundle + ", message=" + message + "].");
} else {
message = msgb.xlate(message);
@@ -30,7 +30,7 @@ import com.samskivert.util.StringUtil;
import com.threerings.util.Name;
import com.threerings.crowd.Log;
import static com.threerings.crowd.Log.log;
/**
* A chat filter that can filter out curse words from user chat.
@@ -150,7 +150,7 @@ public abstract class CurseFilter implements ChatFilter
String mapping = st.nextToken();
StringTokenizer st2 = new StringTokenizer(mapping, "=");
if (st2.countTokens() != 2) {
Log.warning("Something looks wrong in the x.cursewords " +
log.warning("Something looks wrong in the x.cursewords " +
"properties (" + mapping + "), skipping.");
continue;
}
@@ -27,10 +27,11 @@ import com.threerings.presents.data.ClientObject;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.server.InvocationManager;
import com.threerings.crowd.Log;
import com.threerings.crowd.chat.data.ChatCodes;
import com.threerings.crowd.data.BodyObject;
import static com.threerings.crowd.Log.log;
/**
* Wires up the {@link SpeakService} to a particular distributed object. A server entity can make
* "speech" available among the subscribers of a particular distributed object by constructing a
@@ -86,7 +87,7 @@ public class SpeakHandler
// ensure that the speaker is valid
if ((mode == ChatCodes.BROADCAST_MODE) ||
(_validator != null && !_validator.isValidSpeaker(_speakObj, caller, mode))) {
Log.warning("Refusing invalid speak request [caller=" + caller.who() +
log.warning("Refusing invalid speak request [caller=" + caller.who() +
", speakObj=" + _speakObj.which() +
", message=" + message + ", mode=" + mode + "].");
@@ -31,7 +31,6 @@ import com.threerings.presents.data.ClientObject;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.server.InvocationProvider;
import com.threerings.crowd.Log;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.server.CrowdServer;
@@ -42,6 +41,8 @@ import com.threerings.crowd.chat.data.SpeakObject;
import com.threerings.crowd.chat.data.SystemMessage;
import com.threerings.crowd.chat.data.UserMessage;
import static com.threerings.crowd.Log.log;
/**
* Provides the back-end of the chat speaking facilities.
*/
@@ -174,7 +175,7 @@ public class SpeakUtil
public static void sendMessage (DObject speakObj, ChatMessage msg)
{
if (speakObj == null) {
Log.warning("Dropping speak message, no speak obj '" + msg + "'.");
log.warning("Dropping speak message, no speak obj '" + msg + "'.");
Thread.dumpStack();
return;
}
@@ -192,7 +193,7 @@ public class SpeakUtil
_messageMapper.message = null;
} else {
Log.info("Unable to note listeners [dclass=" + speakObj.getClass() +
log.info("Unable to note listeners [dclass=" + speakObj.getClass() +
", msg=" + msg + "].");
}
}
@@ -21,8 +21,6 @@
package com.threerings.crowd.client;
import java.util.logging.Level;
import com.samskivert.util.ObserverList;
import com.samskivert.util.ObserverList.ObserverOp;
import com.samskivert.util.ResultListener;
@@ -262,7 +260,7 @@ public class LocationDirector extends BasicDirector
try {
_controller.mayLeavePlace(_plobj);
} catch (Exception e) {
log.log(Level.WARNING, "Place controller choked in mayLeavePlace " +
log.warning("Place controller choked in mayLeavePlace " +
"[plobj=" + _plobj + "].", e);
}
}
@@ -324,7 +322,7 @@ public class LocationDirector extends BasicDirector
_subber.subscribe(_ctx.getDObjectManager());
} catch (Exception e) {
log.log(Level.WARNING, "Failed to create place controller [config=" + config + "].", e);
log.warning("Failed to create place controller [config=" + config + "].", e);
handleFailure(_placeId, LocationCodes.E_INTERNAL_ERROR);
}
}
@@ -347,7 +345,7 @@ public class LocationDirector extends BasicDirector
try {
_controller.didLeavePlace(_plobj);
} catch (Exception e) {
log.log(Level.WARNING, "Place controller choked in didLeavePlace " +
log.warning("Place controller choked in didLeavePlace " +
"[plobj=" + _plobj + "].", e);
}
}
@@ -461,7 +459,7 @@ public class LocationDirector extends BasicDirector
try {
_controller.willEnterPlace(_plobj);
} catch (Exception e) {
log.log(Level.WARNING, "Controller choked in willEnterPlace " +
log.warning("Controller choked in willEnterPlace " +
"[place=" + _plobj + "].", e);
}
}
@@ -33,11 +33,12 @@ 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;
import static com.threerings.crowd.Log.log;
/**
* The occupant director listens for occupants of places to enter and
* exit, and dispatches notices to interested parties about these events.
@@ -23,9 +23,10 @@ package com.threerings.crowd.client;
import java.awt.Container;
import com.threerings.crowd.Log;
import com.threerings.crowd.data.PlaceObject;
import static com.threerings.crowd.Log.log;
/**
* Provides a mechanism for dispatching notifications to all user
* interface elements in a hierarchy that implement the {@link PlaceView}
@@ -51,9 +52,8 @@ public class PlaceViewUtil
try {
((PlaceView)root).willEnterPlace(plobj);
} catch (Exception e) {
Log.warning("Component choked on willEnterPlace() " +
"[component=" + root + ", plobj=" + plobj + "].");
Log.logStackTrace(e);
log.warning("Component choked on willEnterPlace() " +
"[component=" + root + ", plobj=" + plobj + "].", e);
}
}
@@ -84,9 +84,8 @@ public class PlaceViewUtil
try {
((PlaceView)root).didLeavePlace(plobj);
} catch (Exception e) {
Log.warning("Component choked on didLeavePlace() " +
"[component=" + root + ", plobj=" + plobj + "].");
Log.logStackTrace(e);
log.warning("Component choked on didLeavePlace() " +
"[component=" + root + ", plobj=" + plobj + "].", e);
}
}
@@ -26,9 +26,10 @@ import com.samskivert.util.StringUtil;
import com.threerings.io.SimpleStreamableObject;
import com.threerings.util.ActionScript;
import com.threerings.crowd.Log;
import com.threerings.crowd.client.PlaceController;
import static com.threerings.crowd.Log.log;
/**
* The place config class encapsulates the configuration information for a
* particular type of place. The hierarchy of place config objects mimics
@@ -67,14 +68,12 @@ public abstract class PlaceConfig extends SimpleStreamableObject
"PlaceConfig.createController() must be overridden.");
}
Log.warning("Providing backwards compatibility. PlaceConfig." +
log.warning("Providing backwards compatibility. PlaceConfig." +
"createController() should be overridden directly.");
try {
return (PlaceController)cclass.newInstance();
} catch (Exception e) {
Log.warning("Failed to instantiate controller class '" +
cclass + "'.");
Log.logStackTrace(e);
log.warning("Failed to instantiate controller class '" + cclass + "'.", e);
return null;
}
}
@@ -31,10 +31,11 @@ import com.threerings.presents.dobj.DSet;
import com.threerings.presents.dobj.OidList;
import com.threerings.presents.dobj.ServerMessageEvent;
import com.threerings.crowd.Log;
import com.threerings.crowd.chat.data.SpeakMarshaller;
import com.threerings.crowd.chat.data.SpeakObject;
import static com.threerings.crowd.Log.log;
/**
* A distributed object that contains information on a place that is occupied by bodies. This place
* might be a chat room, a game room, an island in a massively multiplayer piratical universe,
@@ -131,8 +132,7 @@ public class PlaceObject extends DObject
}
}
} catch (Throwable t) {
Log.warning("PlaceObject.getOccupantInfo choked.");
Log.logStackTrace(t);
log.warning("PlaceObject.getOccupantInfo choked.", t);
}
return null;
}
@@ -26,12 +26,13 @@ import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.server.InvocationProvider;
import com.threerings.crowd.Log;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.CrowdCodes;
import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.data.Place;
import static com.threerings.crowd.Log.log;
/**
* Provides the server-side side of the body-related invocation services.
*/
@@ -76,7 +77,7 @@ public class BodyProvider
}
// update their status!
Log.debug("Setting user idle state [user=" + bobj.username + ", status=" + nstatus + "].");
log.debug("Setting user idle state [user=" + bobj.username + ", status=" + nstatus + "].");
updateOccupantStatus(bobj, bobj.location, nstatus);
}
@@ -33,10 +33,11 @@ import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.server.PresentsClient;
import com.threerings.presents.server.PresentsServer;
import com.threerings.crowd.Log;
import com.threerings.crowd.chat.server.ChatProvider;
import com.threerings.crowd.data.BodyObject;
import static com.threerings.crowd.Log.log;
/**
* The crowd server extends the presents server by configuring it to use the
* extensions provided by the crowd layer to support crowd services.
@@ -143,8 +144,7 @@ public class CrowdServer extends PresentsServer
server.init();
server.run();
} catch (Exception e) {
Log.warning("Unable to initialize server.");
Log.logStackTrace(e);
log.warning("Unable to initialize server.", e);
}
}
@@ -30,7 +30,6 @@ import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.server.InvocationProvider;
import com.threerings.presents.server.PresentsClient;
import com.threerings.crowd.Log;
import com.threerings.crowd.client.LocationService;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.LocationCodes;
@@ -39,6 +38,8 @@ import com.threerings.crowd.data.PlaceConfig;
import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.server.CrowdServer;
import static com.threerings.crowd.Log.log;
/**
* This class provides the server end of the location services.
*/
@@ -96,7 +97,7 @@ public class LocationProvider
// make sure the place in question actually exists
PlaceManager pmgr = _plreg.getPlaceManager(placeOid);
if (pmgr == null) {
Log.info("Requested to move to non-existent place [who=" + source.who() +
log.info("Requested to move to non-existent place [who=" + source.who() +
", placeOid=" + placeOid + "].");
throw new InvocationException(NO_SUCH_PLACE);
}
@@ -105,7 +106,7 @@ public class LocationProvider
// because we don't need to update anything in distributed object world
Place place = pmgr.getLocation();
if (place.equals(source.location)) {
Log.debug("Going along with client request to move to where they already are " +
log.debug("Going along with client request to move to where they already are " +
"[source=" + source.who() + ", place=" + place + "].");
return pmgr.getConfig();
}
@@ -196,12 +197,12 @@ public class LocationProvider
}
} else {
Log.info("Body's prior location no longer around? [boid=" + bodoid +
log.info("Body's prior location no longer around? [boid=" + bodoid +
", place=" + oldloc + "].");
}
} catch (ClassCastException cce) {
Log.warning("Body claims to occupy non-PlaceObject!? [boid=" + bodoid +
log.warning("Body claims to occupy non-PlaceObject!? [boid=" + bodoid +
", place=" + oldloc + ", error=" + cce + "].");
}
@@ -24,7 +24,6 @@ package com.threerings.crowd.server;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@@ -51,7 +50,6 @@ import com.threerings.presents.dobj.SetAdapter;
import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.server.PresentsDObjectMgr;
import com.threerings.crowd.Log;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.data.Place;
@@ -62,6 +60,8 @@ import com.threerings.crowd.chat.data.SpeakMarshaller;
import com.threerings.crowd.chat.server.SpeakDispatcher;
import com.threerings.crowd.chat.server.SpeakHandler;
import static com.threerings.crowd.Log.log;
/**
* The place manager is the server-side entity that handles all place-related interaction. It
* subscribes to the place object and reacts to message and other events. Behavior specific to a
@@ -309,9 +309,8 @@ public class PlaceManager
return info;
} catch (Exception e) {
Log.warning("Failure building occupant info [where=" + where() +
", body=" + body + "].");
Log.logStackTrace(e);
log.warning("Failure building occupant info [where=" + where() +
", body=" + body + "].", e);
return null;
}
}
@@ -546,9 +545,7 @@ public class PlaceManager
*/
protected void bodyEntered (final int bodyOid)
{
if (Log.log.getLevel() == Level.FINE) {
Log.debug("Body entered [where=" + where() + ", oid=" + bodyOid + "].");
}
log.debug("Body entered", "where", where(), "oid", bodyOid);
// let our delegates know what's up
applyToDelegates(new DelegateOp() {
@@ -566,9 +563,7 @@ public class PlaceManager
*/
protected void bodyLeft (final int bodyOid)
{
if (Log.log.getLevel() == Level.FINE) {
Log.debug("Body left [where=" + where() + ", oid=" + bodyOid + "].");
}
log.debug("Body left", "where", where(), "oid", bodyOid);
// if their occupant info hasn't been removed (which may be the case if they logged off
// rather than left via a MoveTo request), we need to get it on out of here
@@ -643,7 +638,7 @@ public class PlaceManager
if (idlePeriod > 0L && _shutdownInterval == null) {
_shutdownInterval = new Interval((PresentsDObjectMgr)_omgr) {
public void expired () {
Log.debug("Unloading idle place '" + where () + "'.");
log.debug("Unloading idle place '" + where () + "'.");
shutdown();
}
};
@@ -30,12 +30,13 @@ import com.threerings.presents.dobj.RootDObjectManager;
import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.InvocationManager;
import com.threerings.crowd.Log;
import com.threerings.crowd.data.CrowdCodes;
import com.threerings.crowd.data.Place;
import com.threerings.crowd.data.PlaceConfig;
import com.threerings.crowd.data.PlaceObject;
import static com.threerings.crowd.Log.log;
/**
* The place registry keeps track of all of the active places in the server. It should be used to
* create new places and it will take care of instantiating and initializing a place manager to
@@ -197,9 +198,8 @@ public class PlaceRegistry
pmgr.init(this, _invmgr, _omgr, config);
} catch (Exception e) {
Log.logStackTrace(e);
throw new InstantiationException(
"Error creating place manager [config=" + config + "].");
log.warning(e);
throw new InstantiationException("Error creating PlaceManager for " + config);
}
// give the manager an opportunity to abort the whole process if it fails any permissions
@@ -226,8 +226,7 @@ public class PlaceRegistry
pmgr.startup(plobj);
} catch (Exception e) {
Log.warning("Error starting place manager [obj=" + plobj + ", pmgr=" + pmgr + "].");
Log.logStackTrace(e);
log.warning("Error starting place manager [obj=" + plobj + ", pmgr=" + pmgr + "].", e);
}
return pmgr;
@@ -241,7 +240,7 @@ public class PlaceRegistry
int ploid = pmgr.getPlaceObject().getOid();
// remove it from the table
if (_pmgrs.remove(ploid) == null) {
Log.warning("Requested to unmap unmapped place manager [pmgr=" + pmgr + "].");
log.warning("Requested to unmap unmapped place manager [pmgr=" + pmgr + "].");
// } else {
// Log.info("Unmapped place manager [class=" + pmgr.getClass().getName() +