From 862d181c2902c000d3c66d36db807ad438664c2e Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 2 Mar 2016 17:25:14 +0000 Subject: [PATCH] Refactor console logging --- source/net/filebot/Logging.java | 10 +++++----- source/net/filebot/Main.java | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/net/filebot/Logging.java b/source/net/filebot/Logging.java index 76e0fd1e..4f82b22b 100644 --- a/source/net/filebot/Logging.java +++ b/source/net/filebot/Logging.java @@ -10,7 +10,6 @@ import java.util.logging.Logger; import java.util.logging.SimpleFormatter; import java.util.regex.Pattern; -import net.filebot.cli.CmdlineInterface; import net.filebot.util.SystemProperty; import org.codehaus.groovy.runtime.StackTraceUtils; @@ -20,11 +19,12 @@ public final class Logging { private static final SystemProperty debugLevel = SystemProperty.of("net.filebot.logging.debug", Level::parse, Level.CONFIG); private static final SystemProperty anonymizePattern = SystemProperty.of("net.filebot.logging.anonymize", s -> Pattern.compile(s, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CHARACTER_CLASS | Pattern.MULTILINE)); - public static final Logger log = getConsoleLogger(CmdlineInterface.class, Level.ALL, new ConsoleFormatter(anonymizePattern.get())); - public static final Logger debug = getConsoleLogger(Logging.class, debugLevel.get(), new SimpleFormatter()); + public static final Logger global = getConsoleLogger("net.filebot", Level.ALL, new SimpleFormatter()); + public static final Logger log = getConsoleLogger("net.filebot.console", Level.ALL, new ConsoleFormatter(anonymizePattern.get())); + public static final Logger debug = getConsoleLogger("net.filebot.debug", debugLevel.get(), new ConsoleFormatter(anonymizePattern.get())); - public static Logger getConsoleLogger(Class cls, Level level, Formatter formatter) { - Logger log = Logger.getLogger(cls.getPackage().getName()); + public static Logger getConsoleLogger(String name, Level level, Formatter formatter) { + Logger log = Logger.getLogger(name); log.setLevel(level); log.setUseParentHandlers(false); log.addHandler(new ConsoleHandler(level, formatter)); diff --git a/source/net/filebot/Main.java b/source/net/filebot/Main.java index cd975935..cdaeeb56 100644 --- a/source/net/filebot/Main.java +++ b/source/net/filebot/Main.java @@ -486,7 +486,7 @@ public class Main { } if (cacheRevision != applicationRevision && applicationRevision > 0 && !isNewCache) { - debug.log(Level.WARNING, format("App version (r%d) does not match cache version (r%d): reset cache", applicationRevision, cacheRevision)); + Logger.getLogger(Main.class.getName()).log(Level.WARNING, format("App version (r%d) does not match cache version (r%d): reset cache", applicationRevision, cacheRevision)); // tag cache with new revision number isNewCache = true;