[slf4j-dev] svn commit: r1004 - slf4j/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line

ceki at slf4j.org ceki at slf4j.org
Tue Apr 29 16:59:24 CEST 2008


Author: ceki
Date: Tue Apr 29 16:59:24 2008
New Revision: 1004

Added:
   slf4j/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/JULRuleSet.java

Log:
- added minimal support for JUL to SLF4J migration

Added: slf4j/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/JULRuleSet.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/slf4j-migrator/src/main/java/org/slf4j/migrator/line/JULRuleSet.java	Tue Apr 29 16:59:24 2008
@@ -0,0 +1,53 @@
+package org.slf4j.migrator.line;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.regex.Pattern;
+
+/**
+ * This class represents java.util.logging (JUL) to SLF4J conversion rules
+ * 
+ * @author Jean-Noel Charpin
+ * @author Ceki Gulcu
+ */
+public class JULRuleSet implements RuleSet {
+
+  private ArrayList<ConversionRule> conversionRuleList;
+  
+  public JULRuleSet() {
+  
+    
+    SingleConversionRule crImport0 = new SingleConversionRule(Pattern
+        .compile("import\\s*+java.util.logging.Logger;"),
+        "import org.slf4j.Logger;",
+        "import org.slf4j.LoggerFactory;");
+    
+    SingleConversionRule crImport1 = new SingleConversionRule(Pattern
+        .compile("import\\s*+org.apache.log4j.LogManager;"),
+        "import org.slf4j.LoggerFactory;");
+
+    SingleConversionRule crImport2 = new SingleConversionRule(Pattern
+        .compile("import\\s*+java.util.logging.*;"),
+        "import org.slf4j.Logger;",
+        "import org.slf4j.LoggerFactory;");
+
+
+    SingleConversionRule crFactory0 = new SingleConversionRule(Pattern
+        .compile("Logger.getLogger\\("), "LoggerFactory.getLogger(");
+
+    SingleConversionRule crFactory1 = new SingleConversionRule(Pattern
+        .compile("LogManager.getLogger\\("), "LoggerFactory.getLogger(");
+
+    conversionRuleList = new ArrayList<ConversionRule>();
+    conversionRuleList.add(crImport0);
+    conversionRuleList.add(crImport1);
+    conversionRuleList.add(crImport2);
+    conversionRuleList.add(crFactory0);
+    conversionRuleList.add(crFactory1);
+  }
+
+  public Iterator<ConversionRule> iterator() {
+    return conversionRuleList.iterator();
+  }
+
+}



More information about the slf4j-dev mailing list