From f4e542b4db686dad6f3fe1c4fe0006fc06dd2bd9 Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Sun, 23 Oct 2022 16:13:08 +0100 Subject: [PATCH] Use our global logger instead of per-class ones No slf4j available for 1.16.5, and I'll forget if I depend on log4j. --- src/main/java/dan200/computercraft/data/ModelProvider.java | 7 ++----- .../shared/computer/metrics/ComputerMBean.java | 7 ++----- .../computercraft/core/computer/ComputerThreadTest.java | 7 ++----- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/main/java/dan200/computercraft/data/ModelProvider.java b/src/main/java/dan200/computercraft/data/ModelProvider.java index a4637976a..6771ce3b7 100644 --- a/src/main/java/dan200/computercraft/data/ModelProvider.java +++ b/src/main/java/dan200/computercraft/data/ModelProvider.java @@ -6,13 +6,12 @@ package dan200.computercraft.data; import com.google.gson.JsonElement; +import dan200.computercraft.ComputerCraft; import net.minecraft.block.Block; import net.minecraft.data.*; import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; import net.minecraftforge.registries.ForgeRegistries; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import javax.annotation.Nonnull; import java.nio.file.Path; @@ -32,8 +31,6 @@ import java.util.function.Supplier; */ public class ModelProvider implements IDataProvider { - private static final Logger LOGGER = LogManager.getLogger(); - private final DataGenerator generator; private final Consumer blocks; @@ -97,7 +94,7 @@ public class ModelProvider implements IDataProvider } catch( Exception exception ) { - LOGGER.error( "Couldn't save {}", path, exception ); + ComputerCraft.log.error( "Couldn't save {}", path, exception ); } } } diff --git a/src/main/java/dan200/computercraft/shared/computer/metrics/ComputerMBean.java b/src/main/java/dan200/computercraft/shared/computer/metrics/ComputerMBean.java index e4c3ec162..e4a9e8f4d 100644 --- a/src/main/java/dan200/computercraft/shared/computer/metrics/ComputerMBean.java +++ b/src/main/java/dan200/computercraft/shared/computer/metrics/ComputerMBean.java @@ -6,6 +6,7 @@ package dan200.computercraft.shared.computer.metrics; import com.google.common.base.CaseFormat; +import dan200.computercraft.ComputerCraft; import dan200.computercraft.core.metrics.Metric; import dan200.computercraft.core.metrics.Metrics; import dan200.computercraft.shared.computer.core.ServerComputer; @@ -15,8 +16,6 @@ import dan200.computercraft.shared.computer.metrics.basic.AggregatedMetric; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import net.minecraft.server.MinecraftServer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javax.annotation.Nullable; import javax.management.*; @@ -33,8 +32,6 @@ import java.util.function.LongSupplier; */ public final class ComputerMBean implements DynamicMBean, ComputerMetricsObserver { - private static final Logger LOGGER = LoggerFactory.getLogger( ComputerMBean.class ); - private static @Nullable ComputerMBean instance; private final Map attributes = new HashMap<>(); @@ -66,7 +63,7 @@ public final class ComputerMBean implements DynamicMBean, ComputerMetricsObserve catch( InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException | MalformedObjectNameException e ) { - LOGGER.warn( "Failed to register JMX bean", e ); + ComputerCraft.log.warn( "Failed to register JMX bean", e ); } } diff --git a/src/test/java/dan200/computercraft/core/computer/ComputerThreadTest.java b/src/test/java/dan200/computercraft/core/computer/ComputerThreadTest.java index 87c6be49b..e3597b6dc 100644 --- a/src/test/java/dan200/computercraft/core/computer/ComputerThreadTest.java +++ b/src/test/java/dan200/computercraft/core/computer/ComputerThreadTest.java @@ -5,6 +5,7 @@ */ package dan200.computercraft.core.computer; +import dan200.computercraft.ComputerCraft; import dan200.computercraft.core.lua.MachineResult; import dan200.computercraft.support.ConcurrentHelpers; import org.junit.jupiter.api.AfterEach; @@ -13,8 +14,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; import org.junit.jupiter.api.parallel.Execution; import org.junit.jupiter.api.parallel.ExecutionMode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.concurrent.TimeUnit; @@ -26,8 +25,6 @@ import static org.junit.jupiter.api.Assertions.*; @Execution( ExecutionMode.CONCURRENT ) public class ComputerThreadTest { - private static final Logger LOGGER = LoggerFactory.getLogger( ComputerThreadTest.class ); - private FakeComputerManager manager; @BeforeEach @@ -51,7 +48,7 @@ public class ComputerThreadTest long delay = ConcurrentHelpers.waitUntil( timeout::isSoftAborted ); assertThat( "Should be soft aborted", delay * 1e-9, closeTo( 7, 0.5 ) ); - LOGGER.info( "Slept for {}", delay ); + ComputerCraft.log.info( "Slept for {}", delay ); computer.shutdown(); return MachineResult.OK;