From d203bc6252c8387130592a1179b3646918f86265 Mon Sep 17 00:00:00 2001 From: soloturn Date: Mon, 12 Feb 2024 11:34:53 +0100 Subject: [PATCH] feedback fluent-logger pr. except to make log line shorter. Co-authored-by: jdrueckert --- .../org/terasology/engine/audio/openAL/OpenALManager.java | 2 +- .../engine/audio/openAL/staticSound/OpenALSound.java | 2 +- .../audio/openAL/streamingSound/OpenALStreamingSound.java | 2 +- .../engine/config/flexible/AutoConfigManager.java | 4 ++-- .../java/org/terasology/engine/core/TerasologyEngine.java | 2 +- .../terasology/engine/core/module/ModuleInstaller.java | 2 +- .../core/subsystem/common/ConfigurationSubsystem.java | 2 +- .../engine/entitySystem/metadata/EventMetadata.java | 3 +-- .../engine/logic/characters/CharacterSoundSystem.java | 2 +- .../engine/particles/updating/ParticleUpdaterImpl.java | 3 +-- .../engine/persistence/serializers/EventSerializer.java | 2 +- .../engine/persistence/serializers/PrefabSerializer.java | 3 +-- .../terasology/engine/physics/bullet/BulletPhysics.java | 6 ++---- .../engine/world/block/internal/BlockManagerImpl.java | 8 +++----- 14 files changed, 18 insertions(+), 25 deletions(-) diff --git a/engine/src/main/java/org/terasology/engine/audio/openAL/OpenALManager.java b/engine/src/main/java/org/terasology/engine/audio/openAL/OpenALManager.java index 2778f95fc3d..26be4ddca96 100644 --- a/engine/src/main/java/org/terasology/engine/audio/openAL/OpenALManager.java +++ b/engine/src/main/java/org/terasology/engine/audio/openAL/OpenALManager.java @@ -261,7 +261,7 @@ private void notifyEndListeners(boolean interrupted) { try { entry.getValue().onAudioEnd(interrupted); } catch (Exception e) { - logger.atError().addArgument(() -> entry.getValue()).addArgument(e).log("onAudioEnd() notification failed for {}"); + logger.error("onAudioEnd() notification failed for {}", entry.getValue(), e); //NOPMD } } } diff --git a/engine/src/main/java/org/terasology/engine/audio/openAL/staticSound/OpenALSound.java b/engine/src/main/java/org/terasology/engine/audio/openAL/staticSound/OpenALSound.java index 742cd18bef8..16e272881d9 100644 --- a/engine/src/main/java/org/terasology/engine/audio/openAL/staticSound/OpenALSound.java +++ b/engine/src/main/java/org/terasology/engine/audio/openAL/staticSound/OpenALSound.java @@ -104,7 +104,7 @@ protected void doReload(StaticSoundData newData) { length = (float) size / channels / (bits / 8) / frequency; }); } catch (InterruptedException e) { - logger.atError().addArgument(() -> getUrn()).addArgument(e).log("Failed to reload {}"); + logger.error("Failed to reload {}", getUrn(), e); //NOPMD } } diff --git a/engine/src/main/java/org/terasology/engine/audio/openAL/streamingSound/OpenALStreamingSound.java b/engine/src/main/java/org/terasology/engine/audio/openAL/streamingSound/OpenALStreamingSound.java index da21a199386..cd7ddd6bb56 100644 --- a/engine/src/main/java/org/terasology/engine/audio/openAL/streamingSound/OpenALStreamingSound.java +++ b/engine/src/main/java/org/terasology/engine/audio/openAL/streamingSound/OpenALStreamingSound.java @@ -123,7 +123,7 @@ protected void doReload(StreamingSoundData data) { try { GameThread.synch(this::initializeBuffers); } catch (InterruptedException e) { - logger.atError().addArgument(() -> getUrn()).addArgument(e).log("Failed to reload {}"); + logger.error("Failed to reload {}", getUrn(), e); //NOPMD } } diff --git a/engine/src/main/java/org/terasology/engine/config/flexible/AutoConfigManager.java b/engine/src/main/java/org/terasology/engine/config/flexible/AutoConfigManager.java index 98102c81ebb..aca5578844a 100644 --- a/engine/src/main/java/org/terasology/engine/config/flexible/AutoConfigManager.java +++ b/engine/src/main/java/org/terasology/engine/config/flexible/AutoConfigManager.java @@ -85,7 +85,7 @@ private void loadSettingsFromDisk(Class configClass, T T loadedConfig = (T) serializer.deserialize(TypeInfo.of(configClass), inputStream).get(); mergeConfig(configClass, loadedConfig, config); } catch (Exception e) { - logger.atError().addArgument(() -> config.getId()).addArgument(e).log("Error while loading config {} from disk"); + logger.error("Error while loading config {} from disk", config.getId(), e); //NOPMD } } @@ -116,7 +116,7 @@ private void saveConfigToDisk(AutoConfig config) { StandardOpenOption.CREATE)) { serializer.serialize(config, TypeInfo.of((Class) config.getClass()), output); } catch (IOException e) { - logger.atError().addArgument(() -> config.getId()).addArgument(e).log("Error while saving config {} to disk"); + logger.error("Error while saving config {} to disk", config.getId(), e); //NOPMD } } diff --git a/engine/src/main/java/org/terasology/engine/core/TerasologyEngine.java b/engine/src/main/java/org/terasology/engine/core/TerasologyEngine.java index 404a6f02862..3b3b340ba08 100644 --- a/engine/src/main/java/org/terasology/engine/core/TerasologyEngine.java +++ b/engine/src/main/java/org/terasology/engine/core/TerasologyEngine.java @@ -253,7 +253,7 @@ public void initialize() { } double seconds = 0.001 * totalInitTime.elapsed(TimeUnit.MILLISECONDS); - logger.atInfo().addArgument(() -> String.format("%.2f", seconds)).log("Initialization completed in {}sec."); + logger.info("Initialization completed in {}sec.", String.format("%.2f", seconds)); //NOPMD } private void verifyInitialisation() { diff --git a/engine/src/main/java/org/terasology/engine/core/module/ModuleInstaller.java b/engine/src/main/java/org/terasology/engine/core/module/ModuleInstaller.java index 5dd1728367d..e0be03426f2 100644 --- a/engine/src/main/java/org/terasology/engine/core/module/ModuleInstaller.java +++ b/engine/src/main/java/org/terasology/engine/core/module/ModuleInstaller.java @@ -38,7 +38,7 @@ public class ModuleInstaller implements Callable> { @Override public List call() throws Exception { Map filesToDownload = getDownloadUrls(moduleList); - logger.atInfo().addArgument(() -> filesToDownload.size()).log("Started downloading {} modules"); + logger.info("Started downloading {} modules", filesToDownload.size()); //NOPMD MultiFileDownloader downloader = new MultiFileDownloader(filesToDownload, downloadProgressListener); List downloadedModulesPaths = downloader.call(); logger.info("Module download completed, loading the new modules..."); diff --git a/engine/src/main/java/org/terasology/engine/core/subsystem/common/ConfigurationSubsystem.java b/engine/src/main/java/org/terasology/engine/core/subsystem/common/ConfigurationSubsystem.java index d211194c8d0..08fd8fc866e 100644 --- a/engine/src/main/java/org/terasology/engine/core/subsystem/common/ConfigurationSubsystem.java +++ b/engine/src/main/java/org/terasology/engine/core/subsystem/common/ConfigurationSubsystem.java @@ -66,7 +66,7 @@ public void preInitialise(Context rootContext) { checkServerIdentity(); // TODO: Move to display subsystem - logger.atInfo().addArgument(() -> config.renderConfigAsJson(config.getRendering())).log("Video Settings: {}"); + logger.info("Video Settings: {}", config.renderConfigAsJson(config.getRendering())); //NOPMD rootContext.put(Config.class, config); //add facades diff --git a/engine/src/main/java/org/terasology/engine/entitySystem/metadata/EventMetadata.java b/engine/src/main/java/org/terasology/engine/entitySystem/metadata/EventMetadata.java index 14f32cf21eb..0eb71a8ae1c 100644 --- a/engine/src/main/java/org/terasology/engine/entitySystem/metadata/EventMetadata.java +++ b/engine/src/main/java/org/terasology/engine/entitySystem/metadata/EventMetadata.java @@ -38,8 +38,7 @@ public EventMetadata(Class simpleClass, CopyStrategyLibrary copyStrategies, R skipInstigator = simpleClass.getAnnotation(BroadcastEvent.class).skipInstigator(); } if (networkEventType != NetworkEventType.NONE && !isConstructable() && !Modifier.isAbstract(simpleClass.getModifiers())) { - logger.atError().addArgument(() -> this). - log("Event '{}' is a network event but lacks a default constructor - will not be replicated"); + logger.error("Event '{}' is a network event but lacks a default constructor - will not be replicated", this); //NOPMD } } diff --git a/engine/src/main/java/org/terasology/engine/logic/characters/CharacterSoundSystem.java b/engine/src/main/java/org/terasology/engine/logic/characters/CharacterSoundSystem.java index 7429cd75040..0cee78267c6 100644 --- a/engine/src/main/java/org/terasology/engine/logic/characters/CharacterSoundSystem.java +++ b/engine/src/main/java/org/terasology/engine/logic/characters/CharacterSoundSystem.java @@ -60,7 +60,7 @@ public void onFootstep(FootstepEvent event, EntityRef entity, LocationComponent Block block = worldProvider.getBlock(blockPos); if (block != null) { if (block.getSounds() == null) { - logger.atError().addArgument(() -> block.getURI()).log("Block '{}' has no sounds"); + logger.error("Block '{}' has no sounds", block.getURI()); //NOPMD } else if (!block.getSounds().getStepSounds().isEmpty()) { footstepSounds = block.getSounds().getStepSounds(); } diff --git a/engine/src/main/java/org/terasology/engine/particles/updating/ParticleUpdaterImpl.java b/engine/src/main/java/org/terasology/engine/particles/updating/ParticleUpdaterImpl.java index dd5f1a3cadf..b5a1fd25845 100644 --- a/engine/src/main/java/org/terasology/engine/particles/updating/ParticleUpdaterImpl.java +++ b/engine/src/main/java/org/terasology/engine/particles/updating/ParticleUpdaterImpl.java @@ -125,8 +125,7 @@ public void initialize() { for (Class type : environment.getTypesAnnotatedWith(RegisterParticleSystemFunction.class)) { if (!ParticleSystemFunction.class.isAssignableFrom(type)) { - logger.atError().addArgument(() -> type.getSimpleName()). - log("Cannot register particle system function {}, must be a subclass of ParticleSystemFunction"); + logger.error("Cannot register particle system function {}, must be a subclass of ParticleSystemFunction", type.getSimpleName()); //NOPMD } else { try { ParticleSystemFunction function = (ParticleSystemFunction) type.newInstance(); diff --git a/engine/src/main/java/org/terasology/engine/persistence/serializers/EventSerializer.java b/engine/src/main/java/org/terasology/engine/persistence/serializers/EventSerializer.java index 98d7f15d526..a2913b8b503 100644 --- a/engine/src/main/java/org/terasology/engine/persistence/serializers/EventSerializer.java +++ b/engine/src/main/java/org/terasology/engine/persistence/serializers/EventSerializer.java @@ -154,7 +154,7 @@ public Class getEventClass(EntityData.Event eventData) { } } if (metadata == null) { - logger.atWarn().addArgument(() -> eventData.getType()).log("Unable to deserialize unknown event with id: {}"); + logger.warn("Unable to deserialize unknown event with id: {}", eventData.getType()); //NOPMD return null; } return metadata.getType(); diff --git a/engine/src/main/java/org/terasology/engine/persistence/serializers/PrefabSerializer.java b/engine/src/main/java/org/terasology/engine/persistence/serializers/PrefabSerializer.java index 1bb95f1b201..7c6028ac403 100644 --- a/engine/src/main/java/org/terasology/engine/persistence/serializers/PrefabSerializer.java +++ b/engine/src/main/java/org/terasology/engine/persistence/serializers/PrefabSerializer.java @@ -155,8 +155,7 @@ private void applyComponentChanges(Module context, EntityData.Prefab prefabData, } } } else if (componentData.hasType()) { - logger.atWarn().addArgument(() -> prefabData.getName()).addArgument(() -> componentData.getType()). - log("Prefab '{}' contains unknown component '{}'"); + logger.warn("Prefab '{}' contains unknown component '{}'", prefabData.getName(), componentData.getType()); //NOPMD } } } diff --git a/engine/src/main/java/org/terasology/engine/physics/bullet/BulletPhysics.java b/engine/src/main/java/org/terasology/engine/physics/bullet/BulletPhysics.java index cc2ba46f464..2b117ba1bae 100644 --- a/engine/src/main/java/org/terasology/engine/physics/bullet/BulletPhysics.java +++ b/engine/src/main/java/org/terasology/engine/physics/bullet/BulletPhysics.java @@ -241,8 +241,7 @@ public HitResult rayTrace(Vector3f from, Vector3f direction, float distance, Col hitNormalWorld, voxelPosition); } else { //we hit something we don't understand, assume its nothing and log a warning - logger.atWarn().addArgument(() -> collisionObject.userData). - log("Unidentified object was hit in the physics engine: {}"); + logger.warn("Unidentified object was hit in the physics engine: {}", collisionObject.userData); //NOPMD } } @@ -306,8 +305,7 @@ public HitResult rayTrace(Vector3f from, Vector3f direction, float distance, Set hitNormalWorld, voxelPosition); } else { //we hit something we don't understand, assume its nothing and log a warning - logger.atWarn().addArgument(() -> collisionObject.userData). - log("Unidentified object was hit in the physics engine: {}"); + logger.warn("Unidentified object was hit in the physics engine: {}", collisionObject.userData); //NOPMD } } } 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 46832c13fc2..b5a768dfb96 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,8 +95,7 @@ public void initialise(List registeredBlockFamilies, if (id != null) { block.setId(id); } else { - logger.atError().addArgument(() -> block.getURI()).addArgument(() -> family.get().getURI()). - log("Missing id for block {} in provided family {}"); + logger.error("Missing id for block {} in provided family {}", block.getURI(), family.get().getURI()); //NOPMD if (generateNewIds) { block.setId(getNextId()); } else { @@ -157,8 +156,7 @@ public void receiveFamilyRegistration(BlockUri familyUri, Map r if (id != null) { block.setId((short) id.intValue()); } else { - logger.atError().addArgument(() -> block.getURI()).addArgument(() -> familyUri). - log("Missing id for block {} in registered family {}"); + logger.error("Missing id for block {} in registered family {}", block.getURI(), familyUri); //NOPMD block.setId(UNKNOWN_ID); } } @@ -191,7 +189,7 @@ protected void registerFamily(BlockFamily family) { private void registerBlock(Block block, RegisteredState newState) { if (block.getId() != UNKNOWN_ID) { - logger.atInfo().addArgument(() -> block).addArgument(() -> block.getId()).log("Registered Block {} with id {}"); + logger.info("Registered Block {} with id {}", block, block.getId()); //NOPMD newState.blocksById.put(block.getId(), block); newState.idByUri.put(block.getURI(), block.getId()); } else {