Sfoglia il codice sorgente

:fire: Remove unnecessary LoggingUtils

Signed-off-by: palexdev <alessandro.parisi406@gmail.com>
palexdev 4 anni fa
parent
commit
8e91b5f6c4

+ 0 - 1
demo/build.gradle

@@ -38,5 +38,4 @@ jlink {
     jpackage {
         imageOptions = ['--icon', 'src/main/resources/logo.ico']
     }
-    forceMerge('log4j-api')
 }

+ 0 - 2
materialfx/build.gradle

@@ -16,8 +16,6 @@ compileJava {
 dependencies {
     testImplementation('junit:junit:4.13')
     implementation 'com.vanniktech:gradle-maven-publish-plugin:0.13.0'
-    implementation 'org.apache.logging.log4j:log4j-api:2.14.0'
-    implementation 'org.apache.logging.log4j:log4j-core:2.14.0'
 
     implementation 'org.reactfx:reactfx:2.0-M5'
 }

+ 2 - 6
materialfx/src/main/java/io/github/palexdev/materialfx/controls/SimpleMFXNotificationPane.java

@@ -20,7 +20,6 @@ package io.github.palexdev.materialfx.controls;
 
 import io.github.palexdev.materialfx.controls.base.AbstractMFXNotificationPane;
 import io.github.palexdev.materialfx.font.MFXFontIcon;
-import io.github.palexdev.materialfx.utils.LoggingUtils;
 import io.github.palexdev.materialfx.utils.NodeUtils;
 import javafx.event.EventHandler;
 import javafx.geometry.Insets;
@@ -148,11 +147,8 @@ public class SimpleMFXNotificationPane extends AbstractMFXNotificationPane {
         try {
             this.buttonsBox.getChildren().add(index, button);
         } catch (IndexOutOfBoundsException ex) {
-            LoggingUtils.logException(
-                    "Could not add button at index:" + index +
-                            ", list size is:" + this.buttonsBox.getChildren().size(),
-                    ex
-            );
+            throw new IndexOutOfBoundsException("Could not add button at index:" + index +
+                    ", list size is:" + this.buttonsBox.getChildren().size());
         }
     }
 

+ 5 - 2
materialfx/src/main/java/io/github/palexdev/materialfx/notifications/PositionManager.java

@@ -19,7 +19,6 @@
 package io.github.palexdev.materialfx.notifications;
 
 import io.github.palexdev.materialfx.controls.MFXNotification;
-import io.github.palexdev.materialfx.utils.LoggingUtils;
 import javafx.animation.Interpolator;
 import javafx.animation.Transition;
 import javafx.application.Platform;
@@ -128,7 +127,11 @@ public class PositionManager {
                 return null;
             }
         };
-        showTask.setOnFailed(event -> LoggingUtils.logException(showTask.getException()));
+        showTask.setOnFailed(event -> {
+            if (showTask.getException() != null) {
+                showTask.getException().printStackTrace();
+            }
+        });
         service.submit(showTask);
     }
 

+ 1 - 2
materialfx/src/main/java/io/github/palexdev/materialfx/skins/MFXDatePickerContent.java

@@ -29,7 +29,6 @@ import io.github.palexdev.materialfx.effects.ripple.MFXCircleRippleGenerator;
 import io.github.palexdev.materialfx.effects.ripple.RipplePosition;
 import io.github.palexdev.materialfx.font.MFXFontIcon;
 import io.github.palexdev.materialfx.utils.ColorUtils;
-import io.github.palexdev.materialfx.utils.LoggingUtils;
 import io.github.palexdev.materialfx.utils.NodeUtils;
 import io.github.palexdev.materialfx.utils.StringUtils;
 import javafx.animation.*;
@@ -655,7 +654,7 @@ public class MFXDatePickerContent extends VBox {
                     selectedDate.setText(date.format(getDateFormatter()));
                     setCurrentDate(LocalDate.parse(selectedDate.getText(), getDateFormatter()));
                 } catch (DateTimeParseException ex) {
-                    LoggingUtils.logException(ex);
+                    ex.printStackTrace();
                     inputField.getValidator().add(validInput, ex.getMessage());
                     validInput.set(false);
                 }

+ 0 - 69
materialfx/src/main/java/io/github/palexdev/materialfx/utils/LoggingUtils.java

@@ -1,69 +0,0 @@
-/*
- *     Copyright (C) 2021 Parisi Alessandro
- *     This file is part of MaterialFX (https://github.com/palexdev/MaterialFX).
- *
- *     MaterialFX is free software: you can redistribute it and/or modify
- *     it under the terms of the GNU General Public License as published by
- *     the Free Software Foundation, either version 3 of the License, or
- *     (at your option) any later version.
- *
- *     MaterialFX is distributed in the hope that it will be useful,
- *     but WITHOUT ANY WARRANTY; without even the implied warranty of
- *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *     GNU General Public License for more details.
- *
- *     You should have received a copy of the GNU General Public License
- *     along with MaterialFX.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package io.github.palexdev.materialfx.utils;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
-/**
- * Utils class for logging.
- */
-public class LoggingUtils {
-    public static final Logger logger = LogManager.getLogger("MaterialFX - " + LoggingUtils.class.getSimpleName());
-    private static final Level EXCEPTION = Level.forName("EXCEPTION", 150);
-    private static final StringWriter sw = new StringWriter();
-
-    private LoggingUtils() {
-    }
-
-    /**
-     * Gets the stacktrace of a {@code Throwable} as a String.
-     *
-     * @param ex The throwable/exception
-     * @return the stacktrace as a String
-     */
-    public static String getStackTraceString(Throwable ex) {
-        sw.flush();
-        ex.printStackTrace(new PrintWriter(sw));
-        return sw.toString();
-    }
-
-    /**
-     * Logs the given {@code Throwable}'s stacktrace to the console.
-     *
-     * @param ex The throwable/exception
-     */
-    public static void logException(Throwable ex) {
-        logger.log(EXCEPTION, getStackTraceString(ex));
-    }
-
-    /**
-     * Logs the given {@code Throwable}'s exception to the console and adds the given String at the beginning.
-     *
-     * @param msg The extra message you want to log
-     * @param ex  The throwable/exception
-     */
-    public static void logException(String msg, Throwable ex) {
-        logger.log(EXCEPTION, msg + "\n" + getStackTraceString(ex));
-    }
-}

+ 2 - 2
materialfx/src/main/java/io/github/palexdev/materialfx/utils/NodeUtils.java

@@ -151,7 +151,7 @@ public class NodeUtils {
         try {
             region.setClip(circle);
         } catch (IllegalArgumentException ex) {
-            LoggingUtils.logException("Could not set region's clip to make it circular", ex);
+            throw new IllegalArgumentException("Could not set region's clip to make it circular", ex);
         }
     }
 
@@ -170,7 +170,7 @@ public class NodeUtils {
         try {
             region.setClip(circle);
         } catch (IllegalArgumentException ex) {
-            LoggingUtils.logException("Could not set region's clip to make it circular", ex);
+            throw new IllegalArgumentException("Could not set region's clip to make it circular", ex);
         }
     }
 

+ 0 - 1
materialfx/src/main/java/module-info.java

@@ -5,7 +5,6 @@ module MaterialFX {
     requires java.desktop;
 
     requires reactfx;
-    requires org.apache.logging.log4j;
 
     exports io.github.palexdev.materialfx;
     exports io.github.palexdev.materialfx.beans;