From 6d5f05cf02e12d81beb2ce121f044b143ffcee30 Mon Sep 17 00:00:00 2001 From: Patrick Gotthard Date: Mon, 14 Apr 2014 19:11:19 +0200 Subject: [PATCH] Migrated logging to SLF4J --- .../java/org/rometools/certiorem/example/NotifyTest.java | 9 +++++---- .../org/rometools/certiorem/example/ServerModule.java | 9 +++++++-- .../java/org/rometools/certiorem/example/SubTest.java | 6 +++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/rometools/certiorem/example/NotifyTest.java b/src/main/java/org/rometools/certiorem/example/NotifyTest.java index f829e31..e021eb4 100644 --- a/src/main/java/org/rometools/certiorem/example/NotifyTest.java +++ b/src/main/java/org/rometools/certiorem/example/NotifyTest.java @@ -5,9 +5,6 @@ package org.rometools.certiorem.example; -import java.util.logging.Level; -import java.util.logging.Logger; - import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; @@ -15,6 +12,8 @@ import javax.servlet.http.HttpServletResponse; import org.rometools.certiorem.pub.NotificationException; import org.rometools.certiorem.pub.Publisher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.inject.Singleton; @@ -27,13 +26,15 @@ public class NotifyTest extends HttpServlet { private static final long serialVersionUID = 1L; + private static final Logger LOG = LoggerFactory.getLogger(NotifyTest.class); + @Override public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException { final Publisher pub = new Publisher(); try { pub.sendUpdateNotification("http://localhost/webapp/hub", "http://localhost/webapp/research-atom.xml"); } catch (final NotificationException ex) { - Logger.getLogger(NotifyTest.class.getName()).log(Level.SEVERE, null, ex); + LOG.error(null, ex); throw new ServletException(ex); } } diff --git a/src/main/java/org/rometools/certiorem/example/ServerModule.java b/src/main/java/org/rometools/certiorem/example/ServerModule.java index 6ec8c45..4505022 100644 --- a/src/main/java/org/rometools/certiorem/example/ServerModule.java +++ b/src/main/java/org/rometools/certiorem/example/ServerModule.java @@ -14,6 +14,8 @@ import org.rometools.certiorem.sub.request.AsyncRequester; import org.rometools.fetcher.FeedFetcher; import org.rometools.fetcher.impl.HashMapFeedInfoCache; import org.rometools.fetcher.impl.HttpURLFeedFetcher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.inject.AbstractModule; import com.google.inject.Guice; @@ -24,10 +26,13 @@ import com.google.inject.servlet.GuiceServletContextListener; import com.google.inject.servlet.ServletModule; /** - * + * * @author robert.cooper */ public class ServerModule extends GuiceServletContextListener { + + private static final Logger LOG = LoggerFactory.getLogger(ServerModule.class); + @Override protected Injector getInjector() { return Guice.createInjector(new AbstractModule() { @@ -47,7 +52,7 @@ public class ServerModule extends GuiceServletContextListener { @Provides @Singleton public Subscriptions buildSubs() { - System.out.println("buildSubs"); + LOG.debug("buildSubs"); final Subscriptions subs = new Subscriptions(new HashMapFeedInfoCache(), new AsyncRequester(), "http://localhost/webapp/subscriptions/", new InMemorySubDAO()); diff --git a/src/main/java/org/rometools/certiorem/example/SubTest.java b/src/main/java/org/rometools/certiorem/example/SubTest.java index 6a43249..5ccb363 100644 --- a/src/main/java/org/rometools/certiorem/example/SubTest.java +++ b/src/main/java/org/rometools/certiorem/example/SubTest.java @@ -13,6 +13,8 @@ import org.rometools.certiorem.sub.Subscriptions; import org.rometools.certiorem.sub.data.Subscription; import org.rometools.certiorem.sub.data.SubscriptionCallback; import org.rometools.fetcher.impl.SyndFeedInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -24,6 +26,8 @@ import com.google.inject.Singleton; @Singleton public class SubTest extends HttpServlet { + private static final Logger LOG = LoggerFactory.getLogger(SubTest.class); + private static final long serialVersionUID = 1L; private final Subscriptions subs; @@ -44,7 +48,7 @@ public class SubTest extends HttpServlet { @Override public void onSubscribe(final Subscription subscribed) { - System.out.println("Subscribed " + subscribed.getId() + " " + subscribed.getSourceUrl()); + LOG.debug("Subscribed {} {}", subscribed.getId(), subscribed.getSourceUrl()); } @Override