Skip to content

Commit

Permalink
use logger wildcards better
Browse files Browse the repository at this point in the history
  • Loading branch information
sisby-folk committed Jan 26, 2024
1 parent 4933f6e commit 11ad0fd
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public void onInitializeClient() {
ClientCommandRegistrationCallback.EVENT.register(SwitchyClientCommands::register);
SwitchyClientEvents.registerEntrypointListeners();
SwitchyClientEvents.INIT.invoker().onInitialize();
LOGGER.info("[Switchy Client] Initialized! Registered Modules: " + SwitchyClientModuleRegistry.getModules());
LOGGER.info("[Switchy Client] Initialized! Registered Modules: {}", SwitchyClientModuleRegistry.getModules());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void registerModule(Identifier id, Supplier<SwitchyClientModule> m
throw new IllegalArgumentException("Specified id is already registered");
}
SUPPLIERS.put(id, moduleConstructor);
SwitchyClient.LOGGER.info("[Switchy Client] Registered client module " + id);
SwitchyClient.LOGGER.info("[Switchy Client] Registered client module {}", id);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void applyToPlayer(ServerPlayerEntity player) {
drogtorPlayer.drogtor$setNickname(nickname);
String newName = player.getDisplayName().getString();
if (!Objects.equals(oldName, newName))
SwitchyCompat.LOGGER.info("[Switchy Compat] Player Nickname Change: '" + oldName + "' -> '" + newName + "' [" + player.getGameProfile().getName() + "]");
SwitchyCompat.LOGGER.info("[Switchy Compat] Player Nickname Change: '{}' -> '{}' [{}]", oldName, newName, player.getGameProfile().getName());
drogtorPlayer.drogtor$setNameColor(nameColor);
drogtorPlayer.drogtor$setBio(bio);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void fillFromNbt(NbtCompound nbt) {
for (int i = 0; i < nbtList.size(); i++) {
EquipmentSlot slot = Enums.getIfPresent(EquipmentSlot.class, nbtList.getString(i).toUpperCase(Locale.ROOT)).orNull();
if (slot == null) {
SwitchyCompat.LOGGER.warn("[Switchy Compat] Unrecognized slot " + nbtList.getString(i) + " while loading profile");
SwitchyCompat.LOGGER.warn("[Switchy Compat] Unrecognized slot {} while loading profile", nbtList.getString(i));
} else {
suppressedSlots.add(slot);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void applyToPlayer(ServerPlayerEntity player) {
if (styled_nickname != null) holder.sn_set(styled_nickname, false);
String newName = player.getDisplayName().getString();
if (!Objects.equals(oldName, newName))
SwitchyCompat.LOGGER.info("[Switchy] Player Nickname Change: '" + oldName + "' -> '" + newName + "' [" + player.getGameProfile().getName() + "]");
SwitchyCompat.LOGGER.info("[Switchy Compat] Player Nickname Change: '{}' -> '{}' [{}]", oldName, newName, player.getGameProfile().getName());
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/folk/sisby/switchy/Switchy.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void onInitialize() {
ServerPlayConnectionEvents.DISCONNECT.register(SwitchyPlayConnectionListener::onPlayDisconnect);
SwitchyEvents.registerEntrypointListeners();
SwitchyEvents.INIT.invoker().onInitialize();
Switchy.LOGGER.info("[Switchy] Initialized! Registered Modules: " + SwitchyModuleRegistry.getModules());
Switchy.LOGGER.info("[Switchy] Initialized! Registered Modules: {}", SwitchyModuleRegistry.getModules());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static void registerModule(Identifier id, Supplier<SwitchyModule> moduleC
} else {
Switchy.CONFIG.moduleEditableReadOnly.put(id.toString(), moduleInfo.editable());
}
Switchy.LOGGER.info("[Switchy] Registered module " + id);
Switchy.LOGGER.info("[Switchy] Registered module {}", id);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ static void tryApplyModule(Map<Identifier, SwitchyModule> modules, Identifier id
SwitchyModuleRegistry.getApplyDependencies(id).forEach((depId) -> tryApplyModule(modules, depId, player, registeredModules));
module.applyToPlayer(player);
} catch (Exception ex) {
Switchy.LOGGER.error("[Switchy] Module " + id + " failed to apply! Error:");
Switchy.LOGGER.error(ex.toString());
Switchy.LOGGER.error("[Switchy] Module {} failed to update! Error:", id, ex);
}
registeredModules.add(id);
}
Expand All @@ -50,8 +49,7 @@ public void updateFromPlayer(ServerPlayerEntity player, String nextPreset) {
try {
module.updateFromPlayer(player, nextPreset);
} catch (Exception ex) {
Switchy.LOGGER.error("[Switchy] Module " + id + " failed to update! Error:");
Switchy.LOGGER.error(ex.toString());
Switchy.LOGGER.error("[Switchy] Module {} failed to update! Error:", id, ex);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void toggleModulesFromNbt(NbtList list, Boolean enabled, Boolean silent) {
modules.put(id, enabled);
} else if (!silent) {
logger.warn("[Switchy] Unable to toggle a module - Was a module unloaded?");
logger.warn("[Switchy] Key: " + e.asString());
logger.warn("[Switchy] Key: {}", e.asString());
if (id != null) {
logger.warn("[Switchy] Saved as lost puppy {} module.", enabled ? "enabled" : "disabled");
backup.put(id, enabled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public String switchCurrentPreset(ServerPlayerEntity player, String name) throws
);
setCurrentPreset(nextPreset.getName());
SwitchyEvents.SWITCH.invoker().onSwitch(player, switchEvent);
LOGGER.info("[Switchy] Player switch: '" + oldPreset.getName() + "' -> '" + getCurrentPresetName() + "' [" + player.getGameProfile().getName() + "]");
LOGGER.info("[Switchy] Player switch: '{}' -> '{}' [{}]", oldPreset.getName(), getCurrentPresetName(), player.getGameProfile().getName());

return getCurrentPresetName();
}
Expand Down

0 comments on commit 11ad0fd

Please sign in to comment.