Re-enable Freenet logger.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 5 Nov 2010 23:55:39 +0000 (00:55 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 5 Nov 2010 23:55:39 +0000 (00:55 +0100)
src/main/java/net/pterodactylus/sone/main/SonePlugin.java

index f1b9ff3..7f6cf25 100644 (file)
@@ -20,6 +20,7 @@ package net.pterodactylus.sone.main;
 import java.io.File;
 import java.util.Collections;
 import java.util.logging.Level;
+import java.util.logging.LogRecord;
 import java.util.logging.Logger;
 
 import net.pterodactylus.sone.core.Core;
@@ -34,6 +35,7 @@ import net.pterodactylus.util.config.ConfigurationException;
 import net.pterodactylus.util.config.MapConfigurationBackend;
 import net.pterodactylus.util.config.XMLConfigurationBackend;
 import net.pterodactylus.util.logging.Logging;
+import net.pterodactylus.util.logging.LoggingListener;
 import net.pterodactylus.util.version.Version;
 import freenet.client.async.DatabaseDisabledException;
 import freenet.l10n.BaseL10n.LANGUAGE;
@@ -58,29 +60,25 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10
                /* initialize logging. */
                Logging.setup("sone");
                Logging.setupConsoleLogging();
-               /*
-                * Logging.addLoggingListener(new LoggingListener() {
-                * @Override public void logged(LogRecord logRecord) { Class<?>
-                * loggerClass = Logging.getLoggerClass(logRecord.getLoggerName()); int
-                * recordLevel = logRecord.getLevel().intValue(); if (recordLevel <
-                * Level.FINE.intValue()) { freenet.support.Logger.debug(loggerClass,
-                * String.format(logRecord.getMessage(), logRecord.getParameters()),
-                * logRecord.getThrown()); } else if (recordLevel <
-                * Level.INFO.intValue()) { freenet.support.Logger.minor(loggerClass,
-                * String.format(logRecord.getMessage(), logRecord.getParameters()),
-                * logRecord.getThrown()); } else if (recordLevel <
-                * Level.WARNING.intValue()) {
-                * freenet.support.Logger.normal(loggerClass,
-                * String.format(logRecord.getMessage(), logRecord.getParameters()),
-                * logRecord.getThrown()); } else if (recordLevel <
-                * Level.SEVERE.intValue()) {
-                * freenet.support.Logger.warning(loggerClass,
-                * String.format(logRecord.getMessage(), logRecord.getParameters()),
-                * logRecord.getThrown()); } else {
-                * freenet.support.Logger.error(loggerClass,
-                * String.format(logRecord.getMessage(), logRecord.getParameters()),
-                * logRecord.getThrown()); } } });
-                */
+               Logging.addLoggingListener(new LoggingListener() {
+
+                       @Override
+                       public void logged(LogRecord logRecord) {
+                               Class<?> loggerClass = Logging.getLoggerClass(logRecord.getLoggerName());
+                               int recordLevel = logRecord.getLevel().intValue();
+                               if (recordLevel < Level.FINE.intValue()) {
+                                       freenet.support.Logger.debug(loggerClass, String.format(logRecord.getMessage(), logRecord.getParameters()), logRecord.getThrown());
+                               } else if (recordLevel < Level.INFO.intValue()) {
+                                       freenet.support.Logger.minor(loggerClass, String.format(logRecord.getMessage(), logRecord.getParameters()), logRecord.getThrown());
+                               } else if (recordLevel < Level.WARNING.intValue()) {
+                                       freenet.support.Logger.normal(loggerClass, String.format(logRecord.getMessage(), logRecord.getParameters()), logRecord.getThrown());
+                               } else if (recordLevel < Level.SEVERE.intValue()) {
+                                       freenet.support.Logger.warning(loggerClass, String.format(logRecord.getMessage(), logRecord.getParameters()), logRecord.getThrown());
+                               } else {
+                                       freenet.support.Logger.error(loggerClass, String.format(logRecord.getMessage(), logRecord.getParameters()), logRecord.getThrown());
+                               }
+                       }
+               });
        }
 
        /** The version. */