Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@jakarta.apache.org Received: (qmail 35068 invoked by uid 500); 9 May 2001 06:50:59 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: ant-dev@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 35054 invoked from network); 9 May 2001 06:50:58 -0000 User-Agent: Microsoft-Entourage/9.0.1.3108 Date: Tue, 08 May 2001 23:51:01 -0700 Subject: Re: [Vote] Logging From: Jon Stevens To: "ant-dev@jakarta.apache.org" Message-ID: In-Reply-To: Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N on 5/8/01 11:26 PM, "Conor MacNeill" wrote: > In the .antrc file (or .antrc.xml), we should use introspection to configure > user preferred listeners/loggers. Ewwww....No! That is what interfaces are for. Guys, this stuff isn't difficult. Here is a stripped down example of what I'm talking about taken from Velocity... public interface LogSystem { public void logMessage(int level, String message); } public class LogKitLogSystem implements LogSystem { public void init() { // do setup and config stuff here. } /** * logs messages * * @param level severity level * @param message complete error message */ public void logMessage(int level, String message) { switch (level) { case LogSystem.WARN_ID: logger.warn( message ); break; case LogSystem.INFO_ID: logger.info(message); break; case LogSystem.DEBUG_ID: logger.debug(message); break; case LogSystem.ERROR_ID: logger.error(message); break; default: logger.info(message); break; } } } public class Log4JLogSystem implements LogSystem { // similar to LogKitSystem, but for Log4J } public class LogManager { public static LogSystem createLogSystem() { // create a LogKitSystem or Log4JLogSystem LogSystem instance = Class.forName ().newInstance instance.init(); } } Now, in Ant, you use LogManager to get an instance of the class you want and you are done. You can then write a static little wrapper around logMessage to do something like Log.debug() or hell, put it in the interface! Why is this so difficult for everyone to comprehend and why does Peter think that this is re-implementation of stuff?? -jon -- If you come from a Perl or PHP background, JSP is a way to take your pain to new levels. --Anonymous