add topics for logging
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m53s

This commit is contained in:
Lee 2024-04-19 23:24:51 +01:00
parent e5935c6696
commit cf8e27f039
14 changed files with 22 additions and 22 deletions

@ -13,7 +13,7 @@ import java.nio.file.Files;
import java.nio.file.StandardCopyOption; import java.nio.file.StandardCopyOption;
import java.util.Objects; import java.util.Objects;
@Log4j2 @Log4j2(topic = "Main")
@SpringBootApplication @SpringBootApplication
public class Main { public class Main {
public static final Gson GSON = new GsonBuilder() public static final Gson GSON = new GsonBuilder()

@ -10,7 +10,7 @@ import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@Log4j2 @Log4j2(topic = "Image Utils")
public class ImageUtils { public class ImageUtils {
/** /**
* Scale the given image to the provided size. * Scale the given image to the provided size.

@ -12,7 +12,7 @@ import java.net.http.HttpRequest;
import java.net.http.HttpResponse; import java.net.http.HttpResponse;
import java.util.UUID; import java.util.UUID;
@UtilityClass @Log4j2 @UtilityClass @Log4j2(topic = "Player Utils")
public class PlayerUtils { public class PlayerUtils {
/** /**

@ -11,7 +11,7 @@ import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@Log4j2 @Log4j2(topic = "Skin Renderer")
public abstract class SkinRenderer<T extends ISkinPart> { public abstract class SkinRenderer<T extends ISkinPart> {
/** /**

@ -11,7 +11,7 @@ import xyz.mcutils.backend.model.skin.Skin;
import java.awt.*; import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@AllArgsConstructor @Getter @Log4j2 @AllArgsConstructor @Getter @Log4j2(topic = "Skin Renderer/Body")
public class BodyRenderer extends SkinRenderer<ISkinPart.Custom> { public class BodyRenderer extends SkinRenderer<ISkinPart.Custom> {
public static final BodyRenderer INSTANCE = new BodyRenderer(); public static final BodyRenderer INSTANCE = new BodyRenderer();

@ -10,7 +10,7 @@ import xyz.mcutils.backend.model.skin.Skin;
import java.awt.*; import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@AllArgsConstructor @Getter @Log4j2 @AllArgsConstructor @Getter @Log4j2(topic = "Skin Renderer/Square")
public class SquareRenderer extends SkinRenderer<ISkinPart.Vanilla> { public class SquareRenderer extends SkinRenderer<ISkinPart.Vanilla> {
public static final SquareRenderer INSTANCE = new SquareRenderer(); public static final SquareRenderer INSTANCE = new SquareRenderer();

@ -14,7 +14,7 @@ import org.springframework.web.filter.ShallowEtagHeaderFilter;
import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Getter @Log4j2 @Getter @Log4j2(topic = "Config")
@Configuration @Configuration
public class Config { public class Config {
public static Config INSTANCE; public static Config INSTANCE;

@ -19,7 +19,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
@AllArgsConstructor @NoArgsConstructor @AllArgsConstructor @NoArgsConstructor
@Getter @Log4j2 @EqualsAndHashCode @Getter @Log4j2(topic = "Skin") @EqualsAndHashCode
public class Skin { public class Skin {
/** /**
* The URL for the skin * The URL for the skin

@ -20,7 +20,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@Service @Log4j2 @Service @Log4j2(topic = "Metric Service")
public class MetricService { public class MetricService {
/** /**
* The metrics that are registered. * The metrics that are registered.

@ -28,7 +28,7 @@ import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@Service @Log4j2 @Getter @Service @Log4j2(topic = "Mojang Service") @Getter
public class MojangService { public class MojangService {
/** /**

@ -26,7 +26,7 @@ import java.awt.image.BufferedImage;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
@Service @Log4j2 @Service @Log4j2(topic = "Player Service")
public class PlayerService { public class PlayerService {
private final MojangService mojangAPIService; private final MojangService mojangAPIService;

@ -23,7 +23,7 @@ import java.util.Base64;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@Service @Log4j2 @Service @Log4j2(topic = "Server Service")
public class ServerService { public class ServerService {
private static final String DEFAULT_SERVER_ICON = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAASFBMVEWwsLBBQUE9PT1JSUlFRUUuLi5MTEyzs7M0NDQ5OTlVVVVQUFAmJia5ubl+fn5zc3PFxcVdXV3AwMCJiYmUlJRmZmbQ0NCjo6OL5p+6AAAFVklEQVRYw+1W67K0KAzkJnIZdRAZ3/9NtzvgXM45dX7st1VbW7XBUVDSdEISRqn/5R+T82/+nsr/XZn/SHm/3x9/ArA/IP8qwPK433d44VubZ/XT6/cJy0L792VZfnDrcRznr86d748u92X5vtaxOe228zcCy+MSMpg/5SwRopsYMv8oigCwngbQhE/rzhwAYMpxnvMvHhgy/8AgByJolzb5pPqEbvtgMBBmtvkbgxKmaaIZ5TyPum6Viue6te241N+s+W6nOlucgjEx6Nay9zZta1XVxejW+Q5ZhhkDS31lgOTegjUBor33CQilbC2GYGy9y9bN8ytevjE4a2stajHDAgAcUkoYwzO6zQi8ZflC+XO0+exiuNa3OQtIJOCk13neUjv7VO7Asu/3LwDFeg37sQtQhy4lAQH6IR9ztca0E3oI5PtDAlJ1tHGplrJ12jjrrXPWYvXsU042Bl/qUr3B9qzPSKaovpvjgglYL2F1x+Zs7gIvpLYuq46wr3H5/RJxyvM6sXOY762oU4YZ3mAz1lpc9O3Y30VJUM/iWhBIib63II/LA4COEMxcSmrH4ddl/wTYe3RIO0vK2VI9wQy6AxRsJpb3AAALvXb6TxvUCYSdOQo5Mh0GySkJc7rB405GUEfzbbl/iFpPoNQVNUQAZG06nkI6RCABRqRA9IimH6Up5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0Lfh9X4ac9XgKW86cj8bPh8XmyDOD88FLoB+YPXp4YtyB3gBPXu98xeRI2zploVCBQAAAABJRU5ErkJggg=="; private static final String DEFAULT_SERVER_ICON = "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";

@ -50,19 +50,18 @@ public final class BedrockMinecraftServerPinger implements MinecraftServerPinger
unconnectedPong.process(socket); unconnectedPong.process(socket);
String response = unconnectedPong.getResponse(); String response = unconnectedPong.getResponse();
if (response == null) { // No pong response if (response == null) { // No pong response
throw new ResourceNotFoundException("Server didn't respond to ping"); throw new ResourceNotFoundException("Server '%s' didn't respond to ping".formatted(hostname));
} }
return BedrockMinecraftServer.create(hostname, ip, port, records, response); // Return the server return BedrockMinecraftServer.create(hostname, ip, port, records, response); // Return the server
} catch (IOException ex ) { } catch (IOException ex ) {
if (ex instanceof UnknownHostException) { if (ex instanceof UnknownHostException) {
throw new BadRequestException("Unknown hostname: %s".formatted(hostname)); throw new BadRequestException("Unknown hostname '%s'".formatted(hostname));
} else if (ex instanceof SocketTimeoutException) { } else if (ex instanceof SocketTimeoutException) {
throw new ResourceNotFoundException(ex); throw new ResourceNotFoundException("Server '%s' didn't respond to ping".formatted(hostname));
} else if (ex instanceof SocketException) { } else {
throw new BadRequestException("An error occurred pinging %s:%s".formatted(hostname, port));
}
log.error("An error occurred pinging %s:%s:".formatted(hostname, port), ex); log.error("An error occurred pinging %s:%s:".formatted(hostname, port), ex);
} throw new BadRequestException("An error occurred pinging '%s:%s'".formatted(hostname, port));
return null; }
}
} }
} }

@ -50,10 +50,11 @@ public final class JavaMinecraftServerPinger implements MinecraftServerPinger<Ja
if (ex instanceof UnknownHostException) { if (ex instanceof UnknownHostException) {
throw new BadRequestException("Unknown hostname: %s".formatted(hostname)); throw new BadRequestException("Unknown hostname: %s".formatted(hostname));
} else if (ex instanceof ConnectException || ex instanceof SocketTimeoutException) { } else if (ex instanceof ConnectException || ex instanceof SocketTimeoutException) {
throw new ResourceNotFoundException(ex); throw new ResourceNotFoundException("Server '%s' didn't respond to ping".formatted(hostname));
} } else {
log.error("An error occurred pinging %s".formatted(ServerUtils.getAddress(hostname, port)), ex); log.error("An error occurred pinging %s:%s:".formatted(hostname, port), ex);
} throw new BadRequestException("An error occurred pinging '%s:%s'".formatted(hostname, port));
return null; }
}
} }
} }