[slf4j-dev] svn commit: r1089 - in slf4j/trunk/slf4j-ext/src: main/java/org/slf4j test/java/org/slf4j

Jacob Kjome hoju at visi.com
Sun Aug 3 19:34:56 CEST 2008


Is this stuff supposed to work with JDK1.3+?  You're using varargs.  You really
need to validate this stuff by compiling under the lowest JDK you claim to support.

Jake

ceki at slf4j.org wrote:
> Author: ceki
> Date: Fri Aug  1 23:52:22 2008
> New Revision: 1089
> 
> Added:
>    slf4j/trunk/slf4j-ext/src/main/java/org/slf4j/LoggerX.java
>    slf4j/trunk/slf4j-ext/src/test/java/org/slf4j/LoggerXTest.java
> 
> Log:
> started work on bug 86, http://bugzilla.slf4j.org/show_bug.cgi?id=86
> 
> Added: slf4j/trunk/slf4j-ext/src/main/java/org/slf4j/LoggerX.java
> ==============================================================================
> --- (empty file)
> +++ slf4j/trunk/slf4j-ext/src/main/java/org/slf4j/LoggerX.java	Fri Aug  1 23:52:22 2008
> @@ -0,0 +1,61 @@
> +package org.slf4j;
> +
> +import org.slf4j.helpers.MessageFormatter;
> +import org.slf4j.spi.LocationAwareLogger;
> +
> +/**
> + * A utility that provides standard mechanisms for logging certain kinds of
> + * activities.
> + * 
> + * @author Ralph Goers
> + * @author Ceki Gulcu
> + */
> +public class LoggerX {
> +
> +  private static final String FQCN = LoggerX.class.getName();
> +  static Marker FLOW_MARKER = MarkerFactory.getMarker("FLOW");
> +  static Marker ENTRY_MARKER = MarkerFactory.getMarker("ENTER");
> +  static Marker EXIT_MARKER = MarkerFactory.getMarker("EXIT");
> +
> +  static Marker EXCEPTION_MARKER = MarkerFactory.getMarker("EXCEPTION");
> +  static Marker DIAG_MARKER = MarkerFactory.getMarker("DIAG");
> +
> +  static String ENTRY_MESSAGE_0 = "entry";
> +  static String ENTRY_MESSAGE_1 = "entry with params ({})";
> +  static String ENTRY_MESSAGE_2 = "entry with params ({}, {})";
> +  static String ENTRY_MESSAGE_3 = "entry with params ({}, {}, {})";
> +  static String ENTRY_MESSAGE_4 = "entry with params ({}, {}, {}, {})";
> +  static int ENTRY_MESSAGE_ARRAY_LEN = 5;
> +  static String[] ENTRY_MESSAGE_ARRAY = new String[ENTRY_MESSAGE_ARRAY_LEN];
> +  static {
> +    ENTRY_MARKER.add(FLOW_MARKER);
> +    EXIT_MARKER.add(FLOW_MARKER);
> +    ENTRY_MESSAGE_ARRAY[0] = ENTRY_MESSAGE_0;
> +    ENTRY_MESSAGE_ARRAY[1] = ENTRY_MESSAGE_1;
> +    ENTRY_MESSAGE_ARRAY[2] = ENTRY_MESSAGE_2;
> +    ENTRY_MESSAGE_ARRAY[3] = ENTRY_MESSAGE_3;
> +    ENTRY_MESSAGE_ARRAY[4] = ENTRY_MESSAGE_4;
> +  }
> +
> +  /**
> +   * Log entry to a method
> +   * 
> +   * @param logger
> +   *                the Logger to log with.
> +   */
> +  public static void entering(Logger logger, Object... argArray) {
> +    if (logger.isDebugEnabled(ENTRY_MARKER)
> +        && logger instanceof LocationAwareLogger) {
> +      String messagePattern = "";
> +      if(argArray.length <= ENTRY_MESSAGE_ARRAY_LEN) {
> +        messagePattern = ENTRY_MESSAGE_ARRAY[argArray.length];
> +      }
> +      
> +      String msg = MessageFormatter.arrayFormat(messagePattern, argArray);
> +      
> +      ((LocationAwareLogger) logger).log(ENTRY_MARKER, FQCN,
> +          LocationAwareLogger.ERROR_INT, msg, null);
> +    }
> +  }
> +
> +}
> 
> Added: slf4j/trunk/slf4j-ext/src/test/java/org/slf4j/LoggerXTest.java
> ==============================================================================
> --- (empty file)
> +++ slf4j/trunk/slf4j-ext/src/test/java/org/slf4j/LoggerXTest.java	Fri Aug  1 23:52:22 2008
> @@ -0,0 +1,12 @@
> +package org.slf4j;
> +
> +import junit.framework.TestCase;
> +
> +public class LoggerXTest extends TestCase {
> +
> +  Logger logger = LoggerFactory.getLogger(this.getClass());
> +  
> +  public void testSmoke() {
> +    LoggerX.entering(logger);
> +  }
> +}
> _______________________________________________
> dev mailing list
> dev at slf4j.org
> http://www.slf4j.org/mailman/listinfo/dev
> 
> 
> 



More information about the slf4j-dev mailing list