Deverbosified logging.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5403 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2008-09-30 21:30:48 +00:00
parent 6851fc1b28
commit 2bffe8569b
2 changed files with 35 additions and 37 deletions
@@ -66,6 +66,15 @@ public class AgentObject extends DObject
* bureau and run). */ * bureau and run). */
public int clientOid; public int clientOid;
/**
* Returns a brief string that identifies this agent. Use this instead of {@link #toString}
* when you wish to report an agent object in a log message.
*/
public String which ()
{
return "[bid=" + bureauId + ", type=" + bureauType + "]";
}
// AUTO-GENERATED: METHODS START // AUTO-GENERATED: METHODS START
/** /**
* Requests that the <code>bureauId</code> field be set to the * Requests that the <code>bureauId</code> field be set to the
@@ -252,7 +252,7 @@ public class BureauRegistry
_omgr.registerObject(agent); _omgr.registerObject(agent);
log.info("Bureau ready, sending createAgent", "agent", agent); log.info("Bureau ready, sending createAgent", "agent", agent.which());
BureauSender.createAgent(bureau.clientObj, agent.getOid()); BureauSender.createAgent(bureau.clientObj, agent.getOid());
bureau.agentStates.put(agent, AgentState.STARTED); bureau.agentStates.put(agent, AgentState.STARTED);
@@ -266,7 +266,7 @@ public class BureauRegistry
LauncherEntry launcherEntry = _launchers.get(agent.bureauType); LauncherEntry launcherEntry = _launchers.get(agent.bureauType);
if (launcherEntry == null) { if (launcherEntry == null) {
log.warning("Launcher not found", "agent", agent); log.warning("Launcher not found", "agent", agent.which());
return; return;
} }
@@ -285,7 +285,7 @@ public class BureauRegistry
_omgr.registerObject(agent); _omgr.registerObject(agent);
bureau.agentStates.put(agent, AgentState.PENDING); bureau.agentStates.put(agent, AgentState.PENDING);
log.info("Bureau not ready, pending agent", "agent", agent); log.info("Bureau not ready, pending agent", "agent", agent.which());
bureau.summarize(); bureau.summarize();
} }
@@ -301,7 +301,7 @@ public class BureauRegistry
return; return;
} }
log.info("Destroying agent", "agent", agent); log.info("Destroying agent", "agent", agent.which());
// transition the agent to a new state and perform the effect of the transition // transition the agent to a new state and perform the effect of the transition
if (found.state == AgentState.PENDING) { if (found.state == AgentState.PENDING) {
@@ -318,9 +318,8 @@ public class BureauRegistry
} else if (found.state == AgentState.DESTROYED || } else if (found.state == AgentState.DESTROYED ||
found.state == AgentState.STILL_BORN) { found.state == AgentState.STILL_BORN) {
log.warning( log.warning("Ignoring request to destroy agent in unexpected state",
"Ignoring request to destroy agent in unexpected state", "state", found.state, "state", found.state, "agent", found.agent.which());
"agent", found.agent);
} }
found.bureau.summarize(); found.bureau.summarize();
@@ -346,9 +345,8 @@ public class BureauRegistry
return; return;
} }
if (bureau.client != null) { if (bureau.client != null) {
log.warning( log.warning("Multiple sessions for the same bureau", "id", id, "client", client,
"Multiple sessions for the same bureau", "id", id, "client", client, "bureau", "bureau", bureau);
bureau);
} }
bureau.client = client; bureau.client = client;
} }
@@ -361,9 +359,8 @@ public class BureauRegistry
return; return;
} }
if (bureau.client == null) { if (bureau.client == null) {
log.warning( log.warning("Multiple logouts from the same bureau", "id", id, "client", client,
"Multiple logouts from the same bureau", "id", id, "client", client, "bureau", "bureau", bureau);
bureau);
} }
bureau.client = null; bureau.client = null;
@@ -399,7 +396,7 @@ public class BureauRegistry
// create them // create them
for (AgentObject agent : pending) { for (AgentObject agent : pending) {
log.info("Creating agent", "agent", agent); log.info("Creating agent", "agent", agent.which());
BureauSender.createAgent(bureau.clientObj, agent.getOid()); BureauSender.createAgent(bureau.clientObj, agent.getOid());
bureau.agentStates.put(agent, AgentState.STARTED); bureau.agentStates.put(agent, AgentState.STARTED);
} }
@@ -417,7 +414,7 @@ public class BureauRegistry
return; return;
} }
log.info("Agent creation confirmed", "agent", found.agent); log.info("Agent creation confirmed", "agent", found.agent.which());
if (found.state == AgentState.STARTED) { if (found.state == AgentState.STARTED) {
found.bureau.agentStates.put(found.agent, AgentState.RUNNING); found.bureau.agentStates.put(found.agent, AgentState.RUNNING);
@@ -430,9 +427,8 @@ public class BureauRegistry
} else if (found.state == AgentState.PENDING || } else if (found.state == AgentState.PENDING ||
found.state == AgentState.RUNNING || found.state == AgentState.RUNNING ||
found.state == AgentState.DESTROYED) { found.state == AgentState.DESTROYED) {
log.warning( log.warning("Ignoring confirmation of creation of an agent in an unexpected state",
"Ignoring confirmation of creation of an agent in an unexpected state", "state", "state", found.state, "agent", found.agent.which());
found.state, "agent", found.agent);
} }
found.bureau.summarize(); found.bureau.summarize();
@@ -448,7 +444,7 @@ public class BureauRegistry
return; return;
} }
log.info("Agent creation failed", "agent", found.agent); log.info("Agent creation failed", "agent", found.agent.which());
if (found.state == AgentState.STARTED || if (found.state == AgentState.STARTED ||
found.state == AgentState.STILL_BORN) { found.state == AgentState.STILL_BORN) {
@@ -457,9 +453,8 @@ public class BureauRegistry
} else if (found.state == AgentState.PENDING || } else if (found.state == AgentState.PENDING ||
found.state == AgentState.RUNNING || found.state == AgentState.RUNNING ||
found.state == AgentState.DESTROYED) { found.state == AgentState.DESTROYED) {
log.warning( log.warning("Ignoring failure of creation of an agent in an unexpected state",
"Ignoring failure of creation of an agent in an unexpected state", "state", "state", found.state, "agent", found.agent.which());
found.state, "agent", found.agent);
} }
found.bureau.summarize(); found.bureau.summarize();
@@ -475,7 +470,7 @@ public class BureauRegistry
return; return;
} }
log.info("Agent destruction confirmed", "agent", found.agent); log.info("Agent destruction confirmed", "agent", found.agent.which());
if (found.state == AgentState.DESTROYED) { if (found.state == AgentState.DESTROYED) {
found.bureau.agentStates.remove(found.agent); found.bureau.agentStates.remove(found.agent);
@@ -484,9 +479,8 @@ public class BureauRegistry
found.state == AgentState.STARTED || found.state == AgentState.STARTED ||
found.state == AgentState.RUNNING || found.state == AgentState.RUNNING ||
found.state == AgentState.STILL_BORN) { found.state == AgentState.STILL_BORN) {
log.warning( log.warning("Ignoring confirmation of destruction of agent in unexpected state",
"Ignoring confirmation of destruction of agent in unexpected state", "state", "state", found.state, "agent", found.agent.which());
found.state, "agent", found.agent);
} }
found.bureau.summarize(); found.bureau.summarize();
@@ -522,26 +516,25 @@ public class BureauRegistry
} }
if (!(dobj instanceof AgentObject)) { if (!(dobj instanceof AgentObject)) {
log.warning("Object not an agent", "function", resolver, "obj", dobj); log.warning("Object not an agent", "function", resolver, "obj", dobj.getClass());
return null; return null;
} }
AgentObject agent = (AgentObject)dobj; AgentObject agent = (AgentObject)dobj;
Bureau bureau = _bureaus.get(agent.bureauId); Bureau bureau = _bureaus.get(agent.bureauId);
if (bureau == null) { if (bureau == null) {
log.warning("Bureau not found for agent", "function", resolver, "agent", agent); log.warning("Bureau not found for agent", "function", resolver, "agent", agent.which());
return null; return null;
} }
if (!bureau.agentStates.containsKey(agent)) { if (!bureau.agentStates.containsKey(agent)) {
log.warning("Bureau does not have agent", "function", resolver, "agent", agent); log.warning("Bureau does not have agent", "function", resolver, "agent", agent.which());
return null; return null;
} }
if (client != null && bureau.clientObj != client) { if (client != null && bureau.clientObj != client) {
log.warning( log.warning("Masquerading request", "function", resolver, "agent", agent.which(),
"Masquerading request", "function", resolver, "agent", agent, "client", "client", bureau.clientObj, "client", client);
bureau.clientObj, "client", client);
return null; return null;
} }
@@ -660,11 +653,7 @@ public class BureauRegistry
/** Models the results of searching for an agent. */ /** Models the results of searching for an agent. */
protected static class FoundAgent protected static class FoundAgent
{ {
FoundAgent ( FoundAgent (Bureau bureau, AgentObject agent, AgentState state) {
Bureau bureau,
AgentObject agent,
AgentState state)
{
this.bureau = bureau; this.bureau = bureau;
this.agent = agent; this.agent = agent;
this.state = state; this.state = state;