Switch to log4j2 logging
This commit is contained in:
@@ -11,6 +11,8 @@ import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftEncoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftVarintFrameDecoder;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftVarintLengthEncoder;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
@@ -45,6 +47,8 @@ import static com.velocitypowered.network.Connections.MINECRAFT_ENCODER;
|
||||
import static com.velocitypowered.network.Connections.READ_TIMEOUT;
|
||||
|
||||
public final class ConnectionManager {
|
||||
private static final org.apache.logging.log4j.Logger logger = LogManager.getLogger(ConnectionManager.class);
|
||||
|
||||
private static final String DISABLE_EPOLL_PROPERTY = "velocity.connection.disable-epoll";
|
||||
private static final boolean DISABLE_EPOLL = Boolean.getBoolean(DISABLE_EPOLL_PROPERTY);
|
||||
private final Set<Channel> endpoints = new HashSet<>();
|
||||
@@ -71,12 +75,12 @@ public final class ConnectionManager {
|
||||
|
||||
private void logChannelInformation(final boolean epoll) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("Channel type: ");
|
||||
sb.append("Using channel type ");
|
||||
sb.append(epoll ? "epoll": "nio");
|
||||
if(DISABLE_EPOLL) {
|
||||
sb.append(String.format(" - epoll explicitly disabled using -D%s=true", DISABLE_EPOLL_PROPERTY));
|
||||
}
|
||||
System.out.println(sb.toString()); // TODO: move to logger
|
||||
logger.info(sb.toString()); // TODO: move to logger
|
||||
}
|
||||
|
||||
public void bind(final InetSocketAddress address) {
|
||||
@@ -109,10 +113,9 @@ public final class ConnectionManager {
|
||||
final Channel channel = future.channel();
|
||||
if (future.isSuccess()) {
|
||||
this.endpoints.add(channel);
|
||||
System.out.println("Listening on " + channel.localAddress()); // TODO: move to logger
|
||||
logger.info("Listening on {}", channel.localAddress());
|
||||
} else {
|
||||
System.out.println("Can't bind to " + channel.localAddress()); // TODO: move to logger
|
||||
future.cause().printStackTrace();
|
||||
logger.error("Can't bind to {}", address, future.cause());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -126,11 +129,10 @@ public final class ConnectionManager {
|
||||
public void shutdown() {
|
||||
for (final Channel endpoint : this.endpoints) {
|
||||
try {
|
||||
System.out.println(String.format("Closing endpoint %s", endpoint.localAddress())); // TODO: move to logger
|
||||
logger.info("Closing endpoint {}", endpoint.localAddress());
|
||||
endpoint.close().sync();
|
||||
} catch (final InterruptedException e) {
|
||||
System.err.println("Interrupted whilst closing endpoint"); // TODO: move to logger
|
||||
e.printStackTrace();
|
||||
logger.info("Interrupted whilst closing endpoint", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,8 @@ import com.velocitypowered.proxy.connection.backend.ServerConnection;
|
||||
import com.velocitypowered.proxy.data.ServerInfo;
|
||||
import com.velocitypowered.proxy.util.EncryptionUtils;
|
||||
import com.velocitypowered.proxy.util.UuidUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URL;
|
||||
@@ -21,6 +23,8 @@ import java.util.Arrays;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
private static final Logger logger = LogManager.getLogger(LoginSessionHandler.class);
|
||||
|
||||
private static final String MOJANG_SERVER_AUTH_URL =
|
||||
"https://sessionserver.mojang.com/session/minecraft/hasJoined?username=%s&serverId=%s&ip=%s";
|
||||
|
||||
@@ -71,8 +75,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
handleSuccessfulLogin(profile);
|
||||
}, inbound.getChannel().eventLoop())
|
||||
.exceptionally(exception -> {
|
||||
System.out.println("Can't enable encryption");
|
||||
exception.printStackTrace();
|
||||
logger.error("Unable to enable encryption", exception);
|
||||
inbound.close();
|
||||
return null;
|
||||
});
|
||||
|
Reference in New Issue
Block a user