Skip to content

Commit

Permalink
internal: minor logging cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTJP committed Dec 11, 2023
1 parent 4626585 commit 9a26071
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ private void enterState(int id, boolean force) {
currentState = id;
states[currentState].onStateEntered(oldState);

LOGGER.info("State transition: " + oldState + " -> " + currentState);
LOGGER.debug("State transition: " + oldState + " -> " + currentState);
editor.markDirty();
}

Expand All @@ -269,7 +269,7 @@ private void enterStateOnClient(int id) {
currentState = id;
states[currentState].onClientStateEntered(oldState);

LOGGER.info("Client state transition: " + oldState + " -> " + currentState);
LOGGER.debug("Client state transition: " + oldState + " -> " + currentState);
}

public interface StateMachineCallback {
Expand Down Expand Up @@ -485,7 +485,7 @@ public void onTick(long time) {
public void onInputRegistersChanged(int rotation, Function<Short, Short> changeFunction) {
short oldInput = simulationContainer.getInput(rotation);
short newInput = changeFunction.apply(oldInput);
LOGGER.info("oldInput: " + oldInput + ", newInput: " + newInput);
LOGGER.debug("oldInput: " + oldInput + ", newInput: " + newInput);
if (oldInput != newInput) {
simulationContainer.setInput(rotation, newInput);
simulationContainer.pushInputs(1 << rotation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public boolean isActive() {

//region ICWorkbenchTile utilities
public void save(CompoundTag tag) {
LOGGER.info("ICWorkbenchEditor: saving to NBT");
LOGGER.debug("ICWorkbenchEditor: saving to NBT");
tag.putInt(KEY_FORMAT, EDITOR_FORMAT);
tag.putBoolean(KEY_ACTIVE, isActive);
tag.putString(KEY_IC_NAME, icName);
Expand All @@ -92,31 +92,27 @@ public void save(CompoundTag tag) {
}

public void load(CompoundTag tag) {
LOGGER.info("ICWorkbenchEditor: reading form NBT");
isActive = tag.getBoolean(KEY_ACTIVE);
icName = tag.getString(KEY_IC_NAME);
tileMap.load(tag.getCompound(KEY_TILE_MAP));
stateMachine.load(tag);
}

public void writeDesc(MCDataOutput out) {
LOGGER.info("ICWorkbenchEditor: writing description");
out.writeBoolean(isActive);
out.writeString(icName);
tileMap.writeDesc(out);
stateMachine.writeDesc(out);
}

public void readDesc(MCDataInput in) {
LOGGER.info("ICWorkbenchEditor: Reading description");
isActive = in.readBoolean();
icName = in.readString();
tileMap.readDesc(in);
stateMachine.readDesc(in);
}

private void clear() {
LOGGER.info("ICWorkbenchEditor: Preparing load of initial data (Should be server only)");
tileMap.removeAll();
stateMachine.reset();
icName = "untitled";
Expand Down Expand Up @@ -310,17 +306,17 @@ public void sendNewICName(String name) {
//region State Machine callbacks
@Override
public void onCompileStart() {
LOGGER.info("Compiling...");
LOGGER.debug("Compiling...");
}

@Override
public void onCompileComplete() {
LOGGER.info("Compilation complete");
LOGGER.debug("Compilation complete");
}

@Override
public void onCompileFailed() {
LOGGER.info("Compilation failed");
LOGGER.debug("Compilation failed");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import mrtjp.projectred.fabrication.engine.ICSimulationContainer;
import mrtjp.projectred.fabrication.engine.IIOConnectionTile;
import mrtjp.projectred.fabrication.engine.IRotatableICTile;
import mrtjp.projectred.fabrication.engine.log.MultipleDriversError;
import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -97,7 +98,6 @@ public ICInterfaceType getInterfaceType() {
}

protected void toggleWorldInput() {
LOGGER.info("Toggling world input");
getEditor().getStateMachine().onInputRegistersChanged(getIOSide(), i -> (short) (i ^ (1<<colour)));
}

Expand Down Expand Up @@ -230,8 +230,7 @@ public void locate(IPathFinder pathFinder) {
int absDir = IRotatableICTile.rotationToDir(absR);
PathFinderResult pfr = pathFinder.doPathFinding((d, p) -> d == absDir);
if (pfr.outputRegisters.size() > 1) {
// TODO log this somewhere
System.out.println("ERR: Unexpected multiple drivers: " + pfr.outputRegisters);
getEditor().getStateMachine().getCompilerLog().addProblem(new MultipleDriversError(getPos(), pfr.outputRegisters));
}
if (!pfr.outputRegisters.isEmpty()) {
regId = pfr.outputRegisters.get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,11 @@ public void drawBack(PoseStack stack, Point mouse, float partialFrame) {
public void removed() {
super.removed();
tile.closeGuiFromClient();
ProjectRedFabrication.LOGGER.info("ICWorkbenchScreen REMOVED");
}

@Override
public void onClose() {
super.onClose();
ProjectRedFabrication.LOGGER.info("ICWorkbenchScreen ONCLOSE");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ private void setBlueprintBlockState(boolean blueprintOnTable) {
private void openGuiFromServer(Player player) {
if (getLevel().isClientSide || !(player instanceof ServerPlayer)) { throw new RuntimeException("Server only"); }
filterAndGetWatchers().add((ServerPlayer) player);
LOGGER.info("Watcher added. Size: " + playersWatchingScreen.size());
sendUpdateToPlayer(KEY_CLIENT_OPENED_SCREEN, editor::writeDesc, (ServerPlayer) player);
}

Expand Down Expand Up @@ -186,7 +185,6 @@ public void receiveUpdateFromClient(int key, MCDataInput input, ServerPlayer pla
switch (key) {
case KEY_CLIENT_CLOSED_SCREEN: // Client closed screen
filterAndGetWatchers().remove(player);
LOGGER.info("Watcher removed. Size: " + playersWatchingScreen.size());
break;
case KEY_EDITOR_PACKET: // Some packet for the editor
receiveBufferedStream(input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.util.Objects;

import static mrtjp.projectred.integration.ProjectRedIntegration.LOGGER;
import static mrtjp.projectred.integration.ProjectRedIntegration.MOD_ID;

public class IntegrationNetwork {
Expand Down Expand Up @@ -128,7 +129,7 @@ private void handleIncrCounterMessage(Level world, PacketCustom packet) {
gate.setCounterDecr(gate.getCounterDecr() + packet.readShort());
break;
default:
System.err.println("Unknown counter action id: " + actionId);
LOGGER.error("Unknown counter action id: " + actionId);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import static mrtjp.projectred.integration.ProjectRedIntegration.MOD_ID;

Expand All @@ -27,6 +29,8 @@ public class ProjectRedIntegration {

public static final String MOD_ID = "projectred_integration";

public static final Logger LOGGER = LogManager.getLogger(MOD_ID);

public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID);
public static final DeferredRegister<MultipartType<?>> PARTS = DeferredRegister.create(MultipartType.MULTIPART_TYPES, MOD_ID);

Expand Down

0 comments on commit 9a26071

Please sign in to comment.