Add log4j config (this might work :p)

This commit is contained in:
Alexander Söderberg 2020-07-13 20:39:52 +02:00
parent c6962ef4d2
commit e84d82315c
6 changed files with 48 additions and 28 deletions

View File

@ -37,7 +37,10 @@ dependencies {
implementation("net.alpenblock:BungeePerms:4.0-dev-106")
compile("se.hyperver.hyperverse:Core:0.6.0-SNAPSHOT"){ transitive = false }
compile('com.sk89q:squirrelid:1.0.0-SNAPSHOT'){ transitive = false }
compile("org.slf4j:slf4j-jdk14:2.0.0-alpha1")
// logging
implementation('org.apache.logging.log4j:log4j-slf4j-impl:2.13.3')
implementation('org.apache.logging.log4j:log4j-core:2.13.3')
implementation('org.apache.logging.log4j:log4j-api:2.13.3')
}
sourceCompatibility = 1.8
@ -97,12 +100,16 @@ shadowJar {
include(dependency("org.khelekore:prtree:1.7.0-SNAPSHOT"))
include(dependency("com.sk89q:squirrelid:1.0.0-SNAPSHOT"))
include(dependency("org.slf4j:slf4j-jdk14:2.0.0-alpha1"))
include(dependency('org.apache.logging.log4j:log4j-slf4j-impl:2.13.3'))
include(dependency('org.apache.logging.log4j:log4j-core:2.13.3'))
include(dependency('org.apache.logging.log4j:log4j-api:2.13.3'))
}
relocate('net.kyori.text', 'com.plotsquared.formatting.text')
relocate("io.papermc.lib", "com.plotsquared.bukkit.paperlib")
relocate("org.bstats", "com.plotsquared.metrics")
relocate('com.sk89q.squirrelid', 'com.plotsquared.squirrelid')
relocate('org.khelekore.prtree', 'com.plotsquared.prtree')
relocate('org.apache.logging.log4j', 'com.plotsquared.logging')
archiveFileName = "${project.name}-${parent.version}.jar"
destinationDirectory = file "../target"
}

View File

@ -18,7 +18,10 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.72")
implementation("org.jetbrains:annotations:19.0.0")
implementation("org.khelekore:prtree:1.7.0-SNAPSHOT")
implementation("org.slf4j:slf4j-api:2.0.0-alpha1")
// logging
implementation('org.apache.logging.log4j:log4j-slf4j-impl:2.13.3')
implementation('org.apache.logging.log4j:log4j-core:2.13.3')
implementation('org.apache.logging.log4j:log4j-api:2.13.3')
}
sourceCompatibility = 1.8

View File

@ -99,8 +99,8 @@ public class Config {
field.set(instance, value);
return;
} catch (final Throwable e) {
logger.atDebug().addArgument(key).addArgument(value).addArgument(root.getSimpleName())
.setCause(e).log("Invalid configuration value '{}: {}' in {}");
logger.debug("Invalid configuration value '{}: {}' in {}", key, value, root.getSimpleName());
e.printStackTrace();
}
}
}
@ -289,9 +289,10 @@ public class Config {
Field field = instance.getClass().getField(toFieldName(split[split.length - 1]));
setAccessible(field);
return field;
} catch (Throwable e) {
logger.atDebug().addArgument(StringMan.join(split, ".")).setCause(e)
.addArgument(toNodeName(instance.getClass().getSimpleName())).log("Invalid config field: {} for {}");
} catch (final Throwable e) {
logger.debug("Invalid config field: {} for {}",
StringMan.join(split, "."), toNodeName(instance.getClass().getSimpleName()));
e.printStackTrace();
return null;
}
}

View File

