From e25ef0859eb47acfb9b00ad4a021de643a703903 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 23 Jun 2006 21:21:05 +0000 Subject: [PATCH] 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 --- src/java/com/threerings/NenyaLog.java | 34 +++++ .../threerings/tools/CompiledConfigTask.java | 132 ++++++++++++++++++ .../tools/xml/CompiledConfigParser.java | 70 ++++++++++ .../threerings/tools/xml/NestableRuleSet.java | 83 +++++++++++ .../xml/NestableWriter.java} | 45 ++---- src/java/com/threerings/util/BrowserUtil.java | 11 +- .../com/threerings/util/CompiledConfig.java | 66 +++++++++ src/java/com/threerings/util/IdleTracker.java | 6 +- .../com/threerings/util/KeyboardManager.java | 20 +-- .../com/threerings/util/keybd/Keyboard.java | 8 +- .../com/threerings/util/unsafe/Unsafe.java | 7 +- .../java/com/threerings/util/KeyTimerApp.java | 8 +- .../threerings/util/KeyboardManagerApp.java | 4 +- 13 files changed, 434 insertions(+), 60 deletions(-) create mode 100644 src/java/com/threerings/NenyaLog.java create mode 100644 src/java/com/threerings/tools/CompiledConfigTask.java create mode 100644 src/java/com/threerings/tools/xml/CompiledConfigParser.java create mode 100644 src/java/com/threerings/tools/xml/NestableRuleSet.java rename src/java/com/threerings/{util/Log.java => tools/xml/NestableWriter.java} (54%) create mode 100644 src/java/com/threerings/util/CompiledConfig.java diff --git a/src/java/com/threerings/NenyaLog.java b/src/java/com/threerings/NenyaLog.java new file mode 100644 index 00000000..1c0a5374 --- /dev/null +++ b/src/java/com/threerings/NenyaLog.java @@ -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"); +} diff --git a/src/java/com/threerings/tools/CompiledConfigTask.java b/src/java/com/threerings/tools/CompiledConfigTask.java new file mode 100644 index 00000000..2b6f7380 --- /dev/null +++ b/src/java/com/threerings/tools/CompiledConfigTask.java @@ -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(); +} diff --git a/src/java/com/threerings/tools/xml/CompiledConfigParser.java b/src/java/com/threerings/tools/xml/CompiledConfigParser.java new file mode 100644 index 00000000..80f9fb0a --- /dev/null +++ b/src/java/com/threerings/tools/xml/CompiledConfigParser.java @@ -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); +} diff --git a/src/java/com/threerings/tools/xml/NestableRuleSet.java b/src/java/com/threerings/tools/xml/NestableRuleSet.java new file mode 100644 index 00000000..69477d31 --- /dev/null +++ b/src/java/com/threerings/tools/xml/NestableRuleSet.java @@ -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: + * + *

(Note that in the examples square brackets are used instead of + * angle brackets to simplify my life when composing the documentation.) + * + *

+ * [scene name="Foo" version=5]
+ * [/scene]
+ * 
+ * + * This scene is extended with some auxiliary data defined by libraries + * which can parse and generate XML for their auxiliary objects: + * + *
+ * [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]
+ * 
+ * + * 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 scene.spot and + * scene.miso respectively. They then happily parse their + * auxiliary objects without knowing that they have been nested inside + * some larger structure. + * + *

