From ecac8e0f6d0aa4d58ceb04d6c3a89a8424be7cdf Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 23 Jun 2006 19:32:51 +0000 Subject: [PATCH] Move to our new Java logging based logging style which also fixes a conflict between logging in the Narya util package and the Nenya util package. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4214 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../{util/Log.java => NaryaLog.java} | 38 ++++--------------- .../com/threerings/util/MessageBundle.java | 8 ++-- .../com/threerings/util/MessageManager.java | 8 ++-- .../com/threerings/util/TrackedObject.java | 4 +- .../threerings/util/signal/SignalManager.java | 9 +++-- 5 files changed, 26 insertions(+), 41 deletions(-) rename src/java/com/threerings/{util/Log.java => NaryaLog.java} (56%) diff --git a/src/java/com/threerings/util/Log.java b/src/java/com/threerings/NaryaLog.java similarity index 56% rename from src/java/com/threerings/util/Log.java rename to src/java/com/threerings/NaryaLog.java index 0e7c1a279..d1b87ec89 100644 --- a/src/java/com/threerings/util/Log.java +++ b/src/java/com/threerings/NaryaLog.java @@ -2,7 +2,7 @@ // $Id$ // // Narya library - tools for developing networked games -// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved +// Copyright (C) 2002-2006 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 @@ -19,38 +19,16 @@ // 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; + +import java.util.logging.Logger; /** * A placeholder class that contains a reference to the log object used by - * the media services package. + * this project. */ -public class Log +public class NaryaLog { - 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); - } + /** We dispatch our log messages through this logger. */ + public static Logger log = Logger.getLogger("com.threerings.narya"); } diff --git a/src/java/com/threerings/util/MessageBundle.java b/src/java/com/threerings/util/MessageBundle.java index 7b143614d..07599d757 100644 --- a/src/java/com/threerings/util/MessageBundle.java +++ b/src/java/com/threerings/util/MessageBundle.java @@ -28,6 +28,8 @@ import java.util.ResourceBundle; import com.samskivert.text.MessageUtil; import com.samskivert.util.StringUtil; +import static com.threerings.NaryaLog.log; + /** * A message bundle provides an easy mechanism by which to obtain * translated message strings from a resource bundle. It uses the {@link @@ -116,7 +118,7 @@ public class MessageBundle } if (reportMissing) { - Log.warning("Missing translation message " + + log.warning("Missing translation message " + "[bundle=" + _path + ", key=" + key + "]."); Thread.dumpStack(); } @@ -235,14 +237,14 @@ public class MessageBundle args = newargs; msg = getResourceString(key + getSuffix(args)); } catch (Exception e) { - Log.warning("Failure doing automatic plural handling " + + log.warning("Failure doing automatic plural handling " + "[bundle=" + _path + ", key=" + key + ", args=" + StringUtil.toString(args) + ", error=" + e + "]."); } } else { - Log.warning("Missing translation message " + + log.warning("Missing translation message " + "[bundle=" + _path + ", key=" + key + "]."); Thread.dumpStack(); } diff --git a/src/java/com/threerings/util/MessageManager.java b/src/java/com/threerings/util/MessageManager.java index 3249f7d32..3cfa378b8 100644 --- a/src/java/com/threerings/util/MessageManager.java +++ b/src/java/com/threerings/util/MessageManager.java @@ -28,6 +28,8 @@ import java.util.ResourceBundle; import com.samskivert.util.StringUtil; +import static com.threerings.NaryaLog.log; + /** * The message manager provides a thin wrapper around Java's built-in * localization support, supporting a policy of dividing up localization @@ -70,7 +72,7 @@ public class MessageManager // use the default locale _locale = Locale.getDefault(); - Log.info("Using locale: " + _locale + "."); + log.info("Using locale: " + _locale + "."); // make sure the prefix ends with a dot if (!_prefix.endsWith(".")) { @@ -139,7 +141,7 @@ public class MessageManager rbundle = ResourceBundle.getBundle(fqpath, _locale); } } catch (MissingResourceException mre) { - Log.warning("Unable to resolve resource bundle " + + log.warning("Unable to resolve resource bundle " + "[path=" + fqpath + ", locale=" + _locale + "]."); } @@ -159,7 +161,7 @@ public class MessageManager // nothing to worry about } catch (Throwable t) { - Log.warning("Failure instantiating custom message bundle " + + log.warning("Failure instantiating custom message bundle " + "[mbclass=" + mbclass + ", error=" + t + "]."); } } diff --git a/src/java/com/threerings/util/TrackedObject.java b/src/java/com/threerings/util/TrackedObject.java index 25c45b1d4..ddf514284 100644 --- a/src/java/com/threerings/util/TrackedObject.java +++ b/src/java/com/threerings/util/TrackedObject.java @@ -27,6 +27,8 @@ import java.util.Map; import com.samskivert.util.Tuple; +import static com.threerings.NaryaLog.log; + /** * Used to perform rudimentary memory profiling on large, running systems * where it is impractical to operate a real profiler. Instances of {@link @@ -75,7 +77,7 @@ public class TrackedObject if (count != null) { count[0]--; } else { - Log.warning("Finalized TrackedObject missing counter! " + + log.warning("Finalized TrackedObject missing counter! " + "[class=" + clazz + "]."); } } diff --git a/src/java/com/threerings/util/signal/SignalManager.java b/src/java/com/threerings/util/signal/SignalManager.java index 025544459..5a06bcd3b 100644 --- a/src/java/com/threerings/util/signal/SignalManager.java +++ b/src/java/com/threerings/util/signal/SignalManager.java @@ -23,7 +23,8 @@ package com.threerings.util.signal; import com.samskivert.util.HashIntMap; import com.samskivert.util.ObserverList; -import com.threerings.util.Log; + +import static com.threerings.NaryaLog.log; /** * Uses native code to catch Unix signals and invoke callbacks on a @@ -173,7 +174,7 @@ public class SignalManager if (_haveLibrary && _sigdis == null) { _sigdis = new Thread() { public void run () { - Log.info("Dispatching signals..."); + log.info("Dispatching signals..."); dispatchSignals(); } }; @@ -190,7 +191,7 @@ public class SignalManager { ObserverList list = (ObserverList)_handlers.get(signal); if (list == null || !list.contains(handler)) { - Log.warning("Requested to remove non-registered handler " + + log.warning("Requested to remove non-registered handler " + "[signal=" + signal + ", handler=" + handler + "]."); return; } @@ -273,7 +274,7 @@ public class SignalManager System.loadLibrary("signal"); _haveLibrary = true; } catch (Throwable t) { - Log.info("Could not load libsignal.so; signal handling disabled."); + log.info("Could not load libsignal.so; signal handling disabled."); } } }