From 80f9aba4304a5659bfba7288ff0eacc6de7122bc Mon Sep 17 00:00:00 2001 From: soloturn Date: Sat, 2 Dec 2023 22:22:17 +0100 Subject: [PATCH] qa engine, world, fluent logger. --- .../engine/world/block/family/BlockFamilyLibrary.java | 4 ++-- .../engine/world/block/internal/BlockManagerImpl.java | 8 +++++--- .../chunks/localChunkProvider/LocalChunkProvider.java | 4 ++-- .../world/chunks/pipeline/ChunkProcessingPipeline.java | 3 ++- .../engine/world/generation/FacetedWorldConfigurator.java | 2 +- .../terasology/engine/world/generation/WorldBuilder.java | 3 ++- .../world/generator/internal/WorldGeneratorManager.java | 3 ++- .../engine/world/viewer/layers/FacetLayers.java | 2 +- 8 files changed, 17 insertions(+), 12 deletions(-) diff --git a/engine/src/main/java/org/terasology/engine/world/block/family/BlockFamilyLibrary.java b/engine/src/main/java/org/terasology/engine/world/block/family/BlockFamilyLibrary.java index a7db1027ebb..8f55f529166 100644 --- a/engine/src/main/java/org/terasology/engine/world/block/family/BlockFamilyLibrary.java +++ b/engine/src/main/java/org/terasology/engine/world/block/family/BlockFamilyLibrary.java @@ -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); @@ -96,7 +96,7 @@ public Optional get(Class 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; } diff --git a/engine/src/main/java/org/terasology/engine/world/block/internal/BlockManagerImpl.java b/engine/src/main/java/org/terasology/engine/world/block/internal/BlockManagerImpl.java index 113b3494529..46832c13fc2 100644 --- a/engine/src/main/java/org/terasology/engine/world/block/internal/BlockManagerImpl.java +++ b/engine/src/main/java/org/terasology/engine/world/block/internal/BlockManagerImpl.java @@ -95,7 +95,8 @@ public void initialise(List 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 { @@ -156,7 +157,8 @@ public void receiveFamilyRegistration(BlockUri familyUri, Map 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); } } @@ -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 { diff --git a/engine/src/main/java/org/terasology/engine/world/chunks/localChunkProvider/LocalChunkProvider.java b/engine/src/main/java/org/terasology/engine/world/chunks/localChunkProvider/LocalChunkProvider.java index 11a48265a31..b6c3bd88c06 100644 --- a/engine/src/main/java/org/terasology/engine/world/chunks/localChunkProvider/LocalChunkProvider.java +++ b/engine/src/main/java/org/terasology/engine/world/chunks/localChunkProvider/LocalChunkProvider.java @@ -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; @@ -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 {}"); } } diff --git a/engine/src/main/java/org/terasology/engine/world/chunks/pipeline/ChunkProcessingPipeline.java b/engine/src/main/java/org/terasology/engine/world/chunks/pipeline/ChunkProcessingPipeline.java index 03747a64f42..7bcb22a0d04 100644 --- a/engine/src/main/java/org/terasology/engine/world/chunks/pipeline/ChunkProcessingPipeline.java +++ b/engine/src/main/java/org/terasology/engine/world/chunks/pipeline/ChunkProcessingPipeline.java @@ -115,7 +115,8 @@ private void onStageDone(PositionFuture 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) { } diff --git a/engine/src/main/java/org/terasology/engine/world/generation/FacetedWorldConfigurator.java b/engine/src/main/java/org/terasology/engine/world/generation/FacetedWorldConfigurator.java index 1cc2d7b9a59..4af52612c54 100644 --- a/engine/src/main/java/org/terasology/engine/world/generation/FacetedWorldConfigurator.java +++ b/engine/src/main/java/org/terasology/engine/world/generation/FacetedWorldConfigurator.java @@ -24,7 +24,7 @@ public FacetedWorldConfigurator(List 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; diff --git a/engine/src/main/java/org/terasology/engine/world/generation/WorldBuilder.java b/engine/src/main/java/org/terasology/engine/world/generation/WorldBuilder.java index 4152d645ea3..bf5c888367e 100644 --- a/engine/src/main/java/org/terasology/engine/world/generation/WorldBuilder.java +++ b/engine/src/main/java/org/terasology/engine/world/generation/WorldBuilder.java @@ -184,7 +184,8 @@ private ListMultimap, 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"); } } diff --git a/engine/src/main/java/org/terasology/engine/world/generator/internal/WorldGeneratorManager.java b/engine/src/main/java/org/terasology/engine/world/generator/internal/WorldGeneratorManager.java index 832498c5a8e..92597629c4d 100644 --- a/engine/src/main/java/org/terasology/engine/world/generator/internal/WorldGeneratorManager.java +++ b/engine/src/main/java/org/terasology/engine/world/generator/internal/WorldGeneratorManager.java @@ -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); diff --git a/engine/src/main/java/org/terasology/engine/world/viewer/layers/FacetLayers.java b/engine/src/main/java/org/terasology/engine/world/viewer/layers/FacetLayers.java index 99dd18ceb68..5cdbc3ad7bf 100644 --- a/engine/src/main/java/org/terasology/engine/world/viewer/layers/FacetLayers.java +++ b/engine/src/main/java/org/terasology/engine/world/viewer/layers/FacetLayers.java @@ -78,7 +78,7 @@ private static Collection createLayersFor(Class facetClass.getName()).log("No layers found for facet {}"); } return result;