The nestable ruleset should then leave a single object on the + * digester stack that the enclosing entity can grab. + * + *

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); +} diff --git a/src/java/com/threerings/util/Log.java b/src/java/com/threerings/tools/xml/NestableWriter.java similarity index 54% rename from src/java/com/threerings/util/Log.java rename to src/java/com/threerings/tools/xml/NestableWriter.java index 9a376628..00b0238a 100644 --- a/src/java/com/threerings/util/Log.java +++ b/src/java/com/threerings/tools/xml/NestableWriter.java @@ -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 // 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 // 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 - * the media services package. + * Provides the writing component of the nestable parsing system described + * by {@link NestableRuleSet}. */ -public class Log +public interface NestableWriter { - public static com.samskivert.util.Log log = - new com.samskivert.util.Log("util"); - - /** 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); - } + /** + * Called to generate XML for the supplied object to the supplied data + * writer. + */ + public void write (Object object, DataWriter writer) + throws SAXException; } diff --git a/src/java/com/threerings/util/BrowserUtil.java b/src/java/com/threerings/util/BrowserUtil.java index 315cc51c..f7d76993 100644 --- a/src/java/com/threerings/util/BrowserUtil.java +++ b/src/java/com/threerings/util/BrowserUtil.java @@ -27,6 +27,8 @@ import com.samskivert.util.ResultListener; import com.samskivert.util.RunAnywhere; import com.samskivert.util.StringUtil; +import static com.threerings.NenyaLog.log; + /** * Encapsulates a bunch of hackery needed to invoke an external web browser * from within a Java application. @@ -78,13 +80,13 @@ public class BrowserUtil cmd = new String[] { genagent, url.toString() }; } - Log.info("Browsing URL [cmd=" + StringUtil.join(cmd, " ") + "]."); + log.info("Browsing URL [cmd=" + StringUtil.join(cmd, " ") + "]."); try { Process process = Runtime.getRuntime().exec(cmd); BrowserTracker tracker = new BrowserTracker(process, url, listener); tracker.start(); } catch (Exception e) { - Log.warning("Failed to launch browser [url=" + url + + log.warning("Failed to launch browser [url=" + url + ", error=" + e + "]."); listener.requestFailed(e); } @@ -109,7 +111,7 @@ public class BrowserUtil } String errmsg = "Launched browser failed [rv=" + rv + "]."; - Log.warning(errmsg); + log.warning(errmsg); if (!RunAnywhere.isWindows()) { _listener.requestFailed(new Exception(errmsg)); return; @@ -124,12 +126,11 @@ public class BrowserUtil rv = process.exitValue(); if (rv != 0) { errmsg = "Failed to launch iexplore.exe [rv=" + rv + "]."; - Log.warning(errmsg); + log.warning(errmsg); _listener.requestFailed(new Exception(errmsg)); } } catch (Exception e) { - Log.logStackTrace(e); _listener.requestFailed(e); } } diff --git a/src/java/com/threerings/util/CompiledConfig.java b/src/java/com/threerings/util/CompiledConfig.java new file mode 100644 index 00000000..f2abedb2 --- /dev/null +++ b/src/java/com/threerings/util/CompiledConfig.java @@ -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(); + } +} diff --git a/src/java/com/threerings/util/IdleTracker.java b/src/java/com/threerings/util/IdleTracker.java index 2d30c724..4fdae356 100644 --- a/src/java/com/threerings/util/IdleTracker.java +++ b/src/java/com/threerings/util/IdleTracker.java @@ -28,6 +28,8 @@ import java.awt.event.AWTEventListener; import com.samskivert.util.Interval; import com.samskivert.util.RunQueue; +import static com.threerings.NenyaLog.log; + /** * Used to track user idleness in an AWT application. */ @@ -137,7 +139,7 @@ public abstract class IdleTracker case ACTIVE: // check whether they've idled out if (now >= (_lastEvent + _toIdleTime)) { - Log.info("User idle for " + (now-_lastEvent) + "ms."); + log.info("User idle for " + (now-_lastEvent) + "ms."); _state = IDLE; idledOut(); } @@ -146,7 +148,7 @@ public abstract class IdleTracker case IDLE: // check whether they've been idle for too long if (now >= (_lastEvent + _toIdleTime + _toAbandonTime)) { - Log.info("User idle for " + (now-_lastEvent) + "ms. " + + log.info("User idle for " + (now-_lastEvent) + "ms. " + "Abandoning ship."); _state = ABANDONED; abandonedShip(); diff --git a/src/java/com/threerings/util/KeyboardManager.java b/src/java/com/threerings/util/KeyboardManager.java index feb4995a..33a4e8d4 100644 --- a/src/java/com/threerings/util/KeyboardManager.java +++ b/src/java/com/threerings/util/KeyboardManager.java @@ -44,6 +44,8 @@ import com.samskivert.util.RunAnywhere; import com.threerings.util.keybd.Keyboard; +import static com.threerings.NenyaLog.log; + /** * The keyboard manager observes keyboard actions on a particular * component and posts commands associated with the key presses to the @@ -139,7 +141,7 @@ public class KeyboardManager { // report incorrect usage if (enabled && _target == null) { - Log.warning("Attempt to enable uninitialized keyboard manager!"); + log.warning("Attempt to enable uninitialized keyboard manager!"); Thread.dumpStack(); return; } @@ -262,7 +264,7 @@ public class KeyboardManager // bail if we're not enabled, we haven't the focus, or we're not // showing on-screen if (!_enabled || !_focus || !_target.isShowing()) { -// Log.info("dispatchKeyEvent [enabled=" + _enabled + +// log.info("dispatchKeyEvent [enabled=" + _enabled + // ", focus=" + _focus + // ", showing=" + ((_target == null) ? "N/A" : // "" + _target.isShowing()) + "]."); @@ -360,7 +362,7 @@ public class KeyboardManager { if (DEBUG_EVENTS) { 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; if (DEBUG_EVENTS) { - Log.info("Pressing key [key=" + _keyText + "]."); + log.info("Pressing key [key=" + _keyText + "]."); } } @@ -478,7 +480,7 @@ public class KeyboardManager // infrequently. if (_lastPress == _lastRelease) { 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 + "]."); } release(time); @@ -497,7 +499,7 @@ public class KeyboardManager } if (DEBUG_EVENTS) { - Log.info("Releasing key [key=" + _keyText + "]."); + log.info("Releasing key [key=" + _keyText + "]."); } // remove the repeat interval @@ -523,7 +525,7 @@ public class KeyboardManager long deltaRelease = now - _lastRelease; if (KeyboardManager.DEBUG_INTERVAL) { - Log.info("Interval [key=" + _keyText + + log.info("Interval [key=" + _keyText + ", deltaPress=" + deltaPress + ", deltaRelease=" + deltaRelease + "]."); } @@ -541,7 +543,7 @@ public class KeyboardManager // _siid = IntervalManager.register( // this, delay, Long.valueOf(_lastPress), false); // if (KeyboardManager.DEBUG_INTERVAL) { -// Log.info("Registered sub-interval " + +// log.info("Registered sub-interval " + // "[id=" + _siid + "]."); // } @@ -572,7 +574,7 @@ public class KeyboardManager // sub-interval was registered if (_lastPress != ((Long)arg).longValue()) { if (KeyboardManager.DEBUG_INTERVAL) { - Log.warning("Key pressed since sub-interval was " + + log.warning("Key pressed since sub-interval was " + "registered, aborting release check " + "[key=" + _keyText + "]."); } diff --git a/src/java/com/threerings/util/keybd/Keyboard.java b/src/java/com/threerings/util/keybd/Keyboard.java index 509d140a..ffc6f813 100644 --- a/src/java/com/threerings/util/keybd/Keyboard.java +++ b/src/java/com/threerings/util/keybd/Keyboard.java @@ -21,7 +21,7 @@ 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 @@ -69,13 +69,13 @@ public class Keyboard System.loadLibrary("keybd"); _haveLib = init(); if (_haveLib) { - Log.info("Loaded native keyboard library."); + log.info("Loaded native keyboard library."); } else { - Log.info("Native keyboard library initialization failed."); + log.info("Native keyboard library initialization failed."); } } catch (UnsatisfiedLinkError e) { - Log.warning("Failed to load native keyboard library " + + log.warning("Failed to load native keyboard library " + "[e=" + e + "]."); _haveLib = false; } diff --git a/src/java/com/threerings/util/unsafe/Unsafe.java b/src/java/com/threerings/util/unsafe/Unsafe.java index 7514362d..a1fd223f 100644 --- a/src/java/com/threerings/util/unsafe/Unsafe.java +++ b/src/java/com/threerings/util/unsafe/Unsafe.java @@ -21,9 +21,10 @@ package com.threerings.util.unsafe; -import com.threerings.util.Log; import com.samskivert.util.RunAnywhere; +import static com.threerings.NenyaLog.log; + /** * 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 @@ -66,7 +67,7 @@ public class Unsafe try { Thread.sleep(millis); } 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"); _loaded = init(); } catch (UnsatisfiedLinkError e) { - Log.warning("Failed to load 'unsafe' library: " + e + "."); + log.warning("Failed to load 'unsafe' library: " + e + "."); } } } diff --git a/tests/src/java/com/threerings/util/KeyTimerApp.java b/tests/src/java/com/threerings/util/KeyTimerApp.java index bc4c4cc9..0be875f7 100644 --- a/tests/src/java/com/threerings/util/KeyTimerApp.java +++ b/tests/src/java/com/threerings/util/KeyTimerApp.java @@ -25,7 +25,7 @@ import java.awt.Frame; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; -import com.threerings.util.Log; +import static com.threerings.NenyaLog.log; public class KeyTimerApp { @@ -60,7 +60,7 @@ public class KeyTimerApp _prStart = now; if (_rpStart != -1) { - Log.info("RP\t" + (now - _rpStart)); + log.info("RP\t" + (now - _rpStart)); } logKey("keyPressed", e); @@ -71,7 +71,7 @@ public class KeyTimerApp long now = System.currentTimeMillis(); _rpStart = now; - Log.info("PR\t" + (now - _prStart)); + log.info("PR\t" + (now - _prStart)); logKey("keyReleased", e); } @@ -87,7 +87,7 @@ public class KeyTimerApp protected void logKey (String msg, KeyEvent e) { int keyCode = e.getKeyCode(); - Log.info(msg + " [key=" + KeyEvent.getKeyText(keyCode) + "]."); + log.info(msg + " [key=" + KeyEvent.getKeyText(keyCode) + "]."); } protected long _prStart, _rpStart; diff --git a/tests/src/java/com/threerings/util/KeyboardManagerApp.java b/tests/src/java/com/threerings/util/KeyboardManagerApp.java index 822fd650..12956d26 100644 --- a/tests/src/java/com/threerings/util/KeyboardManagerApp.java +++ b/tests/src/java/com/threerings/util/KeyboardManagerApp.java @@ -30,7 +30,7 @@ import javax.swing.JPanel; import com.samskivert.swing.Controller; import com.samskivert.swing.ControllerProvider; -import com.threerings.util.Log; +import static com.threerings.NenyaLog.log; public class KeyboardManagerApp { @@ -98,7 +98,7 @@ public class KeyboardManagerApp public boolean handleAction (ActionEvent action) { String cmd = action.getActionCommand(); - Log.info("handleAction [cmd=" + cmd + "]."); + log.info("handleAction [cmd=" + cmd + "]."); return true; } }