mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-02 17:32:03 +01:00
Make debug logging togglable.
By: Minecrell <dev@minecrell.net>
This commit is contained in:
parent
f026f7905e
commit
c34736a0d2
2 changed files with 29 additions and 3 deletions
|
@ -18,6 +18,9 @@ import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||||
import net.minecraft.world.entity.ai.attributes.RangedAttribute;
|
import net.minecraft.world.entity.ai.attributes.RangedAttribute;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.core.LoggerContext;
|
||||||
|
import org.apache.logging.log4j.core.config.Configuration;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
|
@ -356,4 +359,27 @@ public class SpigotConfig
|
||||||
SpigotConfig.attackDamage = SpigotConfig.getDouble( "settings.attribute.attackDamage.max", SpigotConfig.attackDamage );
|
SpigotConfig.attackDamage = SpigotConfig.getDouble( "settings.attribute.attackDamage.max", SpigotConfig.attackDamage );
|
||||||
( (RangedAttribute) Attributes.ATTACK_DAMAGE.value() ).maxValue = SpigotConfig.attackDamage;
|
( (RangedAttribute) Attributes.ATTACK_DAMAGE.value() ).maxValue = SpigotConfig.attackDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean debug;
|
||||||
|
private static void debug()
|
||||||
|
{
|
||||||
|
SpigotConfig.debug = SpigotConfig.getBoolean( "settings.debug", false );
|
||||||
|
|
||||||
|
if ( SpigotConfig.debug && !LogManager.getRootLogger().isTraceEnabled() )
|
||||||
|
{
|
||||||
|
// Enable debug logging
|
||||||
|
LoggerContext ctx = (LoggerContext) LogManager.getContext( false );
|
||||||
|
Configuration conf = ctx.getConfiguration();
|
||||||
|
conf.getLoggerConfig( LogManager.ROOT_LOGGER_NAME ).setLevel( org.apache.logging.log4j.Level.ALL );
|
||||||
|
ctx.updateLoggers( conf );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( LogManager.getRootLogger().isTraceEnabled() )
|
||||||
|
{
|
||||||
|
Bukkit.getLogger().info( "Debug logging is enabled" );
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
Bukkit.getLogger().info( "Debug logging is disabled" );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,10 @@
|
||||||
<filters>
|
<filters>
|
||||||
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL" />
|
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL" />
|
||||||
</filters>
|
</filters>
|
||||||
<AppenderRef ref="SysOut"/>
|
<AppenderRef ref="SysOut" level="info"/>
|
||||||
<AppenderRef ref="File"/>
|
<AppenderRef ref="File"/>
|
||||||
<AppenderRef ref="ServerGuiConsole"/>
|
<AppenderRef ref="ServerGuiConsole" level="info"/>
|
||||||
<AppenderRef ref="TerminalConsole"/>
|
<AppenderRef ref="TerminalConsole" level="info"/>
|
||||||
</Root>
|
</Root>
|
||||||
</Loggers>
|
</Loggers>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
|
|
Loading…
Reference in a new issue