Provide per-package loggers.
I also made them package private where possible. It's too easy for code that depends on samskivert to accidentally import com.samskivert.Log rather than define its own logger. Unfortunately Java doesn't have "this package and subpackages" protection, so some of the package loggers have to be public to allow sub-packages to access them. I didn't really want to have to define loggers for half a dozen subpackages as well.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// samskivert library - useful routines for java programs
|
||||
// Copyright (C) 2001-2012 Michael Bayne, et al.
|
||||
// http://github.com/samskivert/samskivert/blob/master/COPYING
|
||||
|
||||
package com.samskivert.io;
|
||||
|
||||
import com.samskivert.util.Logger;
|
||||
|
||||
/** Provides a log instance for this package. */
|
||||
class Log {
|
||||
|
||||
static final Logger log = Logger.getLogger("com.samskivert.io");
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.io.Log.log;
|
||||
|
||||
/**
|
||||
* Convenience methods for streams.
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.net.URLStreamHandlerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.net.Log.log;
|
||||
|
||||
/**
|
||||
* Allows other entities in an application to register URLStreamHandler
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// samskivert library - useful routines for java programs
|
||||
// Copyright (C) 2001-2012 Michael Bayne, et al.
|
||||
// http://github.com/samskivert/samskivert/blob/master/COPYING
|
||||
|
||||
package com.samskivert.net;
|
||||
|
||||
import com.samskivert.util.Logger;
|
||||
|
||||
/** Provides a log instance for this package. */
|
||||
class Log {
|
||||
|
||||
static final Logger log = Logger.getLogger("com.samskivert.net");
|
||||
}
|
||||
@@ -29,7 +29,7 @@ import com.samskivert.jdbc.SimpleRepository;
|
||||
import com.samskivert.util.ArrayUtil;
|
||||
import com.samskivert.util.HashIntMap;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.servlet.Log.log;
|
||||
|
||||
/**
|
||||
* Accomplishes the process of site identification based on a mapping from domains (e.g.
|
||||
|
||||
+5
-8
@@ -3,15 +3,12 @@
|
||||
// Copyright (C) 2001-2012 Michael Bayne, et al.
|
||||
// http://github.com/samskivert/samskivert/blob/master/COPYING
|
||||
|
||||
package com.samskivert;
|
||||
package com.samskivert.servlet;
|
||||
|
||||
import com.samskivert.util.Logger;
|
||||
|
||||
/**
|
||||
* Contains a reference to the log object used by the samskivert package.
|
||||
*/
|
||||
public class Log
|
||||
{
|
||||
/** We dispatch our log messages through this logger. */
|
||||
public static final Logger log = Logger.getLogger("com.samskivert");
|
||||
/** Provides a log instance for this package (and sub-packages). */
|
||||
public class Log {
|
||||
|
||||
public static final Logger log = Logger.getLogger("com.samskivert.servlet");
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import com.samskivert.text.MessageUtil;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.servlet.Log.log;
|
||||
|
||||
/**
|
||||
* The message manager handles the translation messages for a web application. The webapp should
|
||||
|
||||
@@ -19,7 +19,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.samskivert.util.HashIntMap;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.servlet.Log.log;
|
||||
|
||||
/**
|
||||
* Web applications may wish to load resources in such a way that the site
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.samskivert.util.RunQueue;
|
||||
import com.samskivert.util.StringUtil;
|
||||
import com.samskivert.util.Tuple;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.servlet.Log.log;
|
||||
|
||||
/**
|
||||
* The user manager provides easy access to user objects for servlets. It takes care of cookie
|
||||
|
||||
@@ -9,7 +9,8 @@ import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import com.samskivert.util.ConfigUtil;
|
||||
import static com.samskivert.Log.log;
|
||||
|
||||
import static com.samskivert.servlet.Log.log;
|
||||
|
||||
/**
|
||||
* The exception map is used to map exceptions to error messages based on
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.awt.Rectangle;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.swing.Log.log;
|
||||
|
||||
/**
|
||||
* Used to lay out components at absolute coordinates. This layout manager
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.awt.event.HierarchyListener;
|
||||
|
||||
import com.samskivert.swing.event.CommandEvent;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.swing.Log.log;
|
||||
|
||||
/**
|
||||
* The controller class provides a basis for the separation of user interface
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.beans.PropertyChangeListener;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.swing.Log.log;
|
||||
|
||||
/**
|
||||
* Used to enable or disable a source component based on some
|
||||
|
||||
@@ -37,7 +37,7 @@ import com.samskivert.util.Tuple;
|
||||
|
||||
import com.samskivert.swing.util.SwingUtil;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.swing.Log.log;
|
||||
|
||||
/**
|
||||
* The label is a multipurpose text display mechanism that can display small amounts of text
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// samskivert library - useful routines for java programs
|
||||
// Copyright (C) 2001-2012 Michael Bayne, et al.
|
||||
// http://github.com/samskivert/samskivert/blob/master/COPYING
|
||||
|
||||
package com.samskivert.swing;
|
||||
|
||||
import com.samskivert.util.Logger;
|
||||
|
||||
/** Provides a log instance for this package (and sub-packages). */
|
||||
public class Log {
|
||||
|
||||
public static final Logger log = Logger.getLogger("com.samskivert.swing");
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import com.samskivert.util.ClassUtil;
|
||||
import com.samskivert.util.ListUtil;
|
||||
import com.samskivert.util.ObjectUtil;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.swing.Log.log;
|
||||
|
||||
/**
|
||||
* Allows simple displaying and editing of Objects in a table format.
|
||||
|
||||
@@ -37,7 +37,7 @@ import com.samskivert.util.DebugChords;
|
||||
import com.samskivert.util.ListUtil;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.swing.Log.log;
|
||||
|
||||
/**
|
||||
* Provides a service where named variables can be registered as adjustable by the developer at
|
||||
|
||||
@@ -30,7 +30,7 @@ import javax.swing.event.MouseInputAdapter;
|
||||
|
||||
import com.samskivert.swing.event.AncestorAdapter;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.swing.Log.log;
|
||||
|
||||
/**
|
||||
* A custom Drag and Drop manager for use within a single JVM. Does what we
|
||||
|
||||
@@ -15,7 +15,7 @@ import javax.swing.JMenuItem;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.swing.Log.log;
|
||||
|
||||
/**
|
||||
* The menu util class provides miscellaneous useful utility routines for
|
||||
|
||||
@@ -53,7 +53,7 @@ import javax.swing.table.TableModel;
|
||||
|
||||
import com.samskivert.util.SortableArrayList;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.swing.Log.log;
|
||||
|
||||
/**
|
||||
* Miscellaneous useful Swing-related utility functions.
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.lang.reflect.Method;
|
||||
import java.util.Hashtable;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.swing.Log.log;
|
||||
|
||||
/**
|
||||
* The task master provides the ability for swing applications to invoke
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// samskivert library - useful routines for java programs
|
||||
// Copyright (C) 2001-2012 Michael Bayne, et al.
|
||||
// http://github.com/samskivert/samskivert/blob/master/COPYING
|
||||
|
||||
package com.samskivert.test;
|
||||
|
||||
import com.samskivert.util.Logger;
|
||||
|
||||
/** Provides a log instance for this package. */
|
||||
class Log {
|
||||
|
||||
static final Logger log = Logger.getLogger("com.samskivert.test");
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.test.Log.log;
|
||||
|
||||
/**
|
||||
* Utilities used by unit tests for the samskivert library which are
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.text.FieldPosition;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.util.UtilLog.log;
|
||||
|
||||
/**
|
||||
* Used by various services to generate audit logs which can be useful for auditing, debugging and
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package com.samskivert.util;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.util.UtilLog.log;
|
||||
|
||||
/**
|
||||
* A very basic implementation of RunQueue for general purpose use.
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.util.UtilLog.log;
|
||||
|
||||
/**
|
||||
* The config class provides a unified interaface to application configuration information. See
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.Map;
|
||||
|
||||
import com.samskivert.io.StreamUtil;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.util.UtilLog.log;
|
||||
|
||||
/**
|
||||
* The config util class provides routines for loading configuration information.
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.ArrayList;
|
||||
import com.samskivert.util.HashIntMap;
|
||||
import com.samskivert.util.Tuple;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.util.UtilLog.log;
|
||||
|
||||
/**
|
||||
* Provides a mechanism for causing code to be invoked when a particular
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.jar.JarFile;
|
||||
|
||||
import com.samskivert.io.StreamUtil;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.util.UtilLog.log;
|
||||
|
||||
/**
|
||||
* Utility methods for files.
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.Date;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.util.UtilLog.log;
|
||||
|
||||
/**
|
||||
* An interface for doing operations after some delay. Allows expiration to occur on a specific
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.HashMap;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.util.UtilLog.log;
|
||||
|
||||
/**
|
||||
* The invoker is used to invoke self-contained units of code on an invoking thread. Each invoker
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package com.samskivert.util;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.util.UtilLog.log;
|
||||
|
||||
/**
|
||||
* Manages the lifecycle (initialization and shutdown) of a collection of components.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package com.samskivert.util;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.util.UtilLog.log;
|
||||
|
||||
/**
|
||||
* The looping thread provides the basic functionality for a thread that does its processing in a
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.util.UtilLog.log;
|
||||
|
||||
/**
|
||||
* Provides a simplified mechanism for maintaining a list of observers (or listeners or whatever
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.prefs.AbstractPreferences;
|
||||
import java.util.prefs.BackingStoreException;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.util.UtilLog.log;
|
||||
|
||||
/**
|
||||
* Extends the {@link Config} mechanism to allow the modification of configuration values, which
|
||||
@@ -51,7 +51,7 @@ public class PrefsConfig extends Config
|
||||
*/
|
||||
public PrefsConfig (String path, Properties props)
|
||||
{
|
||||
super(path, props);
|
||||
super(props);
|
||||
|
||||
try {
|
||||
_prefs = Preferences.userRoot().node(path);
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.Random;
|
||||
|
||||
import com.samskivert.annotation.ReplacedBy;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.util.UtilLog.log;
|
||||
|
||||
/**
|
||||
* Provides miscellaneous utility routines to simplify obtaining useful random number values and to
|
||||
|
||||
@@ -8,7 +8,7 @@ package com.samskivert.util;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.util.UtilLog.log;
|
||||
|
||||
/**
|
||||
* A class used to debug situations where a method that should be called
|
||||
|
||||
@@ -7,7 +7,7 @@ package com.samskivert.util;
|
||||
|
||||
import java.awt.event.InputEvent;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.util.UtilLog.log;
|
||||
|
||||
/**
|
||||
* <cite>Write once, run anywhere.</cite> Well, at least that's what it
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.util.UtilLog.log;
|
||||
|
||||
/**
|
||||
* Runnable related utility methods.
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.ArrayList;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.util.UtilLog.log;
|
||||
|
||||
/**
|
||||
* Executes tasks serially, but each one on a separate thread. If a task times
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// samskivert library - useful routines for java programs
|
||||
// Copyright (C) 2001-2012 Michael Bayne, et al.
|
||||
// http://github.com/samskivert/samskivert/blob/master/COPYING
|
||||
|
||||
package com.samskivert.util;
|
||||
|
||||
/** Provides a log instance for this package. */
|
||||
class UtilLog {
|
||||
|
||||
static final Logger log = Logger.getLogger("com.samskivert");
|
||||
}
|
||||
@@ -25,7 +25,7 @@ import com.samskivert.servlet.util.FriendlyException;
|
||||
import com.samskivert.servlet.util.RequestUtils;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.servlet.Log.log;
|
||||
|
||||
/**
|
||||
* The servlet API defines the concept of a web application and associates certain attributes with
|
||||
|
||||
@@ -42,7 +42,7 @@ import com.samskivert.servlet.util.FriendlyException;
|
||||
import com.samskivert.util.ConfigUtil;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.servlet.Log.log;
|
||||
|
||||
/**
|
||||
* The dispatcher servlet builds upon Velocity's architecture. It does so in the following ways:
|
||||
|
||||
@@ -13,7 +13,8 @@ import org.apache.velocity.exception.ResourceNotFoundException;
|
||||
import org.apache.velocity.runtime.resource.Resource;
|
||||
import org.apache.velocity.runtime.resource.loader.ResourceLoader;
|
||||
|
||||
import com.samskivert.Log;
|
||||
// we can't static import log because ResourceLoader defines a log that shadows it
|
||||
import com.samskivert.servlet.Log;
|
||||
import com.samskivert.servlet.SiteIdentifier;
|
||||
import com.samskivert.servlet.SiteResourceLoader;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package com.samskivert.velocity;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.servlet.Log.log;
|
||||
|
||||
/**
|
||||
* Decodes a compound Velocity resource name plus site identifier.
|
||||
|
||||
@@ -15,7 +15,8 @@ import org.apache.velocity.runtime.resource.ResourceFactory;
|
||||
import org.apache.velocity.runtime.resource.ResourceManagerImpl;
|
||||
import org.apache.velocity.runtime.resource.loader.ResourceLoader;
|
||||
|
||||
import com.samskivert.Log;
|
||||
// we can't static import log because ResourceManagerImpl defines a log that shadows it
|
||||
import com.samskivert.servlet.Log;
|
||||
import com.samskivert.servlet.SiteIdentifier;
|
||||
import com.samskivert.servlet.SiteResourceLoader;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.apache.velocity.app.VelocityEngine;
|
||||
import org.apache.velocity.runtime.RuntimeServices;
|
||||
import org.apache.velocity.runtime.log.LogChute;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.servlet.Log.log;
|
||||
|
||||
/**
|
||||
* Handy Velocity-related routines.
|
||||
|
||||
@@ -7,7 +7,7 @@ package com.samskivert.xml;
|
||||
|
||||
import org.apache.commons.digester.Rule;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.xml.Log.log;
|
||||
|
||||
/**
|
||||
* Used to compare a file format version number in an XML file with the
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// samskivert library - useful routines for java programs
|
||||
// Copyright (C) 2001-2012 Michael Bayne, et al.
|
||||
// http://github.com/samskivert/samskivert/blob/master/COPYING
|
||||
|
||||
package com.samskivert.xml;
|
||||
|
||||
import com.samskivert.util.Logger;
|
||||
|
||||
/** Provides a log instance for this package. */
|
||||
class Log {
|
||||
|
||||
static final Logger log = Logger.getLogger("com.samskivert.xml");
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import javax.xml.parsers.ParserConfigurationException;
|
||||
import org.xml.sax.*;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
import static com.samskivert.Log.log;
|
||||
import static com.samskivert.xml.Log.log;
|
||||
|
||||
/**
|
||||
* The simple parser class provides an extensible object that is
|
||||
|
||||
Reference in New Issue
Block a user