diff --git a/build.gradle.kts b/build.gradle.kts index 77e5589..bf5ce60 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -45,8 +45,8 @@ dependencies { tasks { java { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } test { diff --git a/src/main/java/com.voinearadu/logger/Logger.java b/src/main/java/com.voinearadu/logger/Logger.java index 1596e3a..1925aa9 100644 --- a/src/main/java/com.voinearadu/logger/Logger.java +++ b/src/main/java/com.voinearadu/logger/Logger.java @@ -86,12 +86,17 @@ private static void log(Level level, Object object, @NotNull ConsoleColor color, id = caller.getSimpleName() + ".java"; } - String log = switch (object) { - case null -> "null"; - case Throwable throwable -> StackTraceUtils.toString(throwable); - case StackTraceElement[] stackTraceElements -> StackTraceUtils.toString(stackTraceElements); - default -> object.toString(); - }; + String log = null; + + if (object == null) { + log = "null"; + } else if (object instanceof Throwable) { + log = StackTraceUtils.toString((Throwable) object); + } else if (object instanceof StackTraceElement[]) { + log = StackTraceUtils.toString((StackTraceElement[]) object); + } else { + log = object.toString(); + } org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(id); logger.info(color + log + ConsoleColor.RESET);