Skip to content

Commit

Permalink
Replace stdout with logger (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommaso Dordoni committed May 22, 2023
1 parent ca3b398 commit f80d9b6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
11 changes: 8 additions & 3 deletions src/main/java/kaptainwutax/seedcrackerX/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@
import kaptainwutax.seedcrackerX.Features;
import kaptainwutax.seedcrackerX.util.FeatureToggle;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.*;

public class Config {
public static Logger logger = LoggerFactory.getLogger("config");

private static final File file = new File(net.fabricmc.loader.api.FabricLoader.getInstance().getConfigDir().toFile(), "seedcracker.json");
private static Config INSTANCE = new Config();
public FeatureToggle buriedTreasure = new FeatureToggle(true);
Expand Down Expand Up @@ -43,7 +48,7 @@ public static void save() {

gson.toJson(INSTANCE, writer);
} catch (IOException e) {
System.out.println("seedcracker could't save config");
logger.error("seedcracker could't save config");
e.printStackTrace();
}
}
Expand All @@ -55,10 +60,10 @@ public static void load() {
INSTANCE = gson.fromJson(reader, Config.class);
} catch (Exception e) {
if (file.exists()) {
System.out.println("seedcracker couldn't load config, deleting it...");
logger.error("seedcracker couldn't load config, deleting it...");
file.delete();
} else {
System.out.println("seedcracker couldn't find config");
logger.warn("seedcracker couldn't find config");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
import java.util.List;
import java.util.Scanner;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class StructureSave {
public static Logger logger = LoggerFactory.getLogger("structureSave");

public static final File saveDir = new File(FabricLoader.getInstance().getConfigDir().toFile(), "SeedCrackerX saved structures");
private static final List<RegionStructure<?,?>> structureTypes = List.of(Features.IGLOO,Features.BURIED_TREASURE,
Expand All @@ -39,6 +43,7 @@ public static void saveStructures(ScheduledSet<DataStorage.Entry<Feature.Data<?>
}
writer.close();
} catch (IOException e) {
logger.error("seedcracker could't save structures");
e.printStackTrace();
}
}
Expand All @@ -64,6 +69,7 @@ public static List<RegionStructure.Data<?>> loadStructures() {
}
}
} catch (IOException e) {
logger.error("seedcracker could't load previous structures");
e.printStackTrace();
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@
import java.util.stream.LongStream;
import java.util.stream.Stream;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TimeMachine {
public static Logger logger = LoggerFactory.getLogger("timeMachine");

public static ExecutorService SERVICE = Executors.newFixedThreadPool(5);

Expand Down Expand Up @@ -291,7 +295,7 @@ protected boolean pokeBiomes() {
Log.warn("tmachine.printSeedsInConsole");
}
} else {
System.out.println("Found world seed " + worldSeed);
logger.info("Found world seed " + worldSeed);
}
}

Expand Down Expand Up @@ -389,7 +393,7 @@ protected boolean pokeBiomes() {
Log.warn("tmachine.printSeedsInConsole");
}
} else {
System.out.println("Found world seed " + worldSeed);
logger.info("Found world seed " + worldSeed);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
import java.util.List;
import java.util.function.Predicate;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class WarpedFungusFinder extends BlockFinder {
public static Logger logger = LoggerFactory.getLogger("warpedFungusFinder");

private static final Predicate<Block> prdc = block -> (block == Blocks.SHROOMLIGHT || block == Blocks.WARPED_WART_BLOCK);

Expand Down Expand Up @@ -204,7 +208,7 @@ public List<BlockPos> findInChunk() {
blocktype = 3;
} else {
blocktype = 0;
System.out.println("error found illegal Block: " + block.getName() + " at " + pos.add(x, y, z).toShortString());
logger.error("error found illegal Block: " + block.getName() + " at " + pos.add(x, y, z).toShortString());
}
layers[counter][x + layerSize][z + layerSize] = blocktype;
}
Expand Down

0 comments on commit f80d9b6

Please sign in to comment.