Remove log4j as much as possible (#1334)

This commit is contained in:
altrisi authored and GitHub committed 2022-02-22 01:35:56 +01:00
1 parent b06d68186e
commit 1f0c609dc0
9 files changed
+26 -22

No files matched your search

+1
View File
@@ -13,6 +13,7 @@ group = project.maven_group
loom { loom {
accessWidenerPath = file("src/main/resources/carpet.accesswidener") accessWidenerPath = file("src/main/resources/carpet.accesswidener")
runtimeOnlyLog4j = false // Can be turned on after TriConsumer is no longer present in public API
} }
dependencies { dependencies {
+4 -3
View File
@@ -22,8 +22,9 @@ import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Iterator; import java.util.Iterator;
import java.util.Locale; import java.util.Locale;
@@ -45,7 +46,7 @@ import static carpet.settings.RuleCategory.CLIENT;
public class CarpetSettings public class CarpetSettings
{ {
public static final String carpetVersion = "1.4.63+v220220"; public static final String carpetVersion = "1.4.63+v220220";
public static final Logger LOG = LogManager.getLogger("carpet"); public static final Logger LOG = LoggerFactory.getLogger("carpet");
public static ThreadLocal<Boolean> skipGenerationChecks = ThreadLocal.withInitial(() -> false); public static ThreadLocal<Boolean> skipGenerationChecks = ThreadLocal.withInitial(() -> false);
public static ThreadLocal<Boolean> impendingFillSkipUpdates = ThreadLocal.withInitial(() -> false); public static ThreadLocal<Boolean> impendingFillSkipUpdates = ThreadLocal.withInitial(() -> false);
public static int runPermissionLevel = 2; public static int runPermissionLevel = 2;
@@ -43,11 +43,11 @@ public abstract class ServerPlayerMixin implements ServerPlayerEntityInterface
} }
catch (StackOverflowError soe) catch (StackOverflowError soe)
{ {
CarpetSettings.LOG.fatal("Caused stack overflow when performing player action", soe); CarpetSettings.LOG.error("Caused stack overflow when performing player action", soe);
} }
catch (Throwable exc) catch (Throwable exc)
{ {
CarpetSettings.LOG.fatal("Error executing player tasks", exc); CarpetSettings.LOG.error("Error executing player tasks", exc);
} }
} }
} }
@@ -34,8 +34,8 @@ import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.storage.LevelResource; import net.minecraft.world.level.storage.LevelResource;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger; import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.nio.file.FileVisitOption; import java.nio.file.FileVisitOption;
@@ -57,7 +57,7 @@ import java.util.stream.Collectors;
public class CarpetScriptServer public class CarpetScriptServer
{ {
//make static for now, but will change that later: //make static for now, but will change that later:
public static final Logger LOG = LogManager.getLogger("scarpet"); public static final Logger LOG = LoggerFactory.getLogger("Scarpet");
public final MinecraftServer server; public final MinecraftServer server;
public CarpetScriptHost globalHost; public CarpetScriptHost globalHost;
public Map<String, CarpetScriptHost> modules; public Map<String, CarpetScriptHost> modules;
+3 -4
View File
@@ -4,13 +4,12 @@ import carpet.script.bundled.Module;
import carpet.script.exception.ExpressionException; import carpet.script.exception.ExpressionException;
import carpet.script.exception.IntegrityException; import carpet.script.exception.IntegrityException;
import carpet.script.exception.InternalExpressionException; import carpet.script.exception.InternalExpressionException;
import carpet.script.language.Arithmetic;
import carpet.script.value.FunctionValue; import carpet.script.value.FunctionValue;
import carpet.script.value.Value; import carpet.script.value.Value;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger; import org.slf4j.LoggerFactory;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@@ -440,7 +439,7 @@ public abstract class ScriptHost
errorSnooper=null; errorSnooper=null;
} }
public static final Logger DEPRECATION_LOG = LogManager.getLogger("Scarpet Deprecation Warnings"); public static final Logger DEPRECATION_LOG = LoggerFactory.getLogger("Scarpet Deprecation Warnings");
public boolean issueDeprecation(String feature) public boolean issueDeprecation(String feature)
{ {
@@ -830,11 +830,14 @@ public class Auxiliary {
String level = lv.get(0).getString().toLowerCase(Locale.ROOT); String level = lv.get(0).getString().toLowerCase(Locale.ROOT);
res = lv.get(1); res = lv.get(1);
switch(level){ switch(level){
case "error": CarpetScriptServer.LOG.error(res.getString()); break;
case "warn": CarpetScriptServer.LOG.warn(res.getString()); break;
case "debug": CarpetScriptServer.LOG.debug(res.getString()); break; case "debug": CarpetScriptServer.LOG.debug(res.getString()); break;
case "fatal": CarpetScriptServer.LOG.fatal(res.getString()); break; case "warn": CarpetScriptServer.LOG.warn(res.getString()); break;
case "info": CarpetScriptServer.LOG.info(res.getString()); break; case "info": CarpetScriptServer.LOG.info(res.getString()); break;
case "fatal":
// Somehow issue deprecation
case "error":
CarpetScriptServer.LOG.error(res.getString());
break;
default: throw new InternalExpressionException("Unknown log level for 'logger': "+level); default: throw new InternalExpressionException("Unknown log level for 'logger': "+level);
} }
} }
@@ -379,9 +379,9 @@ public class FileArgument
} }
catch (IOException secondIO) catch (IOException secondIO)
{ {
CarpetScriptServer.LOG.warn("IOException when trying to read nbt file, something may have gone wrong with the fs",e); CarpetScriptServer.LOG.warn("IOException when trying to read nbt file, something may have gone wrong with the fs", e);
CarpetScriptServer.LOG.catching(ioException); CarpetScriptServer.LOG.warn("", ioException);
CarpetScriptServer.LOG.catching(secondIO); CarpetScriptServer.LOG.warn("", secondIO);
throw new ThrowStatement("Not a valid NBT tag in "+path.toString(), Throwables.NBT_ERROR); throw new ThrowStatement("Not a valid NBT tag in "+path.toString(), Throwables.NBT_ERROR);
} }
} }
+1 -1
View File
@@ -43,7 +43,7 @@ public abstract class Value implements Comparable<Value>, Cloneable
catch (CloneNotSupportedException e) catch (CloneNotSupportedException e)
{ {
// should not happen // should not happen
CarpetSettings.LOG.catching(e); CarpetSettings.LOG.error("Failed to clone variable", e);
throw new InternalExpressionException("Variable of type "+getTypeString()+" is not cloneable. Tell gnembon about it, this shoudn't happen"); throw new InternalExpressionException("Variable of type "+getTypeString()+" is not cloneable. Tell gnembon about it, this shoudn't happen");
} }
copy.boundVariable = var; copy.boundVariable = var;
+3 -3
View File
@@ -15,8 +15,8 @@ import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
import org.apache.logging.log4j.Logger; import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@@ -28,7 +28,7 @@ import java.util.regex.Pattern;
public class Messenger public class Messenger
{ {
public static final Logger LOG = LogManager.getLogger("Messaging System"); public static final Logger LOG = LoggerFactory.getLogger("Messaging System");
private static final Pattern colorExtract = Pattern.compile("#([0-9a-fA-F]{6})"); private static final Pattern colorExtract = Pattern.compile("#([0-9a-fA-F]{6})");
public enum CarpetFormatting public enum CarpetFormatting