Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ public void debug(String message) {
}
}

@Override
public void debug(String message, Throwable t) {
if (debug) {
logger.log(Level.INFO, message, t);
}
}

@Override
public void debug(String message, Object... arguments) {
if (debug) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import net.md_5.bungee.protocol.ProtocolConstants;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.ping.GeyserPingInfo;
import org.geysermc.geyser.ping.IGeyserPingPassthrough;

Expand Down Expand Up @@ -70,7 +71,7 @@ public GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress) {
event = future.get(100, TimeUnit.MILLISECONDS);
} catch (Throwable cause) {
String address = GeyserImpl.getInstance().config().logPlayerIpAddresses() ? inetSocketAddress.toString() : "<IP address withheld>";
GeyserImpl.getInstance().getLogger().error("Failed to get ping information for " + address, cause);
GeyserLogger.get().error("Failed to get ping information for " + address, cause);
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,7 @@ public MetricsPlatform createMetricsPlatform() {
try {
return new BungeeMetrics(this);
} catch (IOException e) {
this.geyserLogger.debug("Integrated bStats support failed to load.");
if (this.config().debugMode()) {
e.printStackTrace();
}
this.geyserLogger.debug("Integrated bStats support failed to load.", e);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import net.minecraft.util.ExtraCodecs;
import net.minecraft.util.HashOps;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.gametest.registries.GameTestJavaRegistryProvider;
import org.geysermc.geyser.item.hashing.DataComponentHashers;
import org.geysermc.geyser.item.hashing.MapHasher;
Expand Down Expand Up @@ -114,11 +115,11 @@ public void run(GameTestHelper helper) {
try {
helper.assertValueEqual(expected, geyser, "hash for component " + encodedJavaValue);
} catch (GameTestAssertException assertException) {
GeyserImpl.getInstance().getLogger().warning("Hash failed for component " + testCase.type() + " (" + testCase.value() + "), printing values of MapHasher");
GeyserLogger.get().warning("Hash failed for component " + testCase.type() + " (" + testCase.value() + "), printing values of MapHasher");
MapHasher.debug = true;
DataComponentHashers.hash(registries, mcplComponent);
MapHasher.debug = false;
GeyserImpl.getInstance().getLogger().warning("The Mojang encoded/expected value is printed in the exception message");
GeyserLogger.get().warning("The Mojang encoded/expected value is printed in the exception message");
throw assertException;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.GameType;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.gametest.mixin.SynchedEntityDataAccessor;
import org.geysermc.geyser.gametest.util.SynchedEntityDataDebugger;
Expand Down Expand Up @@ -101,7 +102,7 @@ public void run(GameTestHelper helper) {
+ SynchedEntityDataDebugger.findNameOfSerializer(dataItems[i].getAccessor().serializer()) + ")");
}
} catch (GameTestAssertException exception) {
GeyserImpl.getInstance().getLogger().warning("Metadata for entity type " + entityType + " are as follows:\n" + SynchedEntityDataDebugger.prettyPrintEntityDataAccessors(javaEntity.getClass(), dataItems));
GeyserLogger.get().warning("Metadata for entity type " + entityType + " are as follows:\n" + SynchedEntityDataDebugger.prettyPrintEntityDataAccessors(javaEntity.getClass(), dataItems));
throw exception;
} finally {
javaEntity.discard();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.GeyserBootstrap;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.network.netty.GeyserInjector;
import org.geysermc.geyser.network.netty.LocalServerChannelWrapper;
import org.geysermc.geyser.platform.mod.platform.GeyserModPlatform;
Expand Down Expand Up @@ -125,10 +126,7 @@ private ChannelInitializer<Channel> getChildHandler(GeyserBootstrap bootstrap, C
childHandler = (ChannelInitializer<Channel>) childHandlerField.get(handler);
break;
} catch (Exception e) {
if (bootstrap.config().debugMode()) {
bootstrap.getGeyserLogger().debug("The handler " + name + " isn't a ChannelInitializer. THIS ERROR IS SAFE TO IGNORE!");
e.printStackTrace();
}
bootstrap.getGeyserLogger().debug("The handler " + name + " isn't a ChannelInitializer. THIS ERROR IS SAFE TO IGNORE!", e);
}
}
if (childHandler == null) {
Expand All @@ -149,8 +147,7 @@ public void shutdown() {
eventLoopGroup.shutdownGracefully().sync();
eventLoopGroup = null;
} catch (Exception e) {
GeyserImpl.getInstance().getLogger().error("Unable to shut down injector! " + e.getMessage());
e.printStackTrace();
GeyserLogger.get().error("Unable to shut down injector!", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ public void debug(String message) {
}
}

@Override
public void debug(String message, Throwable t) {
if (debug) {
logger.info(message, t);
}
}

@Override
public void debug(String message, Object... arguments) {
if (debug) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.command.GeyserCommandSource;
import org.geysermc.geyser.text.ChatColor;

Expand All @@ -60,7 +61,7 @@ public void sendMessage(@NonNull String message) {
if (source.getEntity() instanceof ServerPlayer) {
((ServerPlayer) source.getEntity()).sendSystemMessage(Component.literal(message), false);
} else {
GeyserImpl.getInstance().getLogger().info(ChatColor.toANSI(message + ChatColor.RESET));
GeyserLogger.get().info(ChatColor.toANSI(message + ChatColor.RESET));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import io.netty.channel.ChannelPromise;
import org.bukkit.Bukkit;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserLogger;

/**
* Disables the compression packet (and the compression handlers from being added to the pipeline) for Geyser clients
Expand All @@ -56,7 +57,7 @@ public class GeyserSpigotCompressionDisabler extends ChannelOutboundHandlerAdapt
loginSuccessPacketClass = findLoginSuccessPacket();
enabled = true;
} catch (Exception e) {
GeyserImpl.getInstance().getLogger().error("Could not initialize compression disabler!", e);
GeyserLogger.get().error("Could not initialize compression disabler!", e);
}
COMPRESSION_PACKET_CLASS = compressionPacketClass;
LOGIN_SUCCESS_PACKET_CLASS = loginSuccessPacketClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,7 @@ private ChannelInitializer<Channel> getChildHandler(GeyserBootstrap bootstrap, C
}
break;
} catch (Exception e) {
if (bootstrap.config().debugMode()) {
bootstrap.getGeyserLogger().debug("The handler " + name + " isn't a ChannelInitializer. THIS ERROR IS SAFE TO IGNORE!");
e.printStackTrace();
}
bootstrap.getGeyserLogger().debug("The handler " + name + " isn't a ChannelInitializer. THIS ERROR IS SAFE TO IGNORE!", e);
}
}
if (childHandler == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ public void debug(String message) {
}
}

@Override
public void debug(String message, Throwable t) {
if (debug) {
logger.log(Level.INFO, message, t);
}
}

@Override
public void debug(String message, Object... arguments) {
if (debug) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,7 @@ public void onGeyserEnable() {
}
geyserLogger.debug("Using world manager of type: " + this.geyserWorldManager.getClass().getSimpleName());
} catch (Throwable e) {
if (geyserConfig.debugMode()) {
geyserLogger.debug("Error while attempting to find NMS adapter. Most likely, this can be safely ignored. :)");
e.printStackTrace();
}
geyserLogger.debug("Error while attempting to find NMS adapter. Most likely, this can be safely ignored. :)", e);
}
} else {
geyserLogger.debug("Not using NMS adapter as it is disabled via system property.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package org.geysermc.geyser.platform.spigot;

import org.geysermc.geyser.GeyserLogger;
import org.geysermc.mcprotocollib.protocol.data.DefaultComponentSerializer;
import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender;
Expand Down Expand Up @@ -79,7 +80,7 @@ public final class PaperAdventure {
nativeGsonComponentSerializerDeserializeMethodBound = nativeGsonComponentSerializerDeserializeMethod
.bindTo(nativeGsonComponentSerializerGsonGetter.invoke());
} catch (final Throwable throwable) {
GeyserImpl.getInstance().getLogger().error("Failed to access native GsonComponentSerializer", throwable);
GeyserLogger.get().error("Failed to access native GsonComponentSerializer", throwable);
}
}
}
Expand All @@ -94,31 +95,29 @@ public final class PaperAdventure {
try {
playerComponentSendMessage = CommandSender.class.getMethod("sendMessage", nativeComponentClass);
} catch (final NoSuchMethodException e) {
if (GeyserImpl.getInstance().getLogger().isDebug()) {
e.printStackTrace();
}
GeyserLogger.get().debug("No Paper Adventure component method was found.", e);
}
}
SEND_MESSAGE_COMPONENT = playerComponentSendMessage;
}

public static @Nullable Object toNativeComponent(final Component component) {
if (NATIVE_GSON_COMPONENT_SERIALIZER_DESERIALIZE_METHOD_BOUND == null) {
GeyserImpl.getInstance().getLogger().error("Illegal state where Component serialization was called when it wasn't available!");
GeyserLogger.get().error("Illegal state where Component serialization was called when it wasn't available!");
return null;
}

try {
return NATIVE_GSON_COMPONENT_SERIALIZER_DESERIALIZE_METHOD_BOUND.invoke(DefaultComponentSerializer.get().serialize(component));
} catch (final Throwable throwable) {
GeyserImpl.getInstance().getLogger().error("Failed to create native Component message", throwable);
GeyserLogger.get().error("Failed to create native Component message", throwable);
return null;
}
}

public static void sendMessage(final CommandSender sender, final Component component) {
if (SEND_MESSAGE_COMPONENT == null) {
GeyserImpl.getInstance().getLogger().error("Illegal state where Component sendMessage was called when it wasn't available!");
GeyserLogger.get().error("Illegal state where Component sendMessage was called when it wasn't available!");
return;
}

Expand All @@ -127,7 +126,7 @@ public static void sendMessage(final CommandSender sender, final Component compo
try {
SEND_MESSAGE_COMPONENT.invoke(sender, nativeComponent);
} catch (final InvocationTargetException | IllegalAccessException e) {
GeyserImpl.getInstance().getLogger().error("Failed to send native Component message", e);
GeyserLogger.get().error("Failed to send native Component message", e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.bukkit.command.CommandMap;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.command.CommandRegistry;
import org.geysermc.geyser.command.GeyserCommandSource;
import org.incendo.cloud.CommandManager;
Expand All @@ -55,7 +56,7 @@ public SpigotCommandRegistry(GeyserImpl geyser, CommandManager<GeyserCommandSour
cmdMapField.setAccessible(true);
commandMap = (CommandMap) cmdMapField.get(Bukkit.getServer());
} catch (Exception ex) {
geyser.getLogger().error("Failed to get Spigot's CommandMap", ex);
GeyserLogger.get().error("Failed to get Spigot's CommandMap", ex);
}
}
this.commandMap = commandMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
private GeyserStandaloneGUI gui;
@Getter
private boolean useGui = System.console() == null && !isHeadless();
@Getter
private Logger log4jLogger;
private String configFilename = "config.yml";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ public void debug(@Nullable Object object) {
log.debug("{}", object);
}

@Override
public void debug(String message, Throwable t) {
log.debug(ChatColor.GRAY + "{}", message, t);
}

@Override
public void debug(String message, Object... arguments) {
// We can't use the debug call that would format for us as we're using Java's string formatting
Expand All @@ -130,6 +135,8 @@ public void debug(String message, Object... arguments) {
@Override
public void setDebug(boolean debug) {
Configurator.setLevel(log.getName(), debug ? Level.DEBUG : Level.INFO);
// Hacky, yes, does it work? Also yes.
((GeyserStandaloneBootstrap) GeyserImpl.getInstance().getBootstrap()).getLog4jLogger().get().setLevel(debug ? Level.DEBUG : Level.INFO);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserLogger;

import java.lang.reflect.Method;

Expand Down Expand Up @@ -61,7 +62,7 @@ public class GeyserVelocityCompressionDisabler extends ChannelDuplexHandler {
.getMethod("setCompressionThreshold", int.class);
enabled = true;
} catch (Exception e) {
GeyserImpl.getInstance().getLogger().error("Could not initialize compression disabler!", e);
GeyserLogger.get().error("Could not initialize compression disabler!", e);
}

ENABLED = enabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ public void debug(String message) {
}
}

@Override
public void debug(String message, Throwable t) {
if (debug) {
logger.info(message, t);
}
}

@Override
public void debug(String message, Object... arguments) {
if (debug) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,7 @@ public MetricsPlatform createMetricsPlatform() {
try {
return new VelocityMetrics(this.configFolder);
} catch (IOException e) {
this.geyserLogger.debug("Integrated bStats support failed to load.");
if (this.config().debugMode()) {
e.printStackTrace();
}
this.geyserLogger.debug("Integrated bStats support failed to load.", e);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ public void debug(@Nullable Object object) {
}
}

@Override
public void debug(String message, Throwable t) {
if (this.debug) {
this.logger.debug(ConsoleFormatter.convert(message), t);
}
}

@Override
public void debug(String message, Object... arguments) {
if (this.debug) {
Expand Down
Loading