@ -1735,8 +1735,8 @@ public class Plot {
public boolean claim(@NotNull final PlotPlayer player, boolean teleport, String schematic) {
if (!canClaim(player)) {
logger.atDebug().addArgument(player.getName()).addArgument(this.getId().toCommaSeparatedString())
.log("Player {} attempted to claim plot {}, but was not allowed");
logger.debug("Player {} attempted to claim plot {}, but was not allowed",
player.getName(), this.getId().toCommaSeparatedString());
return false;
}
return claim(player, teleport, schematic, true);
@ -1835,8 +1835,8 @@ public class Plot {
});
return true;
}
logger.atInfo().addArgument(this.getId().toCommaSeparatedString())
.addArgument(this.area.toString()).log("Failed to add plot {} to plot area {}");
logger.info("Failed to add plot {} to plot area {}",
this.getId().toCommaSeparatedString(), this.area.toString());
return false;
}
@ -1934,12 +1934,12 @@ public class Plot {
*/
public boolean moveData(Plot plot, Runnable whenDone) {
if (!this.hasOwner()) {
logger.atDebug().addArgument(plot).log("{} is unowned (single)");
logger.debug("{} is unowned (single)", plot);
TaskManager.runTask(whenDone);
return false;
}
if (plot.hasOwner()) {
logger.atDebug().addArgument(plot).log("{} is unowned (multi)");
logger.debug("{} is unowned (multi)", plot);
TaskManager.runTask(whenDone);
return false;
}
@ -2647,7 +2647,7 @@ public class Plot {
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.NORTH));
if (!tmp.getMerged(Direction.SOUTH)) {
// invalid merge
logger.atDebug().addArgument(this).log("Fixing invalid merge: {}");
logger.debug("Fixing invalid merge: {}", this);
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
tmp.getSettings().setMerged(Direction.SOUTH, true);
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
@ -2664,7 +2664,7 @@ public class Plot {
assert tmp != null;
if (!tmp.getMerged(Direction.WEST)) {
// invalid merge
logger.atDebug().addArgument(this).log("Fixing invalid merge: {}");
logger.debug("Fixing invalid merge: {}", this);
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
tmp.getSettings().setMerged(Direction.WEST, true);
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
@ -2681,7 +2681,7 @@ public class Plot {
assert tmp != null;
if (!tmp.getMerged(Direction.NORTH)) {
// invalid merge
logger.atDebug().addArgument(this).log("Fixing invalid merge: {}");
logger.debug("Fixing invalid merge: {}", this);
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
tmp.getSettings().setMerged(Direction.NORTH, true);
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
@ -2697,7 +2697,7 @@ public class Plot {
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.WEST));
if (!tmp.getMerged(Direction.EAST)) {
// invalid merge
logger.atDebug().addArgument(this).log("Fixing invalid merge: {}");
logger.debug("Fixing invalid merge: {}", this);
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
tmp.getSettings().setMerged(Direction.EAST, true);
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
@ -2712,10 +2712,7 @@ public class Plot {
Plot current;
while ((current = frontier.poll()) != null) {
if (!current.hasOwner() || current.settings == null) {
// Invalid plot
// merged onto unclaimed plot
logger.atDebug().addArgument(current).addArgument(current.getOwnerAbs())
.log("Ignoring invalid merged plot: {} | {}");
logger.debug("Ignoring invalid merged plot: {} | {}", current, current.getOwnerAbs());
continue;
}
tmpSet.add(current);

View File

@ -1063,13 +1063,12 @@ public abstract class PlotArea {
try {
flags.add(flagInstance.parse(split[1]));
} catch (final FlagParseException e) {
logger.atWarn()
.addArgument(e.getFlag().getName())
.addArgument(e.getValue())
.addArgument(e.getErrorMessage())
.setCause(e)
.log("Failed to parse default flag with key '{}' and value '{}'. "
+ "Reason: {}. This flag will not be added as a default flag.");
logger.warn("Failed to parse default flag with key '{}' and value '{}'. "
+ "Reason: {}. This flag will not be added as a default flag.",
e.getFlag().getName(),
e.getValue(),
e.getErrorMessage());
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" packages="com.plotsquared">
<Appenders>
<Console name="SysOut" target="SYSTEM_OUT">
<PatternLayout pattern="%highlight{[P2: %c{1.}][%d{HH:mm:ss}] [%t/%level]: %msg%n%throwable{full}}" />
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="SysOut"/>
</Root>
</Loggers>
</Configuration>