Browse Source

More control over logger settings.

pull/170/head
weisj 5 years ago
parent
commit
f424f479b6
  1. 3
      core/src/main/java/com/github/weisj/darklaf/DarkLaf.java
  2. 26
      core/src/main/java/com/github/weisj/darklaf/LafManager.java
  3. 3
      core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java
  4. 3
      core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java
  5. 3
      core/src/main/java/com/github/weisj/darklaf/task/PropertyFontMapper.java
  6. 3
      core/src/main/java/org/pbjar/jxlayer/plaf/ext/TransformUI.java
  7. 3
      core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformRPMImpl.java
  8. 3
      core/src/main/java/org/pbjar/jxlayer/repaint/RepaintManagerUtils.java
  9. 33
      core/src/main/resources/com/github/weisj/darklaf/log/logging.properties
  10. 3
      macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSLibrary.java
  11. 4
      macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSPreferenceMonitor.java
  12. 3
      property-loader/src/main/java/com/github/weisj/darklaf/PropertyLoader.java
  13. 3
      property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkSVGIcon.java
  14. 3
      property-loader/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java
  15. 3
      property-loader/src/main/java/com/github/weisj/darklaf/icons/IconLoader.java
  16. 4
      property-loader/src/main/java/com/github/weisj/darklaf/icons/LazyIcon.java
  17. 1
      theme/build.gradle.kts
  18. 3
      theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java
  19. 29
      utils/src/main/java/com/github/weisj/darklaf/log/DarkLogHandler.java
  20. 118
      utils/src/main/java/com/github/weisj/darklaf/log/LogFormatter.java
  21. 54
      utils/src/main/java/com/github/weisj/darklaf/util/LogUtil.java
  22. 3
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsLibrary.java
  23. 4
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsPreferenceMonitor.java

3
core/src/main/java/com/github/weisj/darklaf/DarkLaf.java

@ -36,6 +36,7 @@ import com.github.weisj.darklaf.task.*;
import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.ui.DarkPopupFactory;
import com.github.weisj.darklaf.ui.popupmenu.MouseGrabberUtil;
import com.github.weisj.darklaf.util.LogUtil;
import com.github.weisj.darklaf.util.SystemInfo;
/**
@ -45,7 +46,7 @@ public class DarkLaf extends BasicLookAndFeel {
public static final String SYSTEM_PROPERTY_PREFIX = "darklaf.";
public static final String ALLOW_NATIVE_CODE_FLAG = DarkLaf.SYSTEM_PROPERTY_PREFIX + "allowNativeCode";
private static final Logger LOGGER = Logger.getLogger(DarkLaf.class.getName());
private static final Logger LOGGER = LogUtil.getLogger(DarkLaf.class);
/*
* All tasks for initializing the ui defaults in order of execution.
*/

26
core/src/main/java/com/github/weisj/darklaf/LafManager.java

