Switch to new logging API.

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@608 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2008-05-27 20:00:28 +00:00
parent 3b7ef57a20
commit a133c7c693
91 changed files with 486 additions and 722 deletions
+2 -28
View File
@@ -21,8 +21,7 @@
package com.threerings.parlor;
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 Parlor 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.vilya.parlor");
/** 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.parlor");
}
+4 -28
View File
@@ -21,36 +21,12 @@
package com.threerings.parlor.card;
import com.samskivert.util.Logger;
/**
* A placeholder class that contains a reference to the log object used by
* the Card services.
* Contains a reference to the log object used by the Card services.
*/
public class Log
{
public static com.samskivert.util.Log log =
new com.samskivert.util.Log("card");
/** Convenience function. */
public static void debug (String message)
{
log.debug(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.logStackTrace(com.samskivert.util.Log.WARNING, t);
}
public static Logger log = Logger.getLogger("com.threerings.parlor.card");
}
@@ -25,13 +25,14 @@ import com.threerings.util.Name;
import com.threerings.crowd.data.PlaceObject;
import com.threerings.parlor.card.Log;
import com.threerings.parlor.card.data.Card;
import com.threerings.parlor.card.data.CardCodes;
import com.threerings.parlor.card.data.Hand;
import com.threerings.parlor.game.client.GameController;
import com.threerings.parlor.turn.client.TurnGameController;
import static com.threerings.parlor.card.Log.log;
/**
* A controller class for card games. Handles common functions like
* accepting dealt hands.
@@ -44,7 +45,7 @@ public abstract class CardGameController extends GameController
{
if (_ctx.getClient().getClientObject().receivers.containsKey(
CardGameDecoder.RECEIVER_CODE)) {
Log.warning("Yuh oh, we already have a card game receiver " +
log.warning("Yuh oh, we already have a card game receiver " +
"registered and are trying for another...!");
Thread.dumpStack();
}
@@ -47,12 +47,13 @@ import com.threerings.media.util.Path;
import com.threerings.media.util.PathSequence;
import com.threerings.media.util.Pathable;
import com.threerings.parlor.card.Log;
import com.threerings.parlor.card.data.Card;
import com.threerings.parlor.card.data.CardCodes;
import com.threerings.parlor.card.data.Deck;
import com.threerings.parlor.card.data.Hand;
import static com.threerings.parlor.card.Log.log;
/**
* Extends VirtualMediaPanel to provide services specific to rendering and manipulating playing
* cards.
@@ -25,8 +25,6 @@ import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.server.OccupantOp;
import com.threerings.parlor.card.Log;
import com.threerings.parlor.card.data.Card;
import com.threerings.parlor.card.data.CardCodes;
import com.threerings.parlor.card.data.CardGameObject;
@@ -42,6 +40,8 @@ import com.threerings.presents.dobj.MessageEvent;
import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.PresentsServer;
import static com.threerings.parlor.card.Log.log;
/**
* A manager class for card games. Handles common functions like dealing
* hands of cards to all players.
@@ -41,7 +41,6 @@ import com.threerings.crowd.server.PlaceManager;
import com.threerings.parlor.turn.server.TurnGameManagerDelegate;
import com.threerings.parlor.card.Log;
import com.threerings.parlor.card.data.Card;
import com.threerings.parlor.card.data.CardGameObject;
import com.threerings.parlor.card.data.Deck;
@@ -51,6 +50,8 @@ import com.threerings.parlor.card.server.CardGameManager;
import com.threerings.parlor.card.trick.data.TrickCardGameMarshaller;
import com.threerings.parlor.card.trick.data.TrickCardGameObject;
import static com.threerings.parlor.card.Log.log;
/**
* A card game manager delegate for trick-based card games, such as Spades and Hearts.
*/
@@ -216,14 +217,14 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
// make sure they're actually a player
int fromidx = _cgmgr.getPlayerIndex(client);
if (fromidx == -1) {
Log.warning("Send request from non-player [username=" +
log.warning("Send request from non-player [username=" +
((BodyObject)client).who() + ", cards=" + StringUtil.toString(cards) + "].");
return;
}
// make sure they have the cards
if (!_hands[fromidx].containsAll(cards)) {
Log.warning("Tried to send cards not held [username=" +
log.warning("Tried to send cards not held [username=" +
((BodyObject)client).who() + ", cards=" + StringUtil.toString(cards) + "].");
return;
}
@@ -254,14 +255,14 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
// make sure their hand contains the specified card
if (!_hands[pidx].contains(card)) {
Log.warning("Tried to play card not held [username=" + username +
log.warning("Tried to play card not held [username=" + username +
", card=" + card + "].");
return;
}
// make sure the card is legal to play
if (!_trickCardGame.isCardPlayable(_hands[pidx], card)) {
Log.warning("Tried to play illegal card [username=" + username +
log.warning("Tried to play illegal card [username=" + username +
", card=" + card + "].");
return;
}
@@ -274,7 +275,7 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
{
// make sure the game is over
if (_cardGame.state != CardGameObject.GAME_OVER) {
Log.warning("Tried to request rematch when game wasn't over " +
log.warning("Tried to request rematch when game wasn't over " +
"[username=" + ((BodyObject)client).who() + "].");
return;
}
@@ -282,14 +283,14 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
// make sure the requester is one of the players
int pidx = _cgmgr.getPlayerIndex(client);
if (pidx == -1) {
Log.warning("Rematch request from non-player [username=" +
log.warning("Rematch request from non-player [username=" +
((BodyObject)client).who() + "].");
return;
}
// make sure the player hasn't already requested
if (_trickCardGame.getRematchRequests()[pidx] != TrickCardGameObject.NO_REQUEST) {
Log.warning("Repeated rematch request [username=" + ((BodyObject)client).who() + "].");
log.warning("Repeated rematch request [username=" + ((BodyObject)client).who() + "].");
return;
}
@@ -23,11 +23,12 @@ package com.threerings.parlor.client;
import com.threerings.util.Name;
import com.threerings.parlor.Log;
import com.threerings.parlor.data.ParlorCodes;
import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.util.ParlorContext;
import static com.threerings.parlor.Log.log;
/**
* The invitation class is used to track information related to
* outstanding invitations generated by or targeted to this client.
@@ -151,7 +152,7 @@ public class Invitation
{
// make sure we have an observer to notify
if (_observer == null) {
Log.warning("No observer registered for invitation " +
log.warning("No observer registered for invitation " +
this + ".");
return;
}
@@ -173,10 +174,9 @@ public class Invitation
}
} catch (Exception e) {
Log.warning("Invitation response observer choked on response " +
log.warning("Invitation response observer choked on response " +
"[code=" + code + ", arg=" + arg +
", invite=" + this + "].");
Log.logStackTrace(e);
", invite=" + this + "].", e);
}
// unless the invitation was countered, we can remove it from the
@@ -30,11 +30,12 @@ import com.threerings.presents.client.BasicDirector;
import com.threerings.presents.client.Client;
import com.threerings.presents.client.InvocationService;
import com.threerings.parlor.Log;
import com.threerings.parlor.data.ParlorCodes;
import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.util.ParlorContext;
import static com.threerings.parlor.Log.log;
/**
* The parlor director manages the client side of the game configuration and matchmaking
* processes. It is also the entity that is listening for game start notifications which it then
@@ -132,7 +133,7 @@ public class ParlorDirector extends BasicDirector
// documentation inherited from interface
public void gameIsReady (int gameOid)
{
Log.info("Handling game ready [goid=" + gameOid + "].");
log.info("Handling game ready [goid=" + gameOid + "].");
// see what our observers have to say about it
boolean handled = false;
@@ -163,8 +164,7 @@ public class ParlorDirector extends BasicDirector
_handler.invitationReceived(invite);
} catch (Exception e) {
Log.warning("Invitation handler choked on invite notification " + invite + ".");
Log.logStackTrace(e);
log.warning("Invitation handler choked on invite notification " + invite + ".", e);
}
}
@@ -174,7 +174,7 @@ public class ParlorDirector extends BasicDirector
// look up the invitation record for this invitation
Invitation invite = (Invitation)_pendingInvites.get(remoteId);
if (invite == null) {
Log.warning("Have no record of invitation for which we received a response?! " +
log.warning("Have no record of invitation for which we received a response?! " +
"[remoteId=" + remoteId + ", code=" + code + ", arg=" + arg + "].");
} else {
@@ -35,13 +35,14 @@ import com.threerings.presents.dobj.SetListener;
import com.threerings.crowd.data.BodyObject;
import com.threerings.parlor.Log;
import com.threerings.parlor.data.Table;
import com.threerings.parlor.data.TableConfig;
import com.threerings.parlor.data.TableLobbyObject;
import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.util.ParlorContext;
import static com.threerings.parlor.Log.log;
/**
* As tables are created and managed within the scope of a place (a lobby), we want to fold the
* table management functionality into the standard hierarchy of place controllers that deal with
@@ -146,14 +147,14 @@ public class TableDirector extends BasicDirector
{
// if we're already in a table, refuse the request
if (_ourTable != null) {
Log.warning("Ignoring request to create table as we're already in a table " +
log.warning("Ignoring request to create table as we're already in a table " +
"[table=" + _ourTable + "].");
return;
}
// make sure we're currently in a place
if (_tlobj == null) {
Log.warning("Requested to create a table but we're not currently in a place " +
log.warning("Requested to create a table but we're not currently in a place " +
"[config=" + config + "].");
return;
}
@@ -170,14 +171,14 @@ public class TableDirector extends BasicDirector
{
// if we're already in a table, refuse the request
if (_ourTable != null) {
Log.warning("Ignoring request to join table as we're already in a table " +
log.warning("Ignoring request to join table as we're already in a table " +
"[table=" + _ourTable + "].");
return;
}
// make sure we're currently in a place
if (_tlobj == null) {
Log.warning("Requested to join a table but we're not currently in a place " +
log.warning("Requested to join a table but we're not currently in a place " +
"[tableId=" + tableId + "].");
return;
}
@@ -194,7 +195,7 @@ public class TableDirector extends BasicDirector
{
// make sure we're currently in a place
if (_tlobj == null) {
Log.warning("Requested to leave a table but we're not currently in a place " +
log.warning("Requested to leave a table but we're not currently in a place " +
"[tableId=" + tableId + "].");
return;
}
@@ -210,7 +211,7 @@ public class TableDirector extends BasicDirector
public void startTableNow (int tableId)
{
if (_tlobj == null) {
Log.warning("Requested to start a table but we're not currently in a place " +
log.warning("Requested to start a table but we're not currently in a place " +
"[tableId=" + tableId + "].");
return;
}
@@ -270,13 +271,13 @@ public class TableDirector extends BasicDirector
int tableId = (Integer)result;
if (_tlobj == null) {
// we've left, it's none of our concern anymore
Log.info("Table created, but no lobby. [tableId=" + tableId + "].");
log.info("Table created, but no lobby. [tableId=" + tableId + "].");
return;
}
Table table = (Table) _tlobj.getTables().get(tableId);
if (table == null) {
Log.warning("Table created, but where is it? [tableId=" + tableId + "]");
log.warning("Table created, but where is it? [tableId=" + tableId + "]");
return;
}
@@ -289,7 +290,7 @@ public class TableDirector extends BasicDirector
// from interface TableService.ResultListener
public void requestFailed (String reason)
{
Log.warning("Table action failed [reason=" + reason + "].");
log.warning("Table action failed [reason=" + reason + "].");
}
/**
@@ -33,12 +33,13 @@ import com.threerings.crowd.data.PlaceConfig;
import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.util.CrowdContext;
import com.threerings.parlor.Log;
import com.threerings.parlor.game.data.GameCodes;
import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.game.data.GameObject;
import com.threerings.parlor.util.ParlorContext;
import static com.threerings.parlor.Log.log;
/**
* The game controller manages the flow and control of a game on the client side. This class serves
* as the root of a hierarchy of controller classes that aim to provide functionality shared
@@ -94,7 +95,7 @@ public abstract class GameController extends PlaceController
// we don't want to claim to be finished until any derived classes that overrode this
// method have executed, so we'll queue up a runnable here that will let the game manager
// know that we're ready on the next pass through the distributed event loop
Log.info("Entering game " + _gobj.which() + ".");
log.info("Entering game " + _gobj.which() + ".");
if (_gobj.getPlayerIndex(bobj.getVisibleName()) != -1) {
_ctx.getClient().getRunQueue().postRunnable(new Runnable() {
public void run () {
@@ -193,7 +194,7 @@ public abstract class GameController extends PlaceController
if (event.getName().equals(GameObject.STATE)) {
int newState = event.getIntValue();
if (!stateDidChange(newState)) {
Log.warning("Game transitioned to unknown state [gobj=" + _gobj +
log.warning("Game transitioned to unknown state [gobj=" + _gobj +
", state=" + newState + "].");
}
}
@@ -228,7 +229,7 @@ public abstract class GameController extends PlaceController
*/
protected void playerReady ()
{
Log.info("Reporting ready " + _gobj.which() + ".");
log.info("Reporting ready " + _gobj.which() + ".");
_gobj.manager.invoke("playerReady");
}
@@ -239,7 +240,7 @@ public abstract class GameController extends PlaceController
protected void gameDidStart ()
{
if (_gobj == null) {
Log.info("Received gameDidStart() after leaving game room.");
log.info("Received gameDidStart() after leaving game room.");
return;
}
@@ -454,7 +454,7 @@ public class GameManager extends PlaceManager
boolean result = startGame();
// TEMP: track down weirdness
if (!result && !_postponedStart) {
log.log(Level.WARNING, "First call to startGame: ", firstCall);
log.warning("First call to startGame: ", firstCall);
}
// End: temp
}
@@ -1286,7 +1286,7 @@ public class GameManager extends PlaceManager
try {
gmgr.tick(now);
} catch (Exception e) {
log.log(Level.WARNING, "Game manager choked during tick [gmgr=" + gmgr + "].", e);
log.warning("Game manager choked during tick [gmgr=" + gmgr + "].", e);
}
}
}
@@ -32,12 +32,13 @@ import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.server.CrowdServer;
import com.threerings.crowd.server.PlaceRegistry;
import com.threerings.parlor.Log;
import com.threerings.parlor.client.ParlorService;
import com.threerings.parlor.data.ParlorCodes;
import com.threerings.parlor.data.TableConfig;
import com.threerings.parlor.game.data.GameConfig;
import static com.threerings.parlor.Log.log;
/**
* The parlor manager is responsible for the parlor services in aggregate. This includes
* maintaining the registry of active games, handling the necessary coordination for the
@@ -107,7 +108,7 @@ public class ParlorManager
{
BodyObject user = (BodyObject)caller;
Log.debug("Processing start solitaire [caller=" + user.who() + ", config=" + config + "].");
log.debug("Processing start solitaire [caller=" + user.who() + ", config=" + config + "].");
try {
// just this fellow will be playing
@@ -123,9 +124,8 @@ public class ParlorManager
listener.requestProcessed();
} catch (InstantiationException ie) {
Log.warning("Error instantiating game manager " +
"[for=" + caller.who() + ", config=" + config + "].");
Log.logStackTrace(ie);
log.warning("Error instantiating game manager " +
"[for=" + caller.who() + ", config=" + config + "].", ie);
throw new InvocationException(INTERNAL_ERROR);
}
}
@@ -183,7 +183,7 @@ public class ParlorManager
// look up the invitation
Invitation invite = (Invitation)_invites.get(inviteId);
if (invite == null) {
Log.warning("Requested to respond to non-existent invitation " +
log.warning("Requested to respond to non-existent invitation " +
"[source=" + source + ", inviteId=" + inviteId +
", code=" + code + ", arg=" + arg + "].");
return;
@@ -191,7 +191,7 @@ public class ParlorManager
// make sure this response came from the proper person
if (source != invite.invitee) {
Log.warning("Got response from non-invitee [source=" + source +
log.warning("Got response from non-invitee [source=" + source +
", invite=" + invite + ", code=" + code +
", arg=" + arg + "].");
return;
@@ -221,7 +221,7 @@ public class ParlorManager
break;
default:
Log.warning("Requested to respond to invitation with unknown response code " +
log.warning("Requested to respond to invitation with unknown response code " +
"[source=" + source + ", invite=" + invite + ", code=" + code +
", arg=" + arg + "].");
break;
@@ -245,7 +245,7 @@ public class ParlorManager
protected void processAcceptedInvitation (Invitation invite)
{
try {
Log.info("Creating game manager [invite=" + invite + "].");
log.info("Creating game manager [invite=" + invite + "].");
// configure the game config with the player info
invite.config.players = new Name[] { invite.invitee.getVisibleName(),
@@ -256,8 +256,7 @@ public class ParlorManager
createGameManager(invite.config);
} catch (Exception e) {
Log.warning("Unable to create game manager [invite=" + invite + ", error=" + e + "].");
Log.logStackTrace(e);
log.warning("Unable to create game manager [invite=" + invite + "].", e);
}
}
@@ -47,7 +47,6 @@ import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.server.CrowdServer;
import com.threerings.parlor.Log;
import com.threerings.parlor.client.TableService;
import com.threerings.parlor.data.ParlorCodes;
import com.threerings.parlor.data.Table;
@@ -58,6 +57,8 @@ import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.game.data.GameObject;
import com.threerings.parlor.game.server.GameManager;
import static com.threerings.parlor.Log.log;
/**
* A table manager can be used by a place manager (or other entity) to take care of the management
* of a table matchmaking service on a particular distributed object.
@@ -126,7 +127,7 @@ public class TableManager
try {
table = _tableClass.newInstance();
} catch (Exception e) {
Log.warning("Table.newInstance() failde [class=" + _tableClass + ", e=" + e + "].");
log.warning("Table.newInstance() failde [class=" + _tableClass + ", e=" + e + "].");
throw new InvocationException(INTERNAL_ERROR);
}
table.init(_dobj.getOid(), tableConfig, config);
@@ -136,7 +137,7 @@ public class TableManager
int cpos = (config.ais == null) ? 0 : config.ais.length;
String error = table.setPlayer(cpos, creator);
if (error != null) {
Log.warning("Unable to add creator to position zero of table!? [table=" + table +
log.warning("Unable to add creator to position zero of table!? [table=" + table +
", creator=" + creator + ", error=" + error + "].");
// bail out now and abort the table creation process
throw new InvocationException(error);
@@ -171,7 +172,7 @@ public class TableManager
// in which they are requesting to create a table
if (_dobj instanceof PlaceObject &&
!((PlaceObject)_dobj).occupants.contains(creator.getOid())) {
Log.warning("Requested to create a table in a place not occupied by the creator " +
log.warning("Requested to create a table in a place not occupied by the creator " +
"[creator=" + creator + ", ploid=" + _dobj.getOid() + "].");
throw new InvocationException(INTERNAL_ERROR);
}
@@ -240,7 +241,7 @@ public class TableManager
// remove the mapping from this user to the table
if (null == notePlayerRemoved(leaver.getOid(), leaver)) {
Log.warning("No body to table mapping to clear? [leaver=" + leaver.who() +
log.warning("No body to table mapping to clear? [leaver=" + leaver.who() +
", table=" + table + "].");
}
@@ -343,7 +344,7 @@ public class TableManager
return gobj.getOid();
} catch (Throwable t) {
Log.warning("Failed to create manager for game [config=" + table.config + "]: " + t);
log.warning("Failed to create manager for game [config=" + table.config + "]: " + t);
throw new InvocationException(INTERNAL_ERROR);
}
}
@@ -416,7 +417,7 @@ public class TableManager
if (table != null) {
purgeTable(table);
} else {
Log.warning("Requested to unmap table that wasn't mapped [gameOid=" + gameOid + "].");
log.warning("Requested to unmap table that wasn't mapped [gameOid=" + gameOid + "].");
}
}
@@ -432,7 +433,7 @@ public class TableManager
Table table = _goidMap.get(gameOid);
if (table == null) {
Log.warning("Unable to find table for running game [gameOid=" + gameOid + "].");
log.warning("Unable to find table for running game [gameOid=" + gameOid + "].");
return;
}
@@ -456,7 +457,7 @@ public class TableManager
// remove this player from the table
if (!pender.clearPlayerByOid(bodyOid)) {
Log.warning("Attempt to remove body from mapped table failed [table=" + pender +
log.warning("Attempt to remove body from mapped table failed [table=" + pender +
", bodyOid=" + bodyOid + "].");
return;
}
@@ -27,12 +27,13 @@ import com.threerings.util.Name;
import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.server.PlaceManager;
import com.threerings.parlor.Log;
import com.threerings.parlor.game.server.GameManager;
import com.threerings.parlor.game.server.GameManagerDelegate;
import com.threerings.parlor.turn.data.TurnGameObject;
import static com.threerings.parlor.Log.log;
/**
* Performs the server-side turn-based game processing for a turn based game. Game managers which
* wish to make use of the turn services must implement {@link TurnGameManager} and either create
@@ -96,7 +97,7 @@ public class TurnGameManagerDelegate extends GameManagerDelegate
{
// sanity check
if (_turnIdx < 0 || _turnIdx >= _turnGame.getPlayers().length) {
Log.warning("startTurn() called with invalid turn index [game=" + where() +
log.warning("startTurn() called with invalid turn index [game=" + where() +
", turnIdx=" + _turnIdx + "].");
// abort, abort
return;
@@ -105,7 +106,7 @@ public class TurnGameManagerDelegate extends GameManagerDelegate
// get the player name and sanity-check again
Name name = _tgmgr.getPlayerName(_turnIdx);
if (name == null) {
Log.warning("startTurn() called with invalid player [game=" + where() +
log.warning("startTurn() called with invalid player [game=" + where() +
", turnIdx=" + _turnIdx + "].");
return;
}
@@ -218,7 +219,7 @@ public class TurnGameManagerDelegate extends GameManagerDelegate
if (_turnIdx == oturnIdx) {
// if we've wrapped all the way around, stop where we are even if the current
// player is not active.
Log.warning("1 or less active players. Unable to properly change turn. " +
log.warning("1 or less active players. Unable to properly change turn. " +
"[game=" + where() + "].");
break;
}
@@ -236,7 +237,7 @@ public class TurnGameManagerDelegate extends GameManagerDelegate
while (!_tgmgr.isActivePlayer(_turnIdx)) {
_turnIdx = (_turnIdx + 1) % size;
if (_turnIdx == firstPick) {
Log.warning("No players eligible for randomly-assigned turn. Choking. " +
log.warning("No players eligible for randomly-assigned turn. Choking. " +
"[game=" + where() + "].");
return;
}