From fadf226677318199974051fc7a230c8ff3bd3d9e Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Thu, 20 Jun 2002 22:12:23 +0000 Subject: [PATCH] Added convenient where() method to PlaceManager which is used when logging errors to report the "place" in which the error happen. The SceneManager overrides this to include scene information. Scrupulous use will make log messages much more scrutable. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1514 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/crowd/server/PlaceManager.java | 22 ++++++++++++++----- .../whirled/server/SceneManager.java | 8 ++++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/java/com/threerings/crowd/server/PlaceManager.java b/src/java/com/threerings/crowd/server/PlaceManager.java index 078d67f1d..ca17ff463 100644 --- a/src/java/com/threerings/crowd/server/PlaceManager.java +++ b/src/java/com/threerings/crowd/server/PlaceManager.java @@ -1,5 +1,5 @@ // -// $Id: PlaceManager.java,v 1.30 2002/05/24 05:58:55 mdb Exp $ +// $Id: PlaceManager.java,v 1.31 2002/06/20 22:12:22 mdb Exp $ package com.threerings.crowd.server; @@ -215,12 +215,24 @@ public class PlaceManager } catch (Exception e) { Log.warning("Failure building occupant info " + - "[body=" + body + "]."); + "[where=" + where() + ", body=" + body + "]."); Log.logStackTrace(e); return null; } } + /** + * Returns a string that can be used in log messages to identify the + * place as sensibly as possible to the developer who has to puzzle + * over log output trying to figure out what's going on. Derived place + * managers can override this and augment the default value (which is + * simply the place object id) with useful identifying information. + */ + protected String where () + { + return String.valueOf(_plobj.getOid()); + } + /** * Derived classes should override this method if they are making use * of a derived occupant info class. They should call the super @@ -239,8 +251,7 @@ public class PlaceManager */ protected void bodyEntered (final int bodyOid) { - Log.debug("Body entered [ploid=" + _plobj.getOid() + - ", oid=" + bodyOid + "]."); + Log.debug("Body entered [where=" + where() + ", oid=" + bodyOid + "]."); // let our delegates know what's up applyToDelegates(new DelegateOp() { @@ -255,8 +266,7 @@ public class PlaceManager */ protected void bodyLeft (final int bodyOid) { - Log.debug("Body left [ploid=" + _plobj.getOid() + - ", 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), diff --git a/src/java/com/threerings/whirled/server/SceneManager.java b/src/java/com/threerings/whirled/server/SceneManager.java index 8acc6215c..bc66c5cc2 100644 --- a/src/java/com/threerings/whirled/server/SceneManager.java +++ b/src/java/com/threerings/whirled/server/SceneManager.java @@ -1,5 +1,5 @@ // -// $Id: SceneManager.java,v 1.9 2001/12/14 01:51:46 mdb Exp $ +// $Id: SceneManager.java,v 1.10 2002/06/20 22:12:23 mdb Exp $ package com.threerings.whirled.server; @@ -85,6 +85,12 @@ public class SceneManager extends PlaceManager _screg.unmapSceneManager(this); } + // documentation inherited + protected String where () + { + return _scene.getName() + " (" + super.where() + ")"; + } + // documentation inherited protected void toString (StringBuffer buf) {