chore: clean up logging

This commit is contained in:
Johannes Frohnmeyer 2024-09-23 14:55:35 +02:00
parent dc2a35dcc9
commit 42e6b1a03f
Signed by: Johannes
GPG Key ID: E76429612C2929F4
2 changed files with 4 additions and 6 deletions

View File

@ -72,7 +72,7 @@ public class GoogleChat implements ModInitializer {
translated.append(translateIfNeeded(sibling, direction, false));
}
}
if (GoogleChatConfig.Advanced.debugLogs) LOGGER.info("Translated " + sourceString + " to " + toString(translated));
if (GoogleChatConfig.Advanced.debugLogs) LOGGER.info("Translated {0} to {1}", sourceString, toString(translated));
if (GoogleChatConfig.General.translationTooltip) {
return t.copy().styled(style -> addHover(style, Text.literal("Translated: ").append(translated)));
} else if (translated.getStyle().getHoverEvent() == null) {
@ -113,7 +113,7 @@ public class GoogleChat implements ModInitializer {
} else if (t instanceof PlainTextContent.Literal tx) {
return new PlainTextContent.Literal(translateIfNeeded(tx.string(), direction, false));
} else {
// LOGGER.info("Unhandled text type: " + source.getClass() + " (" + source + ")");
// LOGGER.info("Unhandled text type: {0} ({1}})", source.getClass().toString(), source.toString());
return t;
}
});
@ -149,7 +149,7 @@ public class GoogleChat implements ModInitializer {
//noinspection unchecked
return m.group(1) + svc.translate(m.group(2), sourceLang, targetLang) + m.group(3);
} catch (Throwable e) {
LOGGER.error("Could not translate text: " + source, e);
LOGGER.error("Could not translate text: {0}", e, source);
return source;
}
});

View File

@ -5,8 +5,6 @@ import net.minecraft.text.Text;
import java.util.concurrent.CompletableFuture;
import static io.gitlab.jfronny.libjf.LibJf.LOGGER;
public sealed interface TranslatableContainer<T, S extends TranslatableContainer<T, S>> {
S translate(TranslationDirection direction);
@ -26,7 +24,7 @@ public sealed interface TranslatableContainer<T, S extends TranslatableContainer
static Text translateAndLog(final Text source, final TranslationDirection direction) {
var translated = GoogleChat.translateIfNeeded(source, direction, true);
if (GoogleChatConfig.Advanced.debugLogs) LOGGER.info("Applied C2S translation from {0} to {1}", source, translated);
if (GoogleChatConfig.Advanced.debugLogs) GoogleChat.LOGGER.info("Applied C2S translation from {0} to {1}", source, translated);
return translated;
}
}