From 43740d6a1dfc686ab54d0aebd4a5b1bce75b9ed6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 5 Oct 2014 22:11:59 +0200 Subject: [PATCH] =?utf8?q?Don=E2=80=99t=20use=20logging=20from=20utils=20p?= =?utf8?q?ackage.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../java/net/pterodactylus/sone/core/Core.java | 4 +- .../pterodactylus/sone/core/FreenetInterface.java | 4 +- .../net/pterodactylus/sone/core/ImageInserter.java | 4 +- .../sone/core/SoneDownloaderImpl.java | 4 +- .../net/pterodactylus/sone/core/SoneInserter.java | 4 +- .../net/pterodactylus/sone/core/SoneParser.java | 5 +- .../java/net/pterodactylus/sone/core/SoneUri.java | 5 +- .../net/pterodactylus/sone/core/UpdateChecker.java | 5 +- .../sone/core/WebOfTrustUpdaterImpl.java | 4 +- .../java/net/pterodactylus/sone/data/SoneImpl.java | 4 +- .../net/pterodactylus/sone/fcp/FcpInterface.java | 4 +- .../freenet/PluginStoreConfigurationBackend.java | 5 +- .../sone/freenet/wot/IdentityManagerImpl.java | 5 +- .../sone/freenet/wot/WebOfTrustConnector.java | 5 +- .../net/pterodactylus/sone/main/SonePlugin.java | 59 +++++++++------------- .../pterodactylus/sone/template/SoneAccessor.java | 4 +- .../pterodactylus/sone/text/SoneTextParser.java | 5 +- .../net/pterodactylus/sone/web/CreateSonePage.java | 5 +- .../java/net/pterodactylus/sone/web/LoginPage.java | 5 +- .../net/pterodactylus/sone/web/SearchPage.java | 4 +- .../pterodactylus/sone/web/UploadImagePage.java | 5 +- .../net/pterodactylus/sone/web/WebInterface.java | 4 +- .../net/pterodactylus/sone/web/ajax/JsonPage.java | 5 +- .../sone/web/page/FreenetTemplatePage.java | 5 +- 24 files changed, 82 insertions(+), 81 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index ab25618..14327bd 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.primitives.Longs.tryParse; import static java.lang.String.format; import static java.util.logging.Level.WARNING; +import static java.util.logging.Logger.getLogger; import java.util.Collection; import java.util.HashMap; @@ -90,7 +91,6 @@ import net.pterodactylus.sone.freenet.wot.event.OwnIdentityRemovedEvent; import net.pterodactylus.sone.main.SonePlugin; import net.pterodactylus.util.config.Configuration; import net.pterodactylus.util.config.ConfigurationException; -import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.service.AbstractService; import net.pterodactylus.util.thread.NamedThreadFactory; @@ -114,7 +114,7 @@ import com.google.inject.Singleton; public class Core extends AbstractService implements SoneProvider, PostProvider, PostReplyProvider { /** The logger. */ - private static final Logger logger = Logging.getLogger(Core.class); + private static final Logger logger = getLogger("Sone.Core"); /** The start time. */ private final long startupTime = System.currentTimeMillis(); diff --git a/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java b/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java index 9d1a7ed..dc0e3ea 100644 --- a/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java +++ b/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java @@ -20,6 +20,7 @@ package net.pterodactylus.sone.core; import static freenet.keys.USK.create; import static java.lang.String.format; import static java.util.logging.Level.WARNING; +import static java.util.logging.Logger.getLogger; import static net.pterodactylus.sone.freenet.Key.routingKey; import java.net.MalformedURLException; @@ -36,7 +37,6 @@ import net.pterodactylus.sone.core.event.ImageInsertStartedEvent; import net.pterodactylus.sone.data.Image; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.data.TemporaryImage; -import net.pterodactylus.util.logging.Logging; import com.db4o.ObjectContainer; @@ -75,7 +75,7 @@ import freenet.support.io.ArrayBucket; public class FreenetInterface { /** The logger. */ - private static final Logger logger = Logging.getLogger(FreenetInterface.class); + private static final Logger logger = getLogger("Sone.FreenetInterface"); /** The event bus. */ private final EventBus eventBus; diff --git a/src/main/java/net/pterodactylus/sone/core/ImageInserter.java b/src/main/java/net/pterodactylus/sone/core/ImageInserter.java index d0dc31a..25362a6 100644 --- a/src/main/java/net/pterodactylus/sone/core/ImageInserter.java +++ b/src/main/java/net/pterodactylus/sone/core/ImageInserter.java @@ -19,6 +19,7 @@ package net.pterodactylus.sone.core; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; +import static java.util.logging.Logger.getLogger; import java.util.Collections; import java.util.HashMap; @@ -29,7 +30,6 @@ import java.util.logging.Logger; import net.pterodactylus.sone.core.FreenetInterface.InsertToken; import net.pterodactylus.sone.data.Image; import net.pterodactylus.sone.data.TemporaryImage; -import net.pterodactylus.util.logging.Logging; import com.google.common.base.Function; @@ -44,7 +44,7 @@ import com.google.common.base.Function; public class ImageInserter { /** The logger. */ - private static final Logger logger = Logging.getLogger(ImageInserter.class); + private static final Logger logger = getLogger("Sone.Image.Inserter"); /** The freenet interface. */ private final FreenetInterface freenetInterface; diff --git a/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java b/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java index 3297a0d..3ae1371 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java @@ -20,6 +20,7 @@ package net.pterodactylus.sone.core; import static java.lang.String.format; import static java.lang.System.currentTimeMillis; import static java.util.concurrent.TimeUnit.DAYS; +import static java.util.logging.Logger.getLogger; import java.io.InputStream; import java.util.HashSet; @@ -31,7 +32,6 @@ import net.pterodactylus.sone.core.FreenetInterface.Fetched; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.data.Sone.SoneStatus; import net.pterodactylus.util.io.Closer; -import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.service.AbstractService; import freenet.client.FetchResult; @@ -53,7 +53,7 @@ import com.google.common.annotations.VisibleForTesting; public class SoneDownloaderImpl extends AbstractService implements SoneDownloader { /** The logger. */ - private static final Logger logger = Logging.getLogger(SoneDownloaderImpl.class); + private static final Logger logger = getLogger("Sone.Downloader"); /** The maximum protocol version. */ private static final int MAX_PROTOCOL_VERSION = 0; diff --git a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java index f544ef2..c38e495 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java @@ -19,6 +19,7 @@ package net.pterodactylus.sone.core; import static java.lang.String.format; import static java.lang.System.currentTimeMillis; +import static java.util.logging.Logger.getLogger; import static net.pterodactylus.sone.data.Album.NOT_EMPTY; import java.io.InputStream; @@ -45,7 +46,6 @@ import net.pterodactylus.sone.data.Sone.SoneStatus; import net.pterodactylus.sone.freenet.StringBucket; import net.pterodactylus.sone.main.SonePlugin; import net.pterodactylus.util.io.Closer; -import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.service.AbstractService; import net.pterodactylus.util.template.HtmlFilter; import net.pterodactylus.util.template.ReflectionAccessor; @@ -74,7 +74,7 @@ import freenet.keys.FreenetURI; public class SoneInserter extends AbstractService { /** The logger. */ - private static final Logger logger = Logging.getLogger(SoneInserter.class); + private static final Logger logger = getLogger("Sone.Inserter"); /** The insertion delay (in seconds). */ private static final AtomicInteger insertionDelay = new AtomicInteger(60); diff --git a/src/main/java/net/pterodactylus/sone/core/SoneParser.java b/src/main/java/net/pterodactylus/sone/core/SoneParser.java index 5dca54c..213be03 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneParser.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneParser.java @@ -1,5 +1,7 @@ package net.pterodactylus.sone.core; +import static java.util.logging.Logger.getLogger; + import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; @@ -20,7 +22,6 @@ import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.database.PostBuilder; import net.pterodactylus.sone.database.PostReplyBuilder; import net.pterodactylus.sone.database.SoneBuilder; -import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.number.Numbers; import net.pterodactylus.util.xml.SimpleXML; import net.pterodactylus.util.xml.XML; @@ -34,7 +35,7 @@ import org.w3c.dom.Document; */ public class SoneParser { - private static final Logger logger = Logging.getLogger(SoneParser.class); + private static final Logger logger = getLogger("Sone.Parser"); private static final int MAX_PROTOCOL_VERSION = 0; private final Core core; diff --git a/src/main/java/net/pterodactylus/sone/core/SoneUri.java b/src/main/java/net/pterodactylus/sone/core/SoneUri.java index 6c5bf16..ea84b39 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneUri.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneUri.java @@ -17,11 +17,12 @@ package net.pterodactylus.sone.core; +import static java.util.logging.Logger.getLogger; + import java.net.MalformedURLException; import java.util.logging.Level; import java.util.logging.Logger; -import net.pterodactylus.util.logging.Logging; import freenet.keys.FreenetURI; /** @@ -33,7 +34,7 @@ import freenet.keys.FreenetURI; public class SoneUri { /** The logger. */ - private static final Logger logger = Logging.getLogger(SoneUri.class); + private static final Logger logger = getLogger("Sone.Data"); /** * Generate a Sone URI from the given URI. diff --git a/src/main/java/net/pterodactylus/sone/core/UpdateChecker.java b/src/main/java/net/pterodactylus/sone/core/UpdateChecker.java index 307025a..0763c24 100644 --- a/src/main/java/net/pterodactylus/sone/core/UpdateChecker.java +++ b/src/main/java/net/pterodactylus/sone/core/UpdateChecker.java @@ -17,6 +17,8 @@ package net.pterodactylus.sone.core; +import static java.util.logging.Logger.getLogger; + import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -30,7 +32,6 @@ import net.pterodactylus.sone.core.FreenetInterface.Fetched; import net.pterodactylus.sone.core.event.UpdateFoundEvent; import net.pterodactylus.sone.main.SonePlugin; import net.pterodactylus.util.io.Closer; -import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.version.Version; import com.google.common.eventbus.EventBus; @@ -47,7 +48,7 @@ import freenet.support.api.Bucket; public class UpdateChecker { /** The logger. */ - private static final Logger logger = Logging.getLogger(UpdateChecker.class); + private static final Logger logger = getLogger("Sone.UpdateChecker"); /** The key of the Sone homepage. */ private static final String SONE_HOMEPAGE = "USK@nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI,DuQSUZiI~agF8c-6tjsFFGuZ8eICrzWCILB60nT8KKo,AQACAAE/sone/"; diff --git a/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdaterImpl.java b/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdaterImpl.java index 8a6d083..56bd8c9 100644 --- a/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdaterImpl.java +++ b/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdaterImpl.java @@ -18,6 +18,7 @@ package net.pterodactylus.sone.core; import static com.google.common.base.Preconditions.checkNotNull; +import static java.util.logging.Logger.getLogger; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; @@ -30,7 +31,6 @@ import net.pterodactylus.sone.freenet.wot.OwnIdentity; import net.pterodactylus.sone.freenet.wot.Trust; import net.pterodactylus.sone.freenet.wot.WebOfTrustConnector; import net.pterodactylus.sone.freenet.wot.WebOfTrustException; -import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.service.AbstractService; import com.google.common.annotations.VisibleForTesting; @@ -47,7 +47,7 @@ import com.google.inject.Singleton; public class WebOfTrustUpdaterImpl extends AbstractService implements WebOfTrustUpdater { /** The logger. */ - private static final Logger logger = Logging.getLogger(WebOfTrustUpdaterImpl.class); + private static final Logger logger = getLogger("Sone.WoT.Updater"); /** Stop job. */ @SuppressWarnings("synthetic-access") diff --git a/src/main/java/net/pterodactylus/sone/data/SoneImpl.java b/src/main/java/net/pterodactylus/sone/data/SoneImpl.java index 341746b..5678824 100644 --- a/src/main/java/net/pterodactylus/sone/data/SoneImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/SoneImpl.java @@ -19,6 +19,7 @@ package net.pterodactylus.sone.data; import static com.google.common.base.Preconditions.checkNotNull; import static java.lang.String.format; +import static java.util.logging.Logger.getLogger; import java.net.MalformedURLException; import java.util.ArrayList; @@ -33,7 +34,6 @@ import java.util.logging.Logger; import net.pterodactylus.sone.data.SoneOptions.DefaultSoneOptions; import net.pterodactylus.sone.freenet.wot.Identity; import net.pterodactylus.sone.freenet.wot.OwnIdentity; -import net.pterodactylus.util.logging.Logging; import freenet.keys.FreenetURI; @@ -50,7 +50,7 @@ import com.google.common.hash.Hashing; public class SoneImpl implements Sone { /** The logger. */ - private static final Logger logger = Logging.getLogger(SoneImpl.class); + private static final Logger logger = getLogger("Sone.Data"); /** The ID of this Sone. */ private final String id; diff --git a/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java b/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java index 918b15f..839930c 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java +++ b/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java @@ -18,6 +18,7 @@ package net.pterodactylus.sone.fcp; import static com.google.common.base.Preconditions.checkNotNull; +import static java.util.logging.Logger.getLogger; import java.util.Collections; import java.util.HashMap; @@ -34,7 +35,6 @@ import net.pterodactylus.sone.fcp.event.FullAccessRequiredChanged; import net.pterodactylus.sone.freenet.fcp.Command.AccessType; import net.pterodactylus.sone.freenet.fcp.Command.ErrorResponse; import net.pterodactylus.sone.freenet.fcp.Command.Response; -import net.pterodactylus.util.logging.Logging; import freenet.pluginmanager.FredPluginFCP; import freenet.pluginmanager.PluginNotFoundException; @@ -75,7 +75,7 @@ public class FcpInterface { } /** The logger. */ - private static final Logger logger = Logging.getLogger(FcpInterface.class); + private static final Logger logger = getLogger("Sone.External.Fcp"); /** Whether the FCP interface is currently active. */ private final AtomicBoolean active = new AtomicBoolean(); diff --git a/src/main/java/net/pterodactylus/sone/freenet/PluginStoreConfigurationBackend.java b/src/main/java/net/pterodactylus/sone/freenet/PluginStoreConfigurationBackend.java index 1e95389..0ed6dd5 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/PluginStoreConfigurationBackend.java +++ b/src/main/java/net/pterodactylus/sone/freenet/PluginStoreConfigurationBackend.java @@ -17,13 +17,14 @@ package net.pterodactylus.sone.freenet; +import static java.util.logging.Logger.getLogger; + import java.util.logging.Logger; import net.pterodactylus.util.config.AttributeNotFoundException; import net.pterodactylus.util.config.Configuration; import net.pterodactylus.util.config.ConfigurationException; import net.pterodactylus.util.config.ExtendedConfigurationBackend; -import net.pterodactylus.util.logging.Logging; import freenet.client.async.DatabaseDisabledException; import freenet.pluginmanager.PluginRespirator; import freenet.pluginmanager.PluginStore; @@ -37,7 +38,7 @@ public class PluginStoreConfigurationBackend implements ExtendedConfigurationBac /** The logger. */ @SuppressWarnings("unused") - private static final Logger logger = Logging.getLogger(PluginStoreConfigurationBackend.class); + private static final Logger logger = getLogger("Sone.Fred"); /** The plugin respirator. */ private final PluginRespirator pluginRespirator; diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManagerImpl.java b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManagerImpl.java index f568aa4..4c94749 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManagerImpl.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManagerImpl.java @@ -17,6 +17,8 @@ package net.pterodactylus.sone.freenet.wot; +import static java.util.logging.Logger.getLogger; + import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -26,7 +28,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import net.pterodactylus.sone.freenet.plugin.PluginException; -import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.service.AbstractService; import com.google.common.collect.Sets; @@ -49,7 +50,7 @@ import com.google.inject.Singleton; public class IdentityManagerImpl extends AbstractService implements IdentityManager { /** The logger. */ - private static final Logger logger = Logging.getLogger(IdentityManagerImpl.class); + private static final Logger logger = getLogger("Sone.Identities"); /** The event bus. */ private final EventBus eventBus; diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java b/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java index 4996c46..b0b6d42 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java @@ -17,6 +17,8 @@ package net.pterodactylus.sone.freenet.wot; +import static java.util.logging.Logger.getLogger; + import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -28,7 +30,6 @@ import java.util.logging.Logger; import net.pterodactylus.sone.freenet.plugin.PluginConnector; import net.pterodactylus.sone.freenet.plugin.PluginException; import net.pterodactylus.sone.freenet.plugin.event.ReceivedReplyEvent; -import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.number.Numbers; import com.google.common.base.Optional; @@ -49,7 +50,7 @@ import freenet.support.api.Bucket; public class WebOfTrustConnector { /** The logger. */ - private static final Logger logger = Logging.getLogger(WebOfTrustConnector.class); + private static final Logger logger = getLogger("Sone.WoT.Connector"); /** The name of the WoT plugin. */ private static final String WOT_PLUGIN_NAME = "plugins.WebOfTrust.WebOfTrust"; diff --git a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java index d86ed9f..957103b 100644 --- a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java +++ b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java @@ -18,8 +18,10 @@ package net.pterodactylus.sone.main; import static com.google.common.base.Optional.of; +import static java.util.logging.Logger.getLogger; import java.io.File; +import java.util.logging.Handler; import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; @@ -45,8 +47,6 @@ import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.util.config.Configuration; import net.pterodactylus.util.config.ConfigurationException; import net.pterodactylus.util.config.MapConfigurationBackend; -import net.pterodactylus.util.logging.Logging; -import net.pterodactylus.util.logging.LoggingListener; import net.pterodactylus.util.version.Version; import com.google.common.base.Optional; @@ -86,25 +86,31 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr static { /* initialize logging. */ - Logging.setup("sone"); - Logging.addLoggingListener(new LoggingListener() { - + Logger soneLogger = getLogger("Sone"); + soneLogger.addHandler(new Handler() { @Override - public void logged(LogRecord logRecord) { - Class loggerClass = Logging.getLoggerClass(logRecord.getLoggerName()); + public void publish(LogRecord logRecord) { int recordLevel = logRecord.getLevel().intValue(); if (recordLevel < Level.FINE.intValue()) { - freenet.support.Logger.debug(loggerClass, logRecord.getMessage(), logRecord.getThrown()); + freenet.support.Logger.debug(logRecord.getLoggerName(), logRecord.getMessage(), logRecord.getThrown()); } else if (recordLevel < Level.INFO.intValue()) { - freenet.support.Logger.minor(loggerClass, logRecord.getMessage(), logRecord.getThrown()); + freenet.support.Logger.minor(logRecord.getLoggerName(), logRecord.getMessage(), logRecord.getThrown()); } else if (recordLevel < Level.WARNING.intValue()) { - freenet.support.Logger.normal(loggerClass, logRecord.getMessage(), logRecord.getThrown()); + freenet.support.Logger.normal(logRecord.getLoggerName(), logRecord.getMessage(), logRecord.getThrown()); } else if (recordLevel < Level.SEVERE.intValue()) { - freenet.support.Logger.warning(loggerClass, logRecord.getMessage(), logRecord.getThrown()); + freenet.support.Logger.warning(logRecord.getLoggerName(), logRecord.getMessage(), logRecord.getThrown()); } else { - freenet.support.Logger.error(loggerClass, logRecord.getMessage(), logRecord.getThrown()); + freenet.support.Logger.error(logRecord.getLoggerName(), logRecord.getMessage(), logRecord.getThrown()); } } + + @Override + public void flush() { + } + + @Override + public void close() { + } }); } @@ -112,7 +118,7 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr public static final Version VERSION = new Version(0, 8, 9); /** The logger. */ - private static final Logger logger = Logging.getLogger(SonePlugin.class); + private static final Logger logger = getLogger("Sone.Plugin"); /** The plugin respirator. */ private PluginRespirator pluginRespirator; @@ -263,25 +269,11 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr /* create the web interface. */ webInterface = injector.getInstance(WebInterface.class); - boolean startupFailed = true; - try { - - /* start core! */ - core.start(); - webInterface.start(); - webInterface.setFirstStart(firstStart); - webInterface.setNewConfig(newConfig); - startupFailed = false; - } finally { - if (startupFailed) { - /* - * we let the exception bubble up but shut the logging down so - * that the logfile is not swamped by the installed logging - * handlers of the failed instances. - */ - Logging.shutdown(); - } - } + /* start core! */ + core.start(); + webInterface.start(); + webInterface.setFirstStart(firstStart); + webInterface.setNewConfig(newConfig); } /** @@ -300,9 +292,6 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr webOfTrustConnector.stop(); } catch (Throwable t1) { logger.log(Level.SEVERE, "Error while shutting down!", t1); - } finally { - /* shutdown logger. */ - Logging.shutdown(); } } diff --git a/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java b/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java index 92be8e0..711332a 100644 --- a/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java @@ -19,6 +19,7 @@ package net.pterodactylus.sone.template; import static com.google.common.collect.FluentIterable.from; import static java.util.Arrays.asList; +import static java.util.logging.Logger.getLogger; import static net.pterodactylus.sone.data.Album.FLATTENER; import static net.pterodactylus.sone.data.Album.IMAGES; @@ -33,7 +34,6 @@ import net.pterodactylus.sone.freenet.wot.OwnIdentity; import net.pterodactylus.sone.freenet.wot.Trust; import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.sone.web.ajax.GetTimesAjaxPage; -import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.template.Accessor; import net.pterodactylus.util.template.ReflectionAccessor; import net.pterodactylus.util.template.TemplateContext; @@ -58,7 +58,7 @@ import net.pterodactylus.util.template.TemplateContext; public class SoneAccessor extends ReflectionAccessor { /** The logger. */ - private static final Logger logger = Logging.getLogger(SoneAccessor.class); + private static final Logger logger = getLogger("Sone.Data"); /** The core. */ private final Core core; diff --git a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java index ab62fad..9a1882e 100644 --- a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java +++ b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java @@ -17,6 +17,8 @@ package net.pterodactylus.sone.text; +import static java.util.logging.Logger.getLogger; + import java.io.BufferedReader; import java.io.IOException; import java.io.Reader; @@ -33,7 +35,6 @@ import net.pterodactylus.sone.data.impl.IdOnlySone; import net.pterodactylus.sone.database.PostProvider; import net.pterodactylus.sone.database.SoneProvider; import net.pterodactylus.util.io.Closer; -import net.pterodactylus.util.logging.Logging; import com.google.common.base.Optional; @@ -47,7 +48,7 @@ import freenet.keys.FreenetURI; public class SoneTextParser implements Parser { /** The logger. */ - private static final Logger logger = Logging.getLogger(SoneTextParser.class); + private static final Logger logger = getLogger("Sone.Data.Parser"); /** Pattern to detect whitespace. */ private static final Pattern whitespacePattern = Pattern.compile("[\\u000a\u0020\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u200c\u200d\u202f\u205f\u2060\u2800\u3000]"); diff --git a/src/main/java/net/pterodactylus/sone/web/CreateSonePage.java b/src/main/java/net/pterodactylus/sone/web/CreateSonePage.java index fe8c32e..b2d4578 100644 --- a/src/main/java/net/pterodactylus/sone/web/CreateSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/CreateSonePage.java @@ -17,6 +17,8 @@ package net.pterodactylus.sone.web; +import static java.util.logging.Logger.getLogger; + import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -29,7 +31,6 @@ import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.freenet.wot.OwnIdentity; import net.pterodactylus.sone.web.page.FreenetRequest; -import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; import net.pterodactylus.util.web.Method; @@ -43,7 +44,7 @@ import freenet.clients.http.ToadletContext; public class CreateSonePage extends SoneTemplatePage { /** The logger. */ - private static final Logger logger = Logging.getLogger(CreateSonePage.class); + private static final Logger logger = getLogger("Sone.Web.CreateSone"); /** * Creates a new “create Sone” page. diff --git a/src/main/java/net/pterodactylus/sone/web/LoginPage.java b/src/main/java/net/pterodactylus/sone/web/LoginPage.java index a1c71b1..58e33a1 100644 --- a/src/main/java/net/pterodactylus/sone/web/LoginPage.java +++ b/src/main/java/net/pterodactylus/sone/web/LoginPage.java @@ -17,6 +17,8 @@ package net.pterodactylus.sone.web; +import static java.util.logging.Logger.getLogger; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -25,7 +27,6 @@ import java.util.logging.Logger; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.freenet.wot.OwnIdentity; import net.pterodactylus.sone.web.page.FreenetRequest; -import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; import net.pterodactylus.util.web.Method; @@ -40,7 +41,7 @@ public class LoginPage extends SoneTemplatePage { /** The logger. */ @SuppressWarnings("unused") - private static final Logger logger = Logging.getLogger(LoginPage.class); + private static final Logger logger = getLogger("Sone.Web.Login"); /** * Creates a new login page. diff --git a/src/main/java/net/pterodactylus/sone/web/SearchPage.java b/src/main/java/net/pterodactylus/sone/web/SearchPage.java index 7ae0e43..3efba95 100644 --- a/src/main/java/net/pterodactylus/sone/web/SearchPage.java +++ b/src/main/java/net/pterodactylus/sone/web/SearchPage.java @@ -19,6 +19,7 @@ package net.pterodactylus.sone.web; import static com.google.common.base.Optional.fromNullable; import static com.google.common.primitives.Ints.tryParse; +import static java.util.logging.Logger.getLogger; import java.util.ArrayList; import java.util.Collection; @@ -39,7 +40,6 @@ import net.pterodactylus.sone.data.Reply; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.collection.Pagination; -import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; import net.pterodactylus.util.text.StringEscaper; @@ -64,7 +64,7 @@ import com.google.common.collect.Ordering; public class SearchPage extends SoneTemplatePage { /** The logger. */ - private static final Logger logger = Logging.getLogger(SearchPage.class); + private static final Logger logger = getLogger("Sone.Web.Search"); /** Short-term cache. */ private final LoadingCache, Set>> hitCache = CacheBuilder.newBuilder().expireAfterWrite(5, TimeUnit.MINUTES).build(new CacheLoader, Set>>() { diff --git a/src/main/java/net/pterodactylus/sone/web/UploadImagePage.java b/src/main/java/net/pterodactylus/sone/web/UploadImagePage.java index b5e8d51..8aab02e 100644 --- a/src/main/java/net/pterodactylus/sone/web/UploadImagePage.java +++ b/src/main/java/net/pterodactylus/sone/web/UploadImagePage.java @@ -17,6 +17,8 @@ package net.pterodactylus.sone.web; +import static java.util.logging.Logger.getLogger; + import java.awt.Image; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -37,7 +39,6 @@ import net.pterodactylus.sone.data.TemporaryImage; import net.pterodactylus.sone.text.TextFilter; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.io.Closer; -import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; import net.pterodactylus.util.web.Method; @@ -55,7 +56,7 @@ import freenet.support.api.HTTPUploadedFile; public class UploadImagePage extends SoneTemplatePage { /** The logger. */ - private static final Logger logger = Logging.getLogger(UploadImagePage.class); + private static final Logger logger = getLogger("Sone.Web.UploadImage"); /** * Creates a new “upload image” page. diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index dc48e45..9fe5bba 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -17,6 +17,7 @@ package net.pterodactylus.sone.web; +import static java.util.logging.Logger.getLogger; import static net.pterodactylus.util.template.TemplateParser.parse; import java.io.IOException; @@ -128,7 +129,6 @@ import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.sone.web.page.PageToadlet; import net.pterodactylus.sone.web.page.PageToadletFactory; import net.pterodactylus.util.io.Closer; -import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.notify.Notification; import net.pterodactylus.util.notify.NotificationManager; import net.pterodactylus.util.notify.TemplateNotification; @@ -173,7 +173,7 @@ import freenet.support.api.HTTPRequest; public class WebInterface { /** The logger. */ - private static final Logger logger = Logging.getLogger(WebInterface.class); + private static final Logger logger = getLogger("Sone.Web.Main"); /** The notification manager. */ private final NotificationManager notificationManager = new NotificationManager(); diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java index 3c7f587..6d6d92a 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java @@ -17,6 +17,8 @@ package net.pterodactylus.sone.web.ajax; +import static java.util.logging.Logger.getLogger; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; @@ -30,7 +32,6 @@ import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.sone.web.page.FreenetPage; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.io.Closer; -import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.web.Page; import net.pterodactylus.util.web.Response; @@ -47,7 +48,7 @@ import freenet.clients.http.ToadletContext; public abstract class JsonPage implements FreenetPage { /** The logger. */ - private static final Logger logger = Logging.getLogger(JsonPage.class); + private static final Logger logger = getLogger("Sone.Web.Ajax"); /** The JSON serializer. */ private static final ObjectMapper objectMapper = new ObjectMapper(); diff --git a/src/main/java/net/pterodactylus/sone/web/page/FreenetTemplatePage.java b/src/main/java/net/pterodactylus/sone/web/page/FreenetTemplatePage.java index ce3fa2e..40e19b1 100644 --- a/src/main/java/net/pterodactylus/sone/web/page/FreenetTemplatePage.java +++ b/src/main/java/net/pterodactylus/sone/web/page/FreenetTemplatePage.java @@ -17,6 +17,8 @@ package net.pterodactylus.sone.web.page; +import static java.util.logging.Logger.getLogger; + import java.io.IOException; import java.io.StringWriter; import java.net.URI; @@ -28,7 +30,6 @@ import java.util.Map.Entry; import java.util.logging.Level; import java.util.logging.Logger; -import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; import net.pterodactylus.util.template.TemplateContextFactory; @@ -51,7 +52,7 @@ import freenet.support.HTMLNode; public class FreenetTemplatePage implements FreenetPage, LinkEnabledCallback { /** The logger. */ - private static final Logger logger = Logging.getLogger(FreenetTemplatePage.class); + private static final Logger logger = getLogger("Sone.Web.Freenet"); /** The path of the page. */ private final String path; -- 2.7.4