From ccc764b2b55d6c44026ba4a823d0ca6b61e96321 Mon Sep 17 00:00:00 2001 From: Patrick Gotthard Date: Mon, 14 Apr 2014 19:15:34 +0200 Subject: [PATCH] Migrated logging to SLF4J --- pom.xml | 5 ++++ .../feed/synd/impl/ConverterForOPML10.java | 21 ++++++++++++----- .../sun/syndication/io/impl/OPML10Parser.java | 23 ++++++++++--------- src/test/resources/logback-test.xml | 13 +++++++++++ 4 files changed, 45 insertions(+), 17 deletions(-) create mode 100644 src/test/resources/logback-test.xml diff --git a/pom.xml b/pom.xml index 60d6320..f634fd4 100644 --- a/pom.xml +++ b/pom.xml @@ -52,6 +52,11 @@ com.rometools rome + + ch.qos.logback + logback-classic + test + junit junit diff --git a/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForOPML10.java b/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForOPML10.java index 6bbcdc5..073bbcf 100644 --- a/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForOPML10.java +++ b/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForOPML10.java @@ -22,7 +22,9 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Stack; -import java.util.logging.Logger; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.sun.syndication.feed.WireFeed; import com.sun.syndication.feed.opml.Attribute; @@ -46,7 +48,9 @@ import com.sun.syndication.feed.synd.SyndPersonImpl; * @author cooper */ public class ConverterForOPML10 implements Converter { - private static final Logger LOG = Logger.getLogger(ConverterForOPML10.class.getName().toString()); + + private static final Logger LOG = LoggerFactory.getLogger(ConverterForOPML10.class); + public static final String URI_TREE = "urn:rome.tree"; public static final String URI_ATTRIBUTE = "urn:rome.attribute#"; @@ -73,7 +77,8 @@ public class ConverterForOPML10 implements Converter { *

* * @param feed real feed to copy/convert. - * @param syndFeed the SyndFeedImpl that will contain the copied/converted values of the real feed. + * @param syndFeed the SyndFeedImpl that will contain the copied/converted values of the real + * feed. */ @Override public void copyInto(final WireFeed feed, final SyndFeed syndFeed) { @@ -200,8 +205,12 @@ public class ConverterForOPML10 implements Converter { final List entries = Collections.synchronizedList(syndFeed.getEntries()); final HashMap entriesByNode = new HashMap(); - final ArrayList doAfterPass = new ArrayList(); // this will hold entries that we can't parent the first time. - final ArrayList root = new ArrayList(); // this holds root level outlines; + + // this will hold entries that we can't parent the first time. + final ArrayList doAfterPass = new ArrayList(); + + // this holds root level outlines; + final ArrayList root = new ArrayList(); for (int i = 0; i < entries.size(); i++) { final SyndEntry entry = entries.get(i); @@ -294,7 +303,7 @@ public class ConverterForOPML10 implements Converter { if (parent == null) { root.add(o.outline); - LOG.warning("Unable to find parent node :" + o.parent); + LOG.warn("Unable to find parent node: {}", o.parent); } else { parent.getChildren().add(o.outline); } diff --git a/src/main/java/com/sun/syndication/io/impl/OPML10Parser.java b/src/main/java/com/sun/syndication/io/impl/OPML10Parser.java index 34b4a7f..a3ff729 100644 --- a/src/main/java/com/sun/syndication/io/impl/OPML10Parser.java +++ b/src/main/java/com/sun/syndication/io/impl/OPML10Parser.java @@ -21,11 +21,11 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.StringTokenizer; -import java.util.logging.Level; -import java.util.logging.Logger; import org.jdom2.Document; import org.jdom2.Element; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.sun.syndication.feed.WireFeed; import com.sun.syndication.feed.opml.Attribute; @@ -39,7 +39,8 @@ import com.sun.syndication.io.WireFeedParser; * @author Robert "kebernet" Cooper */ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser { - private static Logger LOG = Logger.getLogger(OPML10Parser.class.getName()); + + private static Logger LOG = LoggerFactory.getLogger(OPML10Parser.class); /** Creates a new instance of Opml10Parser */ public OPML10Parser() { @@ -108,7 +109,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser { try { opml.setWindowBottom(readInteger(head.getChildText("windowBottom"))); } catch (final NumberFormatException nfe) { - LOG.log(Level.WARNING, "Unable to parse windowBottom", nfe); + LOG.warn("Unable to parse windowBottom", nfe); if (validate) { throw new FeedException("Unable to parse windowBottom", nfe); @@ -118,13 +119,13 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser { try { opml.setWindowLeft(readInteger(head.getChildText("windowLeft"))); } catch (final NumberFormatException nfe) { - LOG.log(Level.WARNING, "Unable to parse windowLeft", nfe); + LOG.warn("Unable to parse windowLeft", nfe); } try { opml.setWindowRight(readInteger(head.getChildText("windowRight"))); } catch (final NumberFormatException nfe) { - LOG.log(Level.WARNING, "Unable to parse windowRight", nfe); + LOG.warn("Unable to parse windowRight", nfe); if (validate) { throw new FeedException("Unable to parse windowRight", nfe); @@ -134,7 +135,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser { try { opml.setWindowLeft(readInteger(head.getChildText("windowLeft"))); } catch (final NumberFormatException nfe) { - LOG.log(Level.WARNING, "Unable to parse windowLeft", nfe); + LOG.warn("Unable to parse windowLeft", nfe); if (validate) { throw new FeedException("Unable to parse windowLeft", nfe); @@ -144,7 +145,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser { try { opml.setWindowTop(readInteger(head.getChildText("windowTop"))); } catch (final NumberFormatException nfe) { - LOG.log(Level.WARNING, "Unable to parse windowTop", nfe); + LOG.warn("Unable to parse windowTop", nfe); if (validate) { throw new FeedException("Unable to parse windowTop", nfe); @@ -154,7 +155,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser { try { opml.setExpansionState(readIntArray(head.getChildText("expansionState"))); } catch (final NumberFormatException nfe) { - LOG.log(Level.WARNING, "Unable to parse expansionState", nfe); + LOG.warn("Unable to parse expansionState", nfe); if (validate) { throw new FeedException("Unable to parse expansionState", nfe); @@ -194,7 +195,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser { try { outline.setBreakpoint(readBoolean(e.getAttributeValue("isBreakpoint"))); } catch (final Exception ex) { - LOG.log(Level.WARNING, "Unable to parse isBreakpoint value", ex); + LOG.warn("Unable to parse isBreakpoint value", ex); if (validate) { throw new FeedException("Unable to parse isBreakpoint value", ex); @@ -204,7 +205,7 @@ public class OPML10Parser extends BaseWireFeedParser implements WireFeedParser { try { outline.setComment(readBoolean(e.getAttributeValue("isComment"))); } catch (final Exception ex) { - LOG.log(Level.WARNING, "Unable to parse isComment value", ex); + LOG.warn("Unable to parse isComment value", ex); if (validate) { throw new FeedException("Unable to parse isComment value", ex); diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml new file mode 100644 index 0000000..44dea42 --- /dev/null +++ b/src/test/resources/logback-test.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n + + + + + + + + \ No newline at end of file