X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fmain%2FSonePlugin.java;h=ff72f860f35051ccfe47b8559dfacd165f216c93;hp=d86ed9f13de75ef741bc6a8c7eda2091336f7d8d;hb=69bde20c9d91feada988690d3a5a59bc3e086fce;hpb=b90a657060b67444ca5d8a403b9cca928ea4fbbd diff --git a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java index d86ed9f..ff72f86 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; @@ -61,7 +61,7 @@ import com.google.inject.spi.InjectionListener; import com.google.inject.spi.TypeEncounter; import com.google.inject.spi.TypeListener; -import freenet.client.async.DatabaseDisabledException; +import freenet.client.async.PersistenceDisabledException; import freenet.l10n.BaseL10n.LANGUAGE; import freenet.l10n.PluginL10n; import freenet.node.Node; @@ -86,33 +86,43 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr static { /* initialize logging. */ - Logging.setup("sone"); - Logging.addLoggingListener(new LoggingListener() { - + Logger soneLogger = getLogger("Sone"); + soneLogger.setUseParentHandlers(false); + 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() { + } }); } /** The version. */ - public static final Version VERSION = new Version(0, 8, 9); + public static final Version VERSION = new Version("rc1", 0, 9); + + /** The current year at time of release. */ + private static final int YEAR = 2015; /** 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; @@ -163,6 +173,10 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr return l10n; } + public static int getYear() { + return YEAR; + } + // // FREDPLUGIN METHODS // @@ -194,7 +208,7 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr try { oldConfiguration = new Configuration(new PluginStoreConfigurationBackend(pluginRespirator)); logger.log(Level.INFO, "Plugin store loaded."); - } catch (DatabaseDisabledException dde1) { + } catch (PersistenceDisabledException pde1) { logger.log(Level.SEVERE, "Could not load any configuration, using empty configuration!"); oldConfiguration = new Configuration(new MapConfigurationBackend()); } @@ -263,25 +277,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 +300,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(); } }