Skip to content

Commit

Permalink
qa engine, world, fluent logger.
Browse files Browse the repository at this point in the history
  • Loading branch information
soloturn committed Feb 7, 2024
1 parent 121f9dc commit c4f4400
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public BlockFamilyLibrary(ModuleEnvironment moduleEnvironment, Context context)
for (Class<?> entry : moduleEnvironment.getTypesAnnotatedWith(RegisterBlockFamily.class)) {

if (!BlockFamily.class.isAssignableFrom(entry)) {
logger.error("Cannot load {}, must be a subclass of BlockFamily", entry.getSimpleName());
logger.atError().addArgument(() -> entry.getSimpleName()).log("Cannot load {}, must be a subclass of BlockFamily");
continue;
}
RegisterBlockFamily registerInfo = entry.getAnnotation(RegisterBlockFamily.class);
Expand Down Expand Up @@ -96,7 +96,7 @@ public <T> Optional<T> get(Class<T> type) {

return result;
} catch (Exception e) {
logger.error("Failed to load blockFamily {}", blockFamily, e);
logger.atError().addArgument(blockFamily).addArgument(e).log("Failed to load blockFamily {}");
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public void initialise(List<String> registeredBlockFamilies,
if (id != null) {
block.setId(id);
} else {
logger.error("Missing id for block {} in provided family {}", block.getURI(), family.get().getURI());
logger.atError().addArgument(() -> block.getURI()).addArgument(() -> family.get().getURI()).
log("Missing id for block {} in provided family {}");
if (generateNewIds) {
block.setId(getNextId());
} else {
Expand Down Expand Up @@ -156,7 +157,8 @@ public void receiveFamilyRegistration(BlockUri familyUri, Map<String, Integer> r
if (id != null) {
block.setId((short) id.intValue());
} else {
logger.error("Missing id for block {} in registered family {}", block.getURI(), familyUri);
logger.atError().addArgument(() -> block.getURI()).addArgument(() -> familyUri).
log("Missing id for block {} in registered family {}");
block.setId(UNKNOWN_ID);
}
}
Expand Down Expand Up @@ -189,7 +191,7 @@ protected void registerFamily(BlockFamily family) {

private void registerBlock(Block block, RegisteredState newState) {
if (block.getId() != UNKNOWN_ID) {
logger.info("Registered Block {} with id {}", block, block.getId());
logger.atInfo().addArgument(() -> block).addArgument(() -> block.getId()).log("Registered Block {} with id {}");
newState.blocksById.put(block.getId(), block);
newState.idByUri.put(block.getURI(), block.getId());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ private boolean unloadChunkInternal(Vector3ic pos) {
try {
unloadRequestTaskMaster.put(new ChunkUnloadRequest(chunk, this));
} catch (InterruptedException e) {
logger.error("Failed to enqueue unload request for {}", chunk.getPosition(), e);
logger.atError().addArgument(() -> chunk.getPosition()).addArgument(e).log("Failed to enqueue unload request for {}");
}

return true;
Expand All @@ -299,7 +299,7 @@ void gatherBlockPositionsForDeactivate(Chunk chunk) {
try {
deactivateBlocksQueue.put(createBatchBlockEventMappings(chunk));
} catch (InterruptedException e) {
logger.error("Failed to queue deactivation of blocks for {}", chunk.getPosition());
logger.atError().addArgument(() -> chunk.getPosition()).log("Failed to queue deactivation of blocks for {}");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ private void onStageDone(PositionFuture<Chunk> future, ChunkProcessingInfo chunk
chunkProcessingInfo.getChunkTaskProvider() == null
? "Generation or Loading"
: chunkProcessingInfo.getChunkTaskProvider().getName();
logger.error("ChunkTask at position {} and stage [{}] catch error: ", chunkProcessingInfo.getPosition(), stageName, e);
logger.atError().addArgument(chunkProcessingInfo.getPosition()).addArgument(stageName).addArgument(e.getMessage()).
log("ChunkTask at position {} and stage [{}] catch error: {}");
chunkProcessingInfo.getExternalFuture().setException(e);
} catch (CancellationException ignored) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public FacetedWorldConfigurator(List<ConfigurableFacetProvider> providersList) {
for (ConfigurableFacetProvider provider : providersList) {
Component old = properties.put(provider.getConfigurationName(), provider.getConfiguration());
if (old != null) {
logger.warn("Duplicate property key: {}", provider.getConfigurationName());
logger.atWarn().addArgument(() -> provider.getConfigurationName()).log("Duplicate property key: {}");
}
}
this.providers = providersList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ private ListMultimap<Class<? extends WorldFacet>, FacetProvider> determineProvid
if (requires != null) {
for (Facet facet : requires.value()) {
if (!facets.contains(facet.value())) {
logger.error("Facet provider for {} is missing. It is required by {}", facet.value(), provider.getClass());
logger.atError().addArgument(() -> facet.value()).addArgument(() -> provider.getClass()).
log("Facet provider for {} is missing. It is required by {}");
throw new IllegalStateException("Missing facet provider");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public void refresh() {
}
}
} catch (Exception e) {
logger.error("Error loading world generator in module {}, skipping", module.getId(), e);
logger.atError().addArgument(() -> module.getId()).addArgument(e).
log("Error loading world generator in module {}, skipping");
}
} else {
logger.warn("Could not resolve dependencies for module: {}", module);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private static Collection<FacetLayer> createLayersFor(Class<? extends WorldFacet
}

if (result.isEmpty()) {
logger.warn("No layers found for facet {}", facetClass.getName());
logger.atWarn().addArgument(() -> facetClass.getName()).log("No layers found for facet {}");
}

return result;
Expand Down

0 comments on commit c4f4400

Please sign in to comment.