@ -25,20 +25,14 @@
package com.github.weisj.darklaf;
import java.awt.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import javax.swing.*;
import com.github.weisj.darklaf.log.LogHandler;
import com.github.weisj.darklaf.platform.DecorationsHandler;
import com.github.weisj.darklaf.platform.ThemePreferencesHandler;
import com.github.weisj.darklaf.settings.ThemeSettings;
@ -49,6 +43,7 @@ import com.github.weisj.darklaf.theme.event.*;
import com.github.weisj.darklaf.theme.info.DefaultThemeProvider;
import com.github.weisj.darklaf.theme.info.PreferredThemeStyle;
import com.github.weisj.darklaf.theme.info.ThemeProvider;
import com.github.weisj.darklaf.util.LogUtil;
/**
* Manager for the Look and Feel.
@ -65,7 +60,6 @@ public final class LafManager {
private static final ThemeEventSupport<ThemeChangeEvent, ThemeChangeListener> eventSupport = new ThemeEventSupport<>();
static {
setupLogging();
setLogLevel(Level.INFO);
registerTheme(new IntelliJTheme(),
new DarculaTheme(),
@ -76,18 +70,6 @@ public final class LafManager {
new HighContrastDarkTheme());
}
private static void setupLogging() {
try (InputStream inputStream = DarkLaf.class.getResourceAsStream("log/logging.properties")) {
if (inputStream != null) {
Logger.getGlobal().fine("Loading logging configuration.");
LogManager.getLogManager().readConfiguration(inputStream);
}
Logger.getGlobal().fine(() -> "Loaded logging config" + LogManager.getLogManager().toString());
} catch (IOException e) {
Logger.getGlobal().log(Level.SEVERE, "init logging system", e);
}
}
/**
* Enable logging for the Look and Feel.
* true means Level.INFO, false Level.SEVERE.
@ -105,11 +87,7 @@ public final class LafManager {
* @param level the new log level.
*/
public static void setLogLevel(final Level level) {
for (Handler handler : Logger.getLogger("").getHandlers()) {
if (handler instanceof LogHandler) {
handler.setLevel(level);
}
}
LogUtil.setLevel(level);
}
/**

3
core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java

@ -32,11 +32,12 @@ import java.util.logging.Logger;
import com.github.weisj.darklaf.color.DarkColorModelHSB;
import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.uiresource.DarkColorUIResource;
import com.github.weisj.darklaf.util.LogUtil;
import com.github.weisj.darklaf.util.Pair;
public class AccentColorAdjustmentTask extends ColorAdjustmentTask {
private static final Logger LOGGER = Logger.getLogger(AccentColorAdjustmentTask.class.getName());
private static final Logger LOGGER = LogUtil.getLogger(AccentColorAdjustmentTask.class);
private static final String MAIN_ACCENT_LIST_KEY = "accent.propertyList";
private static final String SELECTION_ACCENT_LIST_KEY = "selection.propertyList";

3
core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java

@ -40,11 +40,12 @@ import com.github.weisj.darklaf.PropertyLoader;
import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.theme.info.FontSizeRule;
import com.github.weisj.darklaf.uiresource.DarkFontUIResource;
import com.github.weisj.darklaf.util.LogUtil;
import com.github.weisj.darklaf.util.SystemInfo;
public class FontDefaultsInitTask implements DefaultsInitTask {
private static final Logger LOGGER = Logger.getLogger(FontDefaultsInitTask.class.getName());
private static final Logger LOGGER = LogUtil.getLogger(FontDefaultsInitTask.class);
private static final String FONT_PROPERTY_PATH = "properties/";
private static final String FONT_SIZE_DEFAULTS_NAME = "font_sizes";
private static final String FONT_DEFAULTS_NAME = "font";

3
core/src/main/java/com/github/weisj/darklaf/task/PropertyFontMapper.java

@ -31,10 +31,11 @@ import javax.swing.*;
import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.util.LogUtil;
public class PropertyFontMapper implements FontMapper {
private static final Logger LOGGER = Logger.getLogger(PropertyFontMapper.class.getName());
private static final Logger LOGGER = LogUtil.getLogger(PropertyFontMapper.class);
private Theme lastTheme = null;
private int adjustment;

3
core/src/main/java/org/pbjar/jxlayer/plaf/ext/TransformUI.java

@ -46,6 +46,7 @@ import javax.swing.event.ChangeListener;
import javax.swing.text.GlyphView.GlyphPainter;
import javax.swing.text.JTextComponent;
import com.github.weisj.darklaf.util.LogUtil;
import org.jdesktop.jxlayer.JXLayer;
import org.jdesktop.jxlayer.plaf.AbstractBufferedLayerUI;
import org.jdesktop.jxlayer.plaf.LayerUI;
@ -119,7 +120,7 @@ public class TransformUI extends MouseEventUI<JComponent> {
private static final String KEY_VIEW = "view";
private static final boolean delegatePossible;
private static final RepaintManager wrappedManager = new TransformRepaintManager();
private static final Logger LOGGER = Logger.getLogger(TransformUI.class.getName());
private static final Logger LOGGER = LogUtil.getLogger(TransformUI.class);
static {
LOGGER.setUseParentHandlers(false);

3
core/src/main/java/org/pbjar/jxlayer/plaf/ext/transform/TransformRPMImpl.java

@ -39,6 +39,7 @@ import java.util.logging.Logger;
import javax.swing.*;
import com.github.weisj.darklaf.util.LogUtil;
import org.jdesktop.jxlayer.JXLayer;
import org.jdesktop.jxlayer.plaf.LayerUI;
import org.pbjar.jxlayer.plaf.ext.TransformUI;
@ -53,7 +54,7 @@ import com.github.weisj.darklaf.log.LogFormatter;
*/
public final class TransformRPMImpl {
private static final Logger LOGGER = Logger.getLogger(TransformRPMImpl.class.getName());
private static final Logger LOGGER = LogUtil.getLogger(TransformRPMImpl.class);
/**
* A flag, indicating whether or not a very dirty initialization on created {@link RepaintManager}s must be
* performed.

3
core/src/main/java/org/pbjar/jxlayer/repaint/RepaintManagerUtils.java

@ -39,6 +39,7 @@ import java.util.logging.Logger;
import javax.swing.*;
import com.github.weisj.darklaf.util.LogUtil;
import org.jdesktop.swingx.ForwardingRepaintManager;
import com.github.weisj.darklaf.log.LogFormatter;
@ -50,7 +51,7 @@ import com.github.weisj.darklaf.log.LogFormatter;
*/
public final class RepaintManagerUtils {
private static final Logger LOGGER = Logger.getLogger(RepaintManagerUtils.class.getName());
private static final Logger LOGGER = LogUtil.getLogger(RepaintManagerUtils.class);
/**
* Indicates the availability of SwingX on the class path.
*/

33
core/src/main/resources/com/github/weisj/darklaf/log/logging.properties

@ -1,33 +0,0 @@
#
# MIT License
#
# Copyright (c) 2020 Jannis Weis
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
#
# suppress inspection "UnusedProperty" for whole file
#
handlers = com.github.weisj.darklaf.log.LogHandler
.level = ALL
com.github.weisj.darklaf.log.LogHandler.level = INFO
com.github.weisj.darklaf.log.LogHandler.formatter = com.github.weisj.darklaf.log.LogFormatter
com.github.weisj.darklaf.level = ALL

3
macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSLibrary.java

@ -28,11 +28,12 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.github.weisj.darklaf.platform.NativeUtil;
import com.github.weisj.darklaf.util.LogUtil;
import com.github.weisj.darklaf.util.SystemInfo;
public class MacOSLibrary {
private static final Logger LOGGER = Logger.getLogger(MacOSLibrary.class.getName());
private static final Logger LOGGER = LogUtil.getLogger(MacOSLibrary.class);
private static boolean loaded;
private static boolean attemptedLoad;

4
macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSPreferenceMonitor.java

@ -28,9 +28,11 @@ import java.awt.*;
import java.util.Objects;
import java.util.logging.Logger;
import com.github.weisj.darklaf.util.LogUtil;
public class MacOSPreferenceMonitor {
private static final Logger LOGGER = Logger.getLogger(MacOSThemePreferenceProvider.class.getName());
private static final Logger LOGGER = LogUtil.getLogger(MacOSThemePreferenceProvider.class);
private final MacOSThemePreferenceProvider preferenceProvider;

3
property-loader/src/main/java/com/github/weisj/darklaf/PropertyLoader.java

@ -47,6 +47,7 @@ import com.github.weisj.darklaf.icons.StateIcon;
import com.github.weisj.darklaf.uiresource.DarkColorUIResource;
import com.github.weisj.darklaf.uiresource.DarkFontUIResource;
import com.github.weisj.darklaf.util.ColorUtil;
import com.github.weisj.darklaf.util.LogUtil;
import com.github.weisj.darklaf.util.Pair;
import com.github.weisj.darklaf.util.PropertyValue;
@ -55,7 +56,7 @@ import com.github.weisj.darklaf.util.PropertyValue;
* @author Jannis Weis
*/
public final class PropertyLoader {
private static final Logger LOGGER = Logger.getLogger(PropertyLoader.class.getName());
private static final Logger LOGGER = LogUtil.getLogger(PropertyLoader.class);
private static final IconLoader ICON_LOADER = IconLoader.get(IconLoader.class);
private static final char INT_LIST_START = '[';
private static final char INT_LIST_END = ']';

3
property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkSVGIcon.java

@ -32,6 +32,7 @@ import java.util.logging.Logger;
import javax.swing.*;
import com.github.weisj.darklaf.util.LogUtil;
import com.kitfox.svg.app.beans.SVGIcon;
/**
@ -42,7 +43,7 @@ import com.kitfox.svg.app.beans.SVGIcon;
*/
public class DarkSVGIcon implements Icon, Serializable {
private static final Logger LOGGER = Logger.getLogger(DarkSVGIcon.class.getName());
private static final Logger LOGGER = LogUtil.getLogger(DarkSVGIcon.class);
private final Dimension size;
private final SVGIcon icon;
private final URI uri;

3
property-loader/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java

@ -33,6 +33,7 @@ import java.util.logging.Logger;
import javax.swing.*;
import com.github.weisj.darklaf.util.ColorUtil;
import com.github.weisj.darklaf.util.LogUtil;
import com.github.weisj.darklaf.util.Pair;
import com.kitfox.svg.*;
import com.kitfox.svg.animation.AnimationElement;
@ -43,7 +44,7 @@ import com.kitfox.svg.xml.StyleAttribute;
* @author Jannis Weis
*/
public final class IconColorMapper {
private static final Logger LOGGER = Logger.getLogger(IconLoader.class.getName());
private static final Logger LOGGER = LogUtil.getLogger(IconLoader.class);
private static final Color FALLBACK_COLOR = Color.RED;
public static void patchColors(final SVGIcon svgIcon) {

3
property-loader/src/main/java/com/github/weisj/darklaf/icons/IconLoader.java

@ -36,12 +36,13 @@ import java.util.logging.Logger;
import javax.swing.*;
import com.github.weisj.darklaf.util.LazyValue;
import com.github.weisj.darklaf.util.LogUtil;
/**
* @author Jannis Weis
*/
public final class IconLoader {
private static final Logger LOGGER = Logger.getLogger(IconLoader.class.getName());
private static final Logger LOGGER = LogUtil.getLogger(IconLoader.class);
private static final Map<Class<?>, IconLoader> iconLoaderMap = new HashMap<>();
private static final LazyValue<IconLoader> instance = new LazyValue<>(() -> get(null));

4
property-loader/src/main/java/com/github/weisj/darklaf/icons/LazyIcon.java

@ -30,12 +30,14 @@ import java.util.logging.Logger;
import javax.swing.*;
import javax.swing.plaf.UIResource;
import com.github.weisj.darklaf.util.LogUtil;
/**
* @author Jannis Weis
*/
public abstract class LazyIcon implements Icon, UIResource {
private static final Logger LOGGER = Logger.getLogger(LazyIcon.class.getName());
private static final Logger LOGGER = LogUtil.getLogger(LazyIcon.class);
protected final String path;
protected final IconLoader.IconKey key;
protected final Class<?> parentClass;

1
theme/build.gradle.kts

@ -4,4 +4,5 @@ plugins {
dependencies {
implementation(project(":darklaf-property-loader"))
implementation(project(":darklaf-utils"))
}

3
theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java

@ -40,12 +40,13 @@ import javax.swing.text.html.StyleSheet;
import com.github.weisj.darklaf.PropertyLoader;
import com.github.weisj.darklaf.theme.info.*;
import com.github.weisj.darklaf.util.LogUtil;
/**
* @author Jannis Weis
*/
public abstract class Theme implements Comparable<Theme>, Comparator<Theme> {
private static final Logger LOGGER = Logger.getLogger(Theme.class.getName());
private static final Logger LOGGER = LogUtil.getLogger(Theme.class);
private final FontSizeRule fontSizeRule;
private final AccentColorRule accentColorRule;

29
utils/src/main/java/com/github/weisj/darklaf/log/DarkLogHandler.java

@ -0,0 +1,29 @@
/*
* MIT License
*
* Copyright (c) 2020 Jannis Weis
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.log;
import java.util.logging.ConsoleHandler;
public class DarkLogHandler extends ConsoleHandler {}

118
utils/src/main/java/com/github/weisj/darklaf/log/LogFormatter.java

@ -0,0 +1,118 @@
/*
* MIT License
*
* Copyright (c) 2020 Jannis Weis
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.log;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import com.github.weisj.darklaf.util.StringUtil;
/**
* @author Jannis Weis
*/
public class LogFormatter extends Formatter {
public static final String ANSI_RESET = "\u001B[0m";
public static final String ANSI_BLACK = "\u001B[30m";
public static final String ANSI_RED = "\u001B[31m";
public static final String ANSI_GREEN = "\u001B[32m";
public static final String ANSI_YELLOW = "\u001B[33m";
public static final String ANSI_BLUE = "\u001B[34m";
public static final String ANSI_PURPLE = "\u001B[35m";
public static final String ANSI_CYAN = "\u001B[36m";
public static final String ANSI_WHITE = "\u001B[37m";
public static final String ANSI_BOLD_ON = "\u001B[01m";
public static final String ANSI_BOLD_OFF = "\u001B[2m";
@Override
public String format(final LogRecord record) {
StringBuilder builder = new StringBuilder();
builder.append(ANSI_BLUE);
String time = calculateDateString(record.getMillis());
builder.append("[");
builder.append(time);
builder.append("]");
builder.append(ANSI_YELLOW);
builder.append(" [");
builder.append(record.getLevel().getName());
builder.append("]");
builder.append(ANSI_RESET);
builder.append(getMessageColor(record));
builder.append(" ");
builder.append(record.getMessage());
builder.append(ANSI_RESET);
builder.append(ANSI_BOLD_ON);
builder.append(" [at ");
builder.append(record.getSourceClassName());
builder.append("]");
builder.append(ANSI_BOLD_OFF);
Object[] params = record.getParameters();
int spaceLength = time.length() + 3 + record.getLevel().getName().length() + 3;
String space = StringUtil.repeat(" ", spaceLength);
if (params != null) {
builder.append("\n");
builder.append(StringUtil.repeat(" ", spaceLength - 10));
builder.append(ANSI_YELLOW);
builder.append("[Details] ");
builder.append(getMessageColor(record));
for (int i = 0; i < params.length; i++) {
builder.append(params[i]);
if (i < params.length - 1) {
builder.append(",\n");
builder.append(space);
}
}
}
builder.append(ANSI_RESET);
builder.append("\n");
return builder.toString();
}
private String calculateDateString(final long milliseconds) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date(milliseconds);
return dateFormat.format(date);
}
private String getMessageColor(final LogRecord record) {
if (record.getLevel() == Level.SEVERE) {
return ANSI_RED;
} else if (record.getLevel() == Level.WARNING) {
return ANSI_YELLOW;
} else {
return ANSI_BLACK;
}
}
}

54
utils/src/main/java/com/github/weisj/darklaf/util/LogUtil.java

@ -0,0 +1,54 @@
/*
* MIT License
*
* Copyright (c) 2020 Jannis Weis
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.util;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.github.weisj.darklaf.log.DarkLogHandler;
import com.github.weisj.darklaf.log.LogFormatter;
public class LogUtil {
private static final Logger PARENT = Logger.getLogger("com.github.weisj.darklaf");
private static final Handler LOG_HANDLER = new DarkLogHandler();
static {
LOG_HANDLER.setFormatter(new LogFormatter());
}
public static Logger getLogger(final Class<?> clazz) {
Logger logger = Logger.getLogger(clazz.getName());
logger.setUseParentHandlers(false);
logger.addHandler(LOG_HANDLER);
return logger;
}
public static void setLevel(final Level level) {
PARENT.setLevel(level);
LOG_HANDLER.setLevel(level);
}
}

3
windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsLibrary.java

@ -28,11 +28,12 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.github.weisj.darklaf.platform.NativeUtil;
import com.github.weisj.darklaf.util.LogUtil;
import com.github.weisj.darklaf.util.SystemInfo;
public class WindowsLibrary {
private static final Logger LOGGER = Logger.getLogger(WindowsLibrary.class.getName());
private static final Logger LOGGER = LogUtil.getLogger(WindowsLibrary.class);
private static boolean loaded;
private static boolean attemptedLoad;

4
windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsPreferenceMonitor.java

@ -26,9 +26,11 @@ package com.github.weisj.darklaf.platform.windows;
import java.util.logging.Logger;
import com.github.weisj.darklaf.util.LogUtil;
public class WindowsPreferenceMonitor {
private static final Logger LOGGER = Logger.getLogger(WindowsThemePreferenceProvider.class.getName());
private static final Logger LOGGER = LogUtil.getLogger(WindowsThemePreferenceProvider.class);
private final WindowsThemePreferenceProvider preferenceProvider;

Loading…
Cancel
Save