costin 01/02/02 21:29:50 Modified: src/share/org/apache/tomcat/util/log Log.java Log: Small change in Log, to allow future improvements ( if needed ) without chaging the core. Log has the methods used by tomcat.core and modules - QueueLogger and DefaultLogger are simple implementations that are hidden behind Log. This allows to use Log.getLog() instead of new Log and moves the constants in Log, so only one class is used from core. Revision Changes Path 1.2 +29 -17 jakarta-tomcat/src/share/org/apache/tomcat/util/log/Log.java Index: Log.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/log/Log.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Log.java 2000/09/29 14:33:37 1.1 +++ Log.java 2001/02/03 05:29:50 1.2 @@ -81,12 +81,12 @@ * <p> * Usage: <pre> * class Foo { - * Log log = new Log("tc_log", "Foo"); // or... - * Log log = new Log("tc_log", this); // fills in "Foo" for you + * Log log = Log.getLog("tc_log", "Foo"); // or... + * Log log = Log.getLog("tc_log", this); // fills in "Foo" for you * ... * log.log("Something happened"); * ... - * log.log("Starting something", Logger.DEBUG); + * log.log("Starting something", Log.DEBUG); * ... * catch (IOException e) { * log.log("While doing something", e); @@ -94,23 +94,27 @@ * </pre> * * @author Alex Chaffee [[EMAIL PROTECTED]] + * @author Costin Manolache **/ public class Log { - + /** + * Verbosity level codes. + */ + public static final int FATAL = Integer.MIN_VALUE; + public static final int ERROR = 1; + public static final int WARNING = 2; + public static final int INFORMATION = 3; + public static final int DEBUG = 4; + + // name of the logger ( each logger has a unique name, // used as a key internally ) private String logname; + // string displayed at the beginning of each log line, // to identify the source private String prefix; - // The real logger object ( that knows to write to - // files, optimizations, etc) - private Logger logger; - - // Do we need that? - // private Log proxy; - // -------------------- Various constructors -------------------- public Log() { @@ -147,6 +151,17 @@ this.prefix = prefix; } + public static Log getLog( String channel, String prefix ) { + Log log=new Log( channel, prefix ); + return log; + } + + public static Log getLog( String channel, Object owner ) { + // XXX return singleton + Log log=new Log( channel, owner ); + return log; + } + // -------------------- Log messages. -------------------- // That all a client needs to know about logging ! // -------------------- @@ -188,9 +203,6 @@ msg = prefix + ": " + msg; } - // // activate proxy if present - // if (proxy != null) - // logger = proxy.getLogger(); // activate logname fetch if necessary if (logger == null) { @@ -208,11 +220,11 @@ // -------------------- Extra configuration stuff -------------------- + // The real logger object ( that knows to write to + // files, optimizations, etc) + private Logger logger; - public Logger getLogger() { - // if (proxy != null) - // logger = proxy.getLogger(); return logger; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]