From d699da6a742dfa93191d921027223c527f02ddb4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 27 Sep 2011 06:55:06 +0200 Subject: [PATCH] Stop logging to console. --- .../net/pterodactylus/wotns/main/WoTNSPlugin.java | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/wotns/main/WoTNSPlugin.java b/src/main/java/net/pterodactylus/wotns/main/WoTNSPlugin.java index 83639c2..83be95a 100644 --- a/src/main/java/net/pterodactylus/wotns/main/WoTNSPlugin.java +++ b/src/main/java/net/pterodactylus/wotns/main/WoTNSPlugin.java @@ -17,7 +17,11 @@ package net.pterodactylus.wotns.main; +import java.util.logging.Level; +import java.util.logging.LogRecord; + import net.pterodactylus.util.logging.Logging; +import net.pterodactylus.util.logging.LoggingListener; import net.pterodactylus.util.version.Version; import net.pterodactylus.wotns.freenet.plugin.PluginConnector; import net.pterodactylus.wotns.freenet.wot.IdentityManager; @@ -43,7 +47,25 @@ public class WoTNSPlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL1 static { Logging.setup("WoTNS"); - 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()); + } + } + }); } /** The current version of the plugin. */ -- 2.7.4