Some logging changes
This commit is contained in:
+9
-7
@@ -1,14 +1,16 @@
|
||||
package com.seibel.distanthorizons.core.multiplayer.client;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.config.types.ConfigEntry;
|
||||
import com.seibel.distanthorizons.core.dataObjects.fullData.accessor.ChunkSizedFullDataAccessor;
|
||||
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.CompleteFullDataSource;
|
||||
import com.seibel.distanthorizons.core.level.IDhClientLevel;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.logging.ConfigBasedSpamLogger;
|
||||
import com.seibel.distanthorizons.core.logging.f3.F3Screen;
|
||||
import com.seibel.distanthorizons.core.network.exceptions.InvalidLevelException;
|
||||
import com.seibel.distanthorizons.core.network.exceptions.RateLimitedException;
|
||||
import com.seibel.distanthorizons.core.network.exceptions.RequestRejectedException;
|
||||
import com.seibel.distanthorizons.core.network.messages.fullData.generation.FullDataSourceRequestMessage;
|
||||
import com.seibel.distanthorizons.core.network.messages.fullData.generation.FullDataSourceResponseMessage;
|
||||
import com.seibel.distanthorizons.core.pos.DhBlockPos2D;
|
||||
@@ -18,7 +20,7 @@ import com.seibel.distanthorizons.core.render.renderer.IDebugRenderable;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import com.seibel.distanthorizons.core.util.ratelimiting.SupplierBasedRateLimiter;
|
||||
import io.netty.channel.ChannelException;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -32,7 +34,8 @@ import java.util.function.Consumer;
|
||||
|
||||
public abstract class AbstractFullDataRequestQueue implements IDebugRenderable, AutoCloseable
|
||||
{
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
private static final ConfigBasedSpamLogger LOGGER = new ConfigBasedSpamLogger(LogManager.getLogger(),
|
||||
() -> Config.Client.Advanced.Logging.logNetworkEvent.get(), 3);
|
||||
|
||||
protected static final long SHUTDOWN_TIMEOUT_SECONDS = 5;
|
||||
|
||||
@@ -81,7 +84,7 @@ public abstract class AbstractFullDataRequestQueue implements IDebugRenderable,
|
||||
if (this.alreadyRequestedPositions.contains(sectionPos))
|
||||
{
|
||||
// temporary solution to prevent requesting the same section multiple times
|
||||
LOGGER.trace("Duplicate section " + sectionPos + ". Skipping...");
|
||||
LOGGER.debug("Duplicate section " + sectionPos + ". Skipping...");
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
this.alreadyRequestedPositions.add(sectionPos);
|
||||
@@ -169,7 +172,6 @@ public abstract class AbstractFullDataRequestQueue implements IDebugRenderable,
|
||||
}
|
||||
|
||||
this.waitingTasks.remove(sectionPos);
|
||||
LOGGER.debug("FullDataSourceResponseMessage " + sectionPos);
|
||||
|
||||
CompleteFullDataSource fullDataSource = response.getFullDataSource(sectionPos, this.level);
|
||||
|
||||
@@ -183,9 +185,9 @@ public abstract class AbstractFullDataRequestQueue implements IDebugRenderable,
|
||||
LodUtil.assertTrue(this.changedOnly, "Received empty data source response for not changed-only request");
|
||||
}
|
||||
}
|
||||
catch (InvalidLevelException ignored)
|
||||
catch (InvalidLevelException | RequestRejectedException ignored)
|
||||
{
|
||||
// We're too late
|
||||
// We're too late / some cases might trigger a bunch of expected rejections
|
||||
}
|
||||
catch (ChannelException | RateLimitedException e)
|
||||
{
|
||||
|
||||
+8
-5
@@ -1,22 +1,24 @@
|
||||
package com.seibel.distanthorizons.core.multiplayer.client;
|
||||
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.logging.ConfigBasedLogger;
|
||||
import com.seibel.distanthorizons.core.multiplayer.config.MultiplayerConfig;
|
||||
import com.seibel.distanthorizons.core.multiplayer.config.MultiplayerConfigChangeListener;
|
||||
import com.seibel.distanthorizons.core.network.ScopedNetworkEventSource;
|
||||
import com.seibel.distanthorizons.core.network.NetworkClient;
|
||||
import com.seibel.distanthorizons.core.network.ScopedNetworkEventSource;
|
||||
import com.seibel.distanthorizons.core.network.messages.base.AckMessage;
|
||||
import com.seibel.distanthorizons.core.network.messages.base.HelloMessage;
|
||||
import com.seibel.distanthorizons.core.network.messages.session.PlayerUUIDMessage;
|
||||
import com.seibel.distanthorizons.core.network.messages.session.RemotePlayerConfigMessage;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ClientNetworkState implements Closeable
|
||||
{
|
||||
protected static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
protected static final ConfigBasedLogger LOGGER = new ConfigBasedLogger(LogManager.getLogger(),
|
||||
() -> Config.Client.Advanced.Logging.logNetworkEvent.get());
|
||||
|
||||
private final NetworkClient client;
|
||||
private final UUID playerUUID;
|
||||
@@ -50,7 +52,7 @@ public class ClientNetworkState implements Closeable
|
||||
{
|
||||
LOGGER.info("Connected to server: "+helloMessage.getConnection().getRemoteAddress());
|
||||
|
||||
this.getClient().sendRequest(new PlayerUUIDMessage(playerUUID), AckMessage.class)
|
||||
this.getClient().sendRequest(new PlayerUUIDMessage(this.playerUUID), AckMessage.class)
|
||||
.thenAccept(ack -> this.getClient().sendMessage(new RemotePlayerConfigMessage(new MultiplayerConfig())))
|
||||
.exceptionally(throwable -> {
|
||||
LOGGER.error("Error while fetching server's config", throwable);
|
||||
@@ -70,6 +72,7 @@ public class ClientNetworkState implements Closeable
|
||||
this.getClient().sendMessage(new RemotePlayerConfigMessage(new MultiplayerConfig()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
this.configChangeListener.close();
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.seibel.distanthorizons.core.network.messages.base.ExceptionMessage;
|
||||
import com.seibel.distanthorizons.core.network.protocol.FutureTrackableNetworkMessage;
|
||||
import com.seibel.distanthorizons.core.network.protocol.MessageRegistry;
|
||||
import com.seibel.distanthorizons.core.network.protocol.NetworkMessage;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
import io.netty.channel.ChannelException;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
@@ -93,7 +94,7 @@ public abstract class NetworkEventSource
|
||||
}
|
||||
}
|
||||
|
||||
if (!handled && message.warnWhenUnhandled())
|
||||
if (!handled && ModInfo.IS_DEV_BUILD && message.warnWhenUnhandled())
|
||||
{
|
||||
LOGGER.warn("Unhandled message: " + message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user