Skip to content

Commit

Permalink
Merge pull request #222 from Pommyd/fix-issue-137
Browse files Browse the repository at this point in the history
Replace stdout with SLF4J LoggerFactory for improved logging (#137)
  • Loading branch information
19MisterX98 authored Jun 7, 2023
2 parents 157826b + 7a3464e commit 26f6525
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
12 changes: 8 additions & 4 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 {
private static final 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,8 +48,7 @@ public static void save() {

gson.toJson(INSTANCE, writer);
} catch (IOException e) {
System.out.println("seedcracker could't save config");
e.printStackTrace();
logger.error("seedcracker could't save config", e);
}
}

Expand All @@ -55,10 +59,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...", e);
file.delete();
} else {
System.out.println("seedcracker couldn't find config");
logger.warn("seedcracker couldn't find config", e);
}
}
}
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 {
private static final 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,7 +43,7 @@ public static void saveStructures(ScheduledSet<DataStorage.Entry<Feature.Data<?>
}
writer.close();
} catch (IOException e) {
e.printStackTrace();
logger.error("seedcracker could't save structures", e);
}
}

Expand All @@ -64,7 +68,7 @@ public static List<RegionStructure.Data<?>> loadStructures() {
}
}
} catch (IOException e) {
e.printStackTrace();
logger.error("seedcracker could't load previous structures", e);
}
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 {
private static final 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 {
private static final 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 26f6525

Please sign in to comment.