More logging fixing, moved the compiled config stuff into Nenya.

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@4 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Michael Bayne
2006-06-23 21:21:05 +00:00
parent 220e2ddc53
commit e25ef0859e
13 changed files with 434 additions and 60 deletions
+34
View File
@@ -0,0 +1,34 @@
//
// $Id$
//
// Nenya library - tools for developing networked games
// Copyright (C) 2002-2006 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/nenya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings;
import java.util.logging.Logger;
/**
* A placeholder class that contains a reference to the log object used by this
* library.
*/
public class NenyaLog
{
/** We dispatch our log messages through this logger. */
public static Logger log = Logger.getLogger("com.threerings.nenya");
}
@@ -0,0 +1,132 @@
//
// $Id: CompiledConfigTask.java 3786 2005-12-19 19:09:00Z mdb $
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.tools;
import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.FileSet;
import com.samskivert.util.FileUtil;
import com.threerings.tools.xml.CompiledConfigParser;
import com.threerings.util.CompiledConfig;
/**
* Used to parse configuration information from an XML file and create the
* serialized representation that is used by the client and server.
*/
public class CompiledConfigTask extends Task
{
public void setParser (String parser)
{
_parser = parser;
}
public void setConfigdef (File configdef)
{
_configdef = configdef;
}
public void setTarget (File target)
{
_target = target;
}
public void addFileset (FileSet set)
{
_filesets.add(set);
}
public void execute () throws BuildException
{
// instantiate and sanity check the parser class
Object pobj = null;
try {
Class pclass = Class.forName(_parser);
pobj = pclass.newInstance();
} catch (Exception e) {
throw new BuildException("Error instantiating config parser", e);
}
if (!(pobj instanceof CompiledConfigParser)) {
throw new BuildException("Invalid parser class: " + _parser);
}
CompiledConfigParser parser = (CompiledConfigParser)pobj;
// if we have a single file and target specified, do those
if (_configdef != null) {
parse(parser, _configdef, _target);
}
// deal with the filesets
for (Iterator iter = _filesets.iterator(); iter.hasNext(); ) {
FileSet fs = (FileSet)iter.next();
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
File fromDir = fs.getDir(getProject());
String[] srcFiles = ds.getIncludedFiles();
for (int ii = 0; ii < srcFiles.length; ii++) {
File confdef = new File(fromDir, srcFiles[ii]);
parse(parser, confdef, null);
}
}
}
protected void parse (CompiledConfigParser parser, File confdef, File target)
throws BuildException
{
// make sure the source file exists
if (!confdef.exists()) {
String errmsg = "Config definition file not found: " + confdef;
throw new BuildException(errmsg);
}
// if no target was specified, resuffix the source file as to .dat
if (target == null) {
target = new File(FileUtil.resuffix(confdef, ".xml", ".dat"));
}
System.out.println("Compiling " + confdef + "...");
Serializable config = null;
try {
// parse it on up
config = parser.parseConfig(confdef);
} catch (Exception e) {
throw new BuildException("Failure parsing config definition", e);
}
try {
// and write it on out
CompiledConfig.saveConfig(target, config);
} catch (Exception e) {
throw new BuildException("Failure writing serialized config", e);
}
}
protected File _configdef;
protected File _target;
protected String _parser;
protected ArrayList _filesets = new ArrayList();
}
@@ -0,0 +1,70 @@
//
// $Id: CompiledConfigParser.java 3310 2005-01-24 23:08:21Z mdb $
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.tools.xml;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.Serializable;
import org.xml.sax.SAXException;
import org.apache.commons.digester.Digester;
import com.threerings.tools.CompiledConfigTask;
import com.threerings.util.CompiledConfig;
/**
* An abstract base implementation of a parser that is used to compile
* configuration definitions into config objects for use by the client and
* server.
*
* @see CompiledConfig
* @see CompiledConfigTask
*/
public abstract class CompiledConfigParser
{
/**
* Parses the supplied configuration file into a serializable
* configuration object.
*/
public Serializable parseConfig (File source)
throws IOException, SAXException
{
Digester digester = new Digester();
Serializable config = createConfigObject();
addRules(digester);
digester.push(config);
digester.parse(new FileInputStream(source));
return config;
}
/**
* Creates the config object instance that will be populated during
* the parsing process.
*/
protected abstract Serializable createConfigObject ();
/**
* Adds the necessary digester rules for parsing the config object.
*/
protected abstract void addRules (Digester digester);
}
@@ -0,0 +1,83 @@
//
// $Id: NestableRuleSet.java 4191 2006-06-13 22:42:20Z ray $
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.tools.xml;
import org.apache.commons.digester.Digester;
/**
* Used to define rule sets that can be nested within other rule sets. For
* example, say you have a "scene" object definition like so:
*
* <p> (Note that in the examples square brackets are used instead of
* angle brackets to simplify my life when composing the documentation.)
*
* <pre>
* [scene name="Foo" version=5]
* [/scene]
* </pre>
*
* This scene is extended with some auxiliary data defined by libraries
* which can parse and generate XML for their auxiliary objects:
*
* <pre>
* [scene sceneId=1 name="Foo" version=5]
* [spot]
* [portal portalId=1 x=1 y=1 targetSceneId=2/]
* [portal portalId=2 x=15 y=3 targetSceneId=3/]
* [portal portalId=3 x=9 y=6 targetSceneId=4/]
* [/spot]
* [miso]
* [object tileId=878172 x=4 y=13 action="cluck"/]
* [object tileId=123843 x=18 y=23 action="bark"/]
* [/miso]
* [/scene]
* </pre>
*
* The spot and miso services can define nestable rule sets which will be
* handed to the scene services who will instruct them to add their rule
* instances with a prefix of <code>scene.spot</code> and
* <code>scene.miso</code> respectively. They then happily parse their
* auxiliary objects without knowing that they have been nested inside
* some larger structure.
*
* <p> The nestable ruleset should then leave a single object on the
* digester stack that the enclosing entity can grab.
*
* <p> This isn't proper use of XML, but it solves the problem at hand in
* an easily extensible manner.
*/
public interface NestableRuleSet
{
/**
* Returns the name of the nested object's outer element so that the
* parent parser can use it to compose the total path prefix.
*/
public String getOuterElement ();
/**
* Instructs this ruleset to add its rules such that it parses its
* object from the specified path prefix. The outer element returned
* by {@link #getOuterElement} will have been included in the path
* prefix.
*/
public void addRuleInstances (String prefix, Digester digester);
}
@@ -1,5 +1,5 @@
// //
// $Id: Log.java 4191 2006-06-13 22:42:20Z ray $ // $Id: NestableWriter.java 4191 2006-06-13 22:42:20Z ray $
// //
// Narya library - tools for developing networked games // Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -19,38 +19,21 @@
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.util; package com.threerings.tools.xml;
import org.xml.sax.SAXException;
import com.megginson.sax.DataWriter;
/** /**
* A placeholder class that contains a reference to the log object used by * Provides the writing component of the nestable parsing system described
* the media services package. * by {@link NestableRuleSet}.
*/ */
public class Log public interface NestableWriter
{ {
public static com.samskivert.util.Log log = /**
new com.samskivert.util.Log("util"); * Called to generate XML for the supplied object to the supplied data
* writer.
/** Convenience function. */ */
public static void debug (String message) public void write (Object object, DataWriter writer)
{ throws SAXException;
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);
}
} }
@@ -27,6 +27,8 @@ import com.samskivert.util.ResultListener;
import com.samskivert.util.RunAnywhere; import com.samskivert.util.RunAnywhere;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
import static com.threerings.NenyaLog.log;
/** /**
* Encapsulates a bunch of hackery needed to invoke an external web browser * Encapsulates a bunch of hackery needed to invoke an external web browser
* from within a Java application. * from within a Java application.
@@ -78,13 +80,13 @@ public class BrowserUtil
cmd = new String[] { genagent, url.toString() }; cmd = new String[] { genagent, url.toString() };
} }
Log.info("Browsing URL [cmd=" + StringUtil.join(cmd, " ") + "]."); log.info("Browsing URL [cmd=" + StringUtil.join(cmd, " ") + "].");
try { try {
Process process = Runtime.getRuntime().exec(cmd); Process process = Runtime.getRuntime().exec(cmd);
BrowserTracker tracker = new BrowserTracker(process, url, listener); BrowserTracker tracker = new BrowserTracker(process, url, listener);
tracker.start(); tracker.start();
} catch (Exception e) { } catch (Exception e) {
Log.warning("Failed to launch browser [url=" + url + log.warning("Failed to launch browser [url=" + url +
", error=" + e + "]."); ", error=" + e + "].");
listener.requestFailed(e); listener.requestFailed(e);
} }
@@ -109,7 +111,7 @@ public class BrowserUtil
} }
String errmsg = "Launched browser failed [rv=" + rv + "]."; String errmsg = "Launched browser failed [rv=" + rv + "].";
Log.warning(errmsg); log.warning(errmsg);
if (!RunAnywhere.isWindows()) { if (!RunAnywhere.isWindows()) {
_listener.requestFailed(new Exception(errmsg)); _listener.requestFailed(new Exception(errmsg));
return; return;
@@ -124,12 +126,11 @@ public class BrowserUtil
rv = process.exitValue(); rv = process.exitValue();
if (rv != 0) { if (rv != 0) {
errmsg = "Failed to launch iexplore.exe [rv=" + rv + "]."; errmsg = "Failed to launch iexplore.exe [rv=" + rv + "].";
Log.warning(errmsg); log.warning(errmsg);
_listener.requestFailed(new Exception(errmsg)); _listener.requestFailed(new Exception(errmsg));
} }
} catch (Exception e) { } catch (Exception e) {
Log.logStackTrace(e);
_listener.requestFailed(e); _listener.requestFailed(e);
} }
} }
@@ -0,0 +1,66 @@
//
// $Id: CompiledConfig.java 3788 2005-12-20 02:09:18Z ray $
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.util;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
/**
* Used to load and store compiled configuration data (generally XML files
* that are parsed into Java object models and then serialized for rapid
* and simple access on the client and server).
*/
public class CompiledConfig
{
/**
* Unserializes a configuration object from the supplied input stream.
*/
public static Serializable loadConfig (InputStream source)
throws IOException
{
try {
ObjectInputStream oin = new ObjectInputStream(source);
return (Serializable)oin.readObject();
} catch (ClassNotFoundException cnfe) {
String errmsg = "Unknown config class";
throw (IOException) new IOException(errmsg).initCause(cnfe);
}
}
/**
* Serializes the supplied configuration object to the specified file
* path.
*/
public static void saveConfig (File target, Serializable config)
throws IOException
{
FileOutputStream fout = new FileOutputStream(target);
ObjectOutputStream oout = new ObjectOutputStream(fout);
oout.writeObject(config);
oout.close();
}
}
@@ -28,6 +28,8 @@ import java.awt.event.AWTEventListener;
import com.samskivert.util.Interval; import com.samskivert.util.Interval;
import com.samskivert.util.RunQueue; import com.samskivert.util.RunQueue;
import static com.threerings.NenyaLog.log;
/** /**
* Used to track user idleness in an AWT application. * Used to track user idleness in an AWT application.
*/ */
@@ -137,7 +139,7 @@ public abstract class IdleTracker
case ACTIVE: case ACTIVE:
// check whether they've idled out // check whether they've idled out
if (now >= (_lastEvent + _toIdleTime)) { if (now >= (_lastEvent + _toIdleTime)) {
Log.info("User idle for " + (now-_lastEvent) + "ms."); log.info("User idle for " + (now-_lastEvent) + "ms.");
_state = IDLE; _state = IDLE;
idledOut(); idledOut();
} }
@@ -146,7 +148,7 @@ public abstract class IdleTracker
case IDLE: case IDLE:
// check whether they've been idle for too long // check whether they've been idle for too long
if (now >= (_lastEvent + _toIdleTime + _toAbandonTime)) { if (now >= (_lastEvent + _toIdleTime + _toAbandonTime)) {
Log.info("User idle for " + (now-_lastEvent) + "ms. " + log.info("User idle for " + (now-_lastEvent) + "ms. " +
"Abandoning ship."); "Abandoning ship.");
_state = ABANDONED; _state = ABANDONED;
abandonedShip(); abandonedShip();
@@ -44,6 +44,8 @@ import com.samskivert.util.RunAnywhere;
import com.threerings.util.keybd.Keyboard; import com.threerings.util.keybd.Keyboard;
import static com.threerings.NenyaLog.log;
/** /**
* The keyboard manager observes keyboard actions on a particular * The keyboard manager observes keyboard actions on a particular
* component and posts commands associated with the key presses to the * component and posts commands associated with the key presses to the
@@ -139,7 +141,7 @@ public class KeyboardManager
{ {
// report incorrect usage // report incorrect usage
if (enabled && _target == null) { if (enabled && _target == null) {
Log.warning("Attempt to enable uninitialized keyboard manager!"); log.warning("Attempt to enable uninitialized keyboard manager!");
Thread.dumpStack(); Thread.dumpStack();
return; return;
} }
@@ -262,7 +264,7 @@ public class KeyboardManager
// bail if we're not enabled, we haven't the focus, or we're not // bail if we're not enabled, we haven't the focus, or we're not
// showing on-screen // showing on-screen
if (!_enabled || !_focus || !_target.isShowing()) { if (!_enabled || !_focus || !_target.isShowing()) {
// Log.info("dispatchKeyEvent [enabled=" + _enabled + // log.info("dispatchKeyEvent [enabled=" + _enabled +
// ", focus=" + _focus + // ", focus=" + _focus +
// ", showing=" + ((_target == null) ? "N/A" : // ", showing=" + ((_target == null) ? "N/A" :
// "" + _target.isShowing()) + "]."); // "" + _target.isShowing()) + "].");
@@ -360,7 +362,7 @@ public class KeyboardManager
{ {
if (DEBUG_EVENTS) { if (DEBUG_EVENTS) {
int keyCode = e.getKeyCode(); int keyCode = e.getKeyCode();
Log.info(msg + " [key=" + KeyEvent.getKeyText(keyCode) + "]."); log.info(msg + " [key=" + KeyEvent.getKeyText(keyCode) + "].");
} }
} }
@@ -442,7 +444,7 @@ public class KeyboardManager
_scheduled = true; _scheduled = true;
if (DEBUG_EVENTS) { if (DEBUG_EVENTS) {
Log.info("Pressing key [key=" + _keyText + "]."); log.info("Pressing key [key=" + _keyText + "].");
} }
} }
@@ -478,7 +480,7 @@ public class KeyboardManager
// infrequently. // infrequently.
if (_lastPress == _lastRelease) { if (_lastPress == _lastRelease) {
if (DEBUG_EVENTS) { if (DEBUG_EVENTS) {
Log.warning("Insta-releasing key due to equal key " + log.warning("Insta-releasing key due to equal key " +
"press/release times [key=" + _keyText + "]."); "press/release times [key=" + _keyText + "].");
} }
release(time); release(time);
@@ -497,7 +499,7 @@ public class KeyboardManager
} }
if (DEBUG_EVENTS) { if (DEBUG_EVENTS) {
Log.info("Releasing key [key=" + _keyText + "]."); log.info("Releasing key [key=" + _keyText + "].");
} }
// remove the repeat interval // remove the repeat interval
@@ -523,7 +525,7 @@ public class KeyboardManager
long deltaRelease = now - _lastRelease; long deltaRelease = now - _lastRelease;
if (KeyboardManager.DEBUG_INTERVAL) { if (KeyboardManager.DEBUG_INTERVAL) {
Log.info("Interval [key=" + _keyText + log.info("Interval [key=" + _keyText +
", deltaPress=" + deltaPress + ", deltaPress=" + deltaPress +
", deltaRelease=" + deltaRelease + "]."); ", deltaRelease=" + deltaRelease + "].");
} }
@@ -541,7 +543,7 @@ public class KeyboardManager
// _siid = IntervalManager.register( // _siid = IntervalManager.register(
// this, delay, Long.valueOf(_lastPress), false); // this, delay, Long.valueOf(_lastPress), false);
// if (KeyboardManager.DEBUG_INTERVAL) { // if (KeyboardManager.DEBUG_INTERVAL) {
// Log.info("Registered sub-interval " + // log.info("Registered sub-interval " +
// "[id=" + _siid + "]."); // "[id=" + _siid + "].");
// } // }
@@ -572,7 +574,7 @@ public class KeyboardManager
// sub-interval was registered // sub-interval was registered
if (_lastPress != ((Long)arg).longValue()) { if (_lastPress != ((Long)arg).longValue()) {
if (KeyboardManager.DEBUG_INTERVAL) { if (KeyboardManager.DEBUG_INTERVAL) {
Log.warning("Key pressed since sub-interval was " + log.warning("Key pressed since sub-interval was " +
"registered, aborting release check " + "registered, aborting release check " +
"[key=" + _keyText + "]."); "[key=" + _keyText + "].");
} }
@@ -21,7 +21,7 @@
package com.threerings.util.keybd; package com.threerings.util.keybd;
import com.threerings.util.Log; import static com.threerings.NenyaLog.log;
/** /**
* Provides access to the native operating system's auto-repeat keyboard * Provides access to the native operating system's auto-repeat keyboard
@@ -69,13 +69,13 @@ public class Keyboard
System.loadLibrary("keybd"); System.loadLibrary("keybd");
_haveLib = init(); _haveLib = init();
if (_haveLib) { if (_haveLib) {
Log.info("Loaded native keyboard library."); log.info("Loaded native keyboard library.");
} else { } else {
Log.info("Native keyboard library initialization failed."); log.info("Native keyboard library initialization failed.");
} }
} catch (UnsatisfiedLinkError e) { } catch (UnsatisfiedLinkError e) {
Log.warning("Failed to load native keyboard library " + log.warning("Failed to load native keyboard library " +
"[e=" + e + "]."); "[e=" + e + "].");
_haveLib = false; _haveLib = false;
} }
@@ -21,9 +21,10 @@
package com.threerings.util.unsafe; package com.threerings.util.unsafe;
import com.threerings.util.Log;
import com.samskivert.util.RunAnywhere; import com.samskivert.util.RunAnywhere;
import static com.threerings.NenyaLog.log;
/** /**
* A native library for doing unsafe things. Don't use this library. If * A native library for doing unsafe things. Don't use this library. If
* you must ignore that warning, then be sure you use it sparingly and * you must ignore that warning, then be sure you use it sparingly and
@@ -66,7 +67,7 @@ public class Unsafe
try { try {
Thread.sleep(millis); Thread.sleep(millis);
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
Log.info("Thread.sleep(" + millis + ") interrupted."); log.info("Thread.sleep(" + millis + ") interrupted.");
} }
} }
} }
@@ -138,7 +139,7 @@ public class Unsafe
System.loadLibrary("unsafe"); System.loadLibrary("unsafe");
_loaded = init(); _loaded = init();
} catch (UnsatisfiedLinkError e) { } catch (UnsatisfiedLinkError e) {
Log.warning("Failed to load 'unsafe' library: " + e + "."); log.warning("Failed to load 'unsafe' library: " + e + ".");
} }
} }
} }
@@ -25,7 +25,7 @@ import java.awt.Frame;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
import com.threerings.util.Log; import static com.threerings.NenyaLog.log;
public class KeyTimerApp public class KeyTimerApp
{ {
@@ -60,7 +60,7 @@ public class KeyTimerApp
_prStart = now; _prStart = now;
if (_rpStart != -1) { if (_rpStart != -1) {
Log.info("RP\t" + (now - _rpStart)); log.info("RP\t" + (now - _rpStart));
} }
logKey("keyPressed", e); logKey("keyPressed", e);
@@ -71,7 +71,7 @@ public class KeyTimerApp
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
_rpStart = now; _rpStart = now;
Log.info("PR\t" + (now - _prStart)); log.info("PR\t" + (now - _prStart));
logKey("keyReleased", e); logKey("keyReleased", e);
} }
@@ -87,7 +87,7 @@ public class KeyTimerApp
protected void logKey (String msg, KeyEvent e) protected void logKey (String msg, KeyEvent e)
{ {
int keyCode = e.getKeyCode(); int keyCode = e.getKeyCode();
Log.info(msg + " [key=" + KeyEvent.getKeyText(keyCode) + "]."); log.info(msg + " [key=" + KeyEvent.getKeyText(keyCode) + "].");
} }
protected long _prStart, _rpStart; protected long _prStart, _rpStart;
@@ -30,7 +30,7 @@ import javax.swing.JPanel;
import com.samskivert.swing.Controller; import com.samskivert.swing.Controller;
import com.samskivert.swing.ControllerProvider; import com.samskivert.swing.ControllerProvider;
import com.threerings.util.Log; import static com.threerings.NenyaLog.log;
public class KeyboardManagerApp public class KeyboardManagerApp
{ {
@@ -98,7 +98,7 @@ public class KeyboardManagerApp
public boolean handleAction (ActionEvent action) public boolean handleAction (ActionEvent action)
{ {
String cmd = action.getActionCommand(); String cmd = action.getActionCommand();
Log.info("handleAction [cmd=" + cmd + "]."); log.info("handleAction [cmd=" + cmd + "].");
return true; return true;
} }
} }