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
@@ -19,13 +19,13 @@ import com.threerings.presents.net.Credentials;
import com.threerings.presents.net.PingRequest;
import com.threerings.presents.net.PongResponse;
import com.threerings.presents.Log;
public class Client extends EventDispatcher
{
/** The default port on which the server listens for client connections. */
public static const DEFAULT_SERVER_PORT :int = 47624;
private static const log :Log = Log.getLog(Client);
public function Client (creds :Credentials, stage :Stage)
{
_creds = creds;
@@ -228,7 +228,7 @@ public class Client extends EventDispatcher
public function logoff (abortable :Boolean) :Boolean
{
if (_comm == null) {
Log.warning("Ignoring request to log off: not logged on.");
log.warning("Ignoring request to log off: not logged on.");
return true;
}
@@ -249,7 +249,7 @@ public class Client extends EventDispatcher
public function gotBootstrap (data :BootstrapData, omgr :DObjectManager)
:void
{
Log.debug("Got bootstrap " + data + ".");
log.debug("Got bootstrap " + data + ".");
_bstrap = data;
_omgr = omgr;
@@ -257,7 +257,7 @@ public class Client extends EventDispatcher
_invdir.init(omgr, _cloid, this);
Log.debug("TimeBaseService: " + requireService(TimeBaseService));
log.debug("TimeBaseService: " + requireService(TimeBaseService));
}
/**
@@ -47,8 +47,6 @@ import com.threerings.presents.net.SubscribeRequest;
import com.threerings.presents.net.UnsubscribeRequest;
import com.threerings.presents.net.UnsubscribeResponse;
import com.threerings.presents.Log;
/**
* The client distributed object manager manages a set of proxy objects
* which mirror the distributed objects maintained on the server.
@@ -59,6 +57,8 @@ import com.threerings.presents.Log;
public class ClientDObjectMgr
implements DObjectManager
{
private static const log :Log = Log.getLog(ClientDObjectMgr);
/**
* Constructs a client distributed object manager.
*
@@ -149,7 +149,7 @@ public class ClientDObjectMgr
long expire = System.currentTimeMillis() +
((Long)_delays.get(dclass)).longValue();
_flushes.put(obj.getOid(), new FlushRecord(obj, expire));
// Log.info("Flushing " + obj.getOid() + " at " +
// log.info("Flushing " + obj.getOid() + " at " +
// new java.util.Date(expire));
return;
}
@@ -194,14 +194,13 @@ public class ClientDObjectMgr
}
var obj :Object = _actions.shift();
Log.debug("processNextAction: " + obj);
// do the proper thing depending on the object
if (obj is BootstrapNotification) {
_client.gotBootstrap(obj.getData(), this);
} else if (obj is EventNotification) {
var evt :DEvent = obj.getEvent();
// Log.info("Dispatch event: " + evt);
// log.info("Dispatch event: " + evt);
dispatchEvent(evt);
} else if (obj is ObjectResponse) {
@@ -210,7 +209,7 @@ public class ClientDObjectMgr
} else if (obj is UnsubscribeResponse) {
var oid :int = obj.getOid();
if (_dead.remove(oid) == null) {
Log.warning("Received unsub ACK from unknown object " +
log.warning("Received unsub ACK from unknown object " +
"[oid=" + oid + "].");
}
@@ -253,7 +252,7 @@ public class ClientDObjectMgr
var target :DObject = (_ocache.get(toid) as DObject);
if (target == null) {
if (_dead.get(toid) == null) {
Log.warning("Unable to dispatch event on non-proxied " +
log.warning("Unable to dispatch event on non-proxied " +
"object [event=" + event + "].");
}
return;
@@ -266,7 +265,7 @@ public class ClientDObjectMgr
// if this is an object destroyed event, we need to remove the
// object from our object table
if (event is ObjectDestroyedEvent) {
// Log.info("Pitching destroyed object " +
// log.info("Pitching destroyed object " +
// "[oid=" + toid + ", class=" +
// StringUtil.shortClassName(target) + "].");
_ocache.remove(toid);
@@ -278,9 +277,9 @@ public class ClientDObjectMgr
}
} catch (e :Error) {
Log.warning("Failure processing event [event=" + event +
log.warning("Failure processing event [event=" + event +
", target=" + target + "].");
Log.logStackTrace(e);
log.logStackTrace(e);
}
}
@@ -300,15 +299,15 @@ public class ClientDObjectMgr
// let the penders know that the object is available
var req :PendingRequest = (_penders.remove(oid) as PendingRequest);
if (req == null) {
Log.warning("Got object, but no one cares?! " +
log.warning("Got object, but no one cares?! " +
"[oid=" + oid + ", obj=" + obj + "].");
return;
}
Log.debug("Got object: pendReq=" + req);
log.debug("Got object: pendReq=" + req);
for (var ii :int = 0; ii < req.targets.length; ii++) {
var target :Subscriber = (req.targets[ii] as Subscriber);
Log.debug("Notifying subscriber: " + target);
log.debug("Notifying subscriber: " + target);
// add them as a subscriber
obj.addSubscriber(target);
// and let them know that the object is in
@@ -325,7 +324,7 @@ public class ClientDObjectMgr
// let the penders know that the object is not available
var req :PendingRequest = (_penders.remove(oid) as PendingRequest);
if (req == null) {
Log.warning("Failed to get object, but no one cares?! " +
log.warning("Failed to get object, but no one cares?! " +
"[oid=" + oid + "].");
return;
}
@@ -343,7 +342,7 @@ public class ClientDObjectMgr
*/
protected function doSubscribe (oid :int, target :Subscriber) :void
{
// Log.info("doSubscribe: " + oid + ": " + target);
// log.info("doSubscribe: " + oid + ": " + target);
// first see if we've already got the object in our table
var obj :DObject = (_ocache.get(oid) as DObject);
@@ -369,7 +368,7 @@ public class ClientDObjectMgr
req = new PendingRequest(oid);
req.addTarget(target);
_penders.put(oid, req);
// Log.info("Registering pending request [oid=" + oid + "].");
// log.info("Registering pending request [oid=" + oid + "].");
// and issue a request to get things rolling
_comm.postMessage(new SubscribeRequest(oid));
@@ -386,7 +385,7 @@ public class ClientDObjectMgr
dobj.removeSubscriber(target);
} else {
Log.info("Requested to remove subscriber from " +
log.info("Requested to remove subscriber from " +
"non-proxied object [oid=" + oid +
", sub=" + target + "].");
}
@@ -16,8 +16,6 @@ import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Translations;
import com.threerings.presents.Log;
import com.threerings.presents.net.AuthRequest;
import com.threerings.presents.net.AuthResponse;
import com.threerings.presents.net.AuthResponseData;
@@ -76,7 +74,8 @@ public class Communicator
try {
_socket.close();
} catch (err :Error) {
Log.warning("Error closing failed socket [error=" + err + "].");
Log.getLog(this).warning(
"Error closing failed socket [error=" + err + "].");
}
_socket = null;
_outStream = null;
@@ -140,7 +139,8 @@ public class Communicator
var msg :DownstreamMessage =
(_inStream.readObject() as DownstreamMessage);
if (frameData.bytesAvailable > 0) {
Log.warning("Beans! We didn't fully read a frame, surely there's " +
Log.getLog(this).warning(
"Beans! We didn't fully read a frame, surely there's " +
"a bug in some streaming code. " +
"[bytesLeftOver=" + frameData.bytesAvailable + "].");
}
@@ -180,7 +180,7 @@ public class Communicator
*/
protected function socketError (event :IOErrorEvent) :void
{
Log.warning("socket error: " + event);
Log.getLog(this).warning("socket error: " + event);
shutdown(new Error("socket closed unexpectedly."));
}
@@ -21,8 +21,6 @@
package com.threerings.presents.client {
import com.threerings.presents.Log;
/**
* Provides the basic functionality used to dispatch invocation
* notification events.
@@ -47,9 +45,9 @@ public /* abstract */ class InvocationDecoder
*/
public function dispatchNotification (methodId :int, args :Array) :void
{
Log.warning("Requested to dispatch unknown method " +
"[receiver=" + receiver + ", methodId=" + methodId +
", args=" + args + "].");
Log.getLog(this).warning("Requested to dispatch unknown method " +
"[receiver=" + receiver + ", methodId=" + methodId +
", args=" + args + "].");
}
}
}
@@ -20,16 +20,16 @@ import com.threerings.presents.dobj.SubscriberAdapter;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.Log;
public class InvocationDirector
implements EventListener
{
private static const log :Log = Log.getLog(InvocationDirector);
public function init (omgr :DObjectManager, cloid :int, client :Client)
:void
{
if (_clobj != null) {
Log.warning("Zoiks, client object around during invmgr init!");
log.warning("Zoiks, client object around during invmgr init!");
cleanup();
}
@@ -84,11 +84,11 @@ public class InvocationDirector
var rreg :InvocationRegistration =
(_clobj.receivers.get(receiverCode) as InvocationRegistration);
if (rreg == null) {
Log.warning("Receiver unregistered for which we have no " +
log.warning("Receiver unregistered for which we have no " +
"id to code mapping [code=" + receiverCode + "].");
} else {
var odecoder :Object = _receivers.remove(rreg.receiverId);
// Log.info("Cleared receiver " +
// log.info("Cleared receiver " +
// StringUtil.shortClassName(odecoder) +
// " " + rreg + ".");
}
@@ -188,7 +188,7 @@ public class InvocationDirector
var listener :ListenerMarshaller =
(_listeners.remove(reqId) as ListenerMarshaller);
if (listener == null) {
Log.warning("Received invocation response for which we have " +
log.warning("Received invocation response for which we have " +
"no registered listener [reqId=" + reqId +
", methId=" + methodId +
", args=" + args + "]. " +
@@ -198,7 +198,7 @@ public class InvocationDirector
return;
}
// Log.info("Dispatching invocation response " +
// log.info("Dispatching invocation response " +
// "[listener=" + listener + ", methId=" + methodId +
// ", args=" + StringUtil.toString(args) + "].");
@@ -206,10 +206,10 @@ public class InvocationDirector
try {
listener.dispatchResponse(methodId, args);
} catch (e :Error) {
Log.warning("Invocation response listener choked " +
log.warning("Invocation response listener choked " +
"[listener=" + listener + ", methId=" + methodId +
", args=" + args + "].");
Log.logStackTrace(e);
log.logStackTrace(e);
}
// flush expired listeners periodically
@@ -230,25 +230,25 @@ public class InvocationDirector
var decoder :InvocationDecoder =
(_receivers.get(receiverId) as InvocationDecoder);
if (decoder == null) {
Log.warning("Received notification for which we have no " +
log.warning("Received notification for which we have no " +
"registered receiver [recvId=" + receiverId +
", methodId=" + methodId +
", args=" + args + "].");
return;
}
// Log.info("Dispatching invocation notification " +
// log.info("Dispatching invocation notification " +
// "[receiver=" + decoder.receiver + ", methodId=" + methodId +
// ", args=" + StringUtil.toString(args) + "].");
try {
decoder.dispatchNotification(methodId, args);
} catch (e :Error) {
Log.warning("Invocation notification receiver choked " +
log.warning("Invocation notification receiver choked " +
"[receiver=" + decoder.receiver +
", methId=" + methodId +
", args=" + args + "].");
Log.logStackTrace(e);
log.logStackTrace(e);
}
}
@@ -323,7 +323,7 @@ public class InvocationDirector
internal function gotClientObjectFailed (
oid :int, cause :ObjectAccessError) :void
{
Log.warning("Invocation director unable to subscribe to " +
log.warning("Invocation director unable to subscribe to " +
"client object [cloid=" + oid + ", cause=" + cause + "]!");
_client.getClientObjectFailed(cause);
}
@@ -5,7 +5,6 @@ import flash.utils.describeType;
import mx.collections.ArrayCollection;
import com.threerings.util.Name;
import com.threerings.presents.Log;
import com.threerings.presents.data.TimeBaseMarshaller;
import com.threerings.presents.dobj.DSet;
import com.threerings.presents.dobj.QSet;
@@ -18,6 +17,8 @@ import com.threerings.presents.net.BootstrapData;
public class TestClient extends Client
{
private static const log :Log = Log.getLog(TestClient);
public function TestClient ()
{
super(new UsernamePasswordCreds(new Name("Ray"), "fork-u-2"));
@@ -26,10 +27,10 @@ public class TestClient extends Client
var g1 :String = null;
var g2 :String = (com.threerings.util.Util.cast(g1, String) as String);
Log.debug("foo: " + (g1 === g2) + ", *" + g2 + "*, "); // + g2.length);
log.debug("foo: " + (g1 === g2) + ", *" + g2 + "*, "); // + g2.length);
var ob :Object = "this is a string";
Log.debug("part of an object: " + ob.substring(1));
log.debug("part of an object: " + ob.substring(1));
var arr :Array = new Array();
arr[0] = "Florp";
@@ -37,17 +38,17 @@ public class TestClient extends Client
arr[2] = "Swissbrat";
for (var key:* in arr) {
Log.debug("a key=" + key + " -> " + arr[key]);
log.debug("a key=" + key + " -> " + arr[key]);
}
delete arr[1];
arr["1"] = "oinkenheimer";
for (var key:* in arr) {
Log.debug("a key=" + key + " -> " + arr[key]);
log.debug("a key=" + key + " -> " + arr[key]);
}
Log.debug("length: " + arr.length);
Log.debug("arr[0]: " + arr[0]);
Log.debug("arr[1]: " + arr[1]);
Log.debug("arr[2]: " + arr[2]);
log.debug("length: " + arr.length);
log.debug("arr[0]: " + arr[0]);
log.debug("arr[1]: " + arr[1]);
log.debug("arr[2]: " + arr[2]);
//testFunc(2);
var bob :Person = new Person("Bob");
@@ -55,25 +56,25 @@ public class TestClient extends Client
var bob2 :Person = new Person("Bob");
bob.callPrintName(jim.printName);
Log.debug("bob == jim: " + (bob == jim));
Log.debug("bob === jim: " + (bob === jim));
Log.debug("bob == bob2: " + (bob == bob2));
Log.debug("bob === bob2: " + (bob === bob2));
Log.debug("bob == bob: " + (bob == bob));
Log.debug("bob === bob: " + (bob === bob));
log.debug("bob == jim: " + (bob == jim));
log.debug("bob === jim: " + (bob === jim));
log.debug("bob == bob2: " + (bob == bob2));
log.debug("bob === bob2: " + (bob === bob2));
log.debug("bob == bob: " + (bob == bob));
log.debug("bob === bob: " + (bob === bob));
var list :ArrayCollection = new ArrayCollection();
list.addItem(bob);
Log.debug("jim's indeX: " + list.getItemIndex(jim));
Log.debug("bob2's indeX: " + list.getItemIndex(bob2));
Log.debug("function: " + describeType(testFunc).toXMLString());
Log.debug("func length: " + testFunc.length);
Log.debug("funcToString: " + testFunc);
Log.debug("interfaces: " + describeType(Bint));
log.debug("jim's indeX: " + list.getItemIndex(jim));
log.debug("bob2's indeX: " + list.getItemIndex(bob2));
log.debug("function: " + describeType(testFunc).toXMLString());
log.debug("func length: " + testFunc.length);
log.debug("funcToString: " + testFunc);
log.debug("interfaces: " + describeType(Bint));
var funcy :Function = function (i :int) :void {
Log.debug("i is " + i);
Log.debug("first list item is " + list[0]);
log.debug("i is " + i);
log.debug("first list item is " + list[0]);
}
_savedFunc = funcy;
@@ -84,8 +85,8 @@ public class TestClient extends Client
var a :Object = new OldClass();
var c :Class = OldClass;
Log.debug("instance: " + describeType(a).toXMLString());
Log.debug("class : " + describeType(Pork).toXMLString());
log.debug("instance: " + describeType(a).toXMLString());
log.debug("class : " + describeType(Pork).toXMLString());
*/
/*
@@ -93,18 +94,18 @@ public class TestClient extends Client
var c :Object = 2.4;
var d :Object = new HooperClass(this);
Log.debug("1) " + (a as HelperClass));
Log.debug("2) " + (b as HelperClass));
Log.debug("3) " + HelperClass(a));
//Log.debug("4) " + HelperClass(b));
Log.debug("5) " + (c as int));
Log.debug("6) " + int(c));
log.debug("1) " + (a as HelperClass));
log.debug("2) " + (b as HelperClass));
log.debug("3) " + HelperClass(a));
//log.debug("4) " + HelperClass(b));
log.debug("5) " + (c as int));
log.debug("6) " + int(c));
//Log.debug("7) " + (d === a));
//log.debug("7) " + (d === a));
Log.debug("8) " + (a as HooperClass));
Log.debug("9) " + HelperClass(d));
//Log.debug("X) " + HooperClass(a));
log.debug("8) " + (a as HooperClass));
log.debug("9) " + HelperClass(d));
//log.debug("X) " + HooperClass(a));
var x :HelperClass = HelperClass(d);
var y :HelperClass = (d as HelperClass);
@@ -113,11 +114,11 @@ public class TestClient extends Client
x.hype();
y.hype();
z.hype();
Log.debug("x === d: " + (x === d));
Log.debug("y === d: " + (y === d));
Log.debug("x === y: " + (x === y));
Log.debug("d === z: " + (d === z));
Log.debug("y === z: " + (y === z));
log.debug("x === d: " + (x === d));
log.debug("y === d: " + (y === d));
log.debug("x === y: " + (x === y));
log.debug("d === z: " + (d === z));
log.debug("y === z: " + (y === z));
*/
//var ta :TypedArray = new TypedArray(HooperClass);
@@ -142,13 +143,13 @@ public class TestClient extends Client
public function testFunc (one :int, two :int = 0, three :int = -1) :void
{
Log.debug("this: " + ", args: " + arguments.length +
log.debug("this: " + ", args: " + arguments.length +
": " + arguments);
}
public function crazyArgs (num :int = 0, str :String = "lol") :void
{
Log.debug("crazyArgs " + num + ", " + str);
log.debug("crazyArgs " + num + ", " + str);
}
prototype var _foo :String;
@@ -158,7 +159,6 @@ public class TestClient extends Client
}
}
import com.threerings.presents.Log;
import com.threerings.presents.client.TestClient;
interface Aint {
@@ -178,7 +178,8 @@ class Person
public function printName () :void
{
Log.debug("printName called on " + _name + "! (this=" + this + ")");
Log.getLog(this).debug(
"printName called on " + _name + "! (this=" + this + ")");
}
public function callPrintName (funcy :Function) :void
@@ -211,7 +212,7 @@ class HelperClass
public function hype () :void
{
Log.debug("helper hype");
Log.getLog(this).debug("helper hype");
}
protected var _cli :TestClient;
@@ -232,7 +233,7 @@ final class HooperClass extends HelperClass
public override function hype () :void
{
Log.debug("hooper hype");
Log.getLog(this).debug("hooper hype");
}
public function porker () :void