From e5e0e41e78094a155a9be786d7725361845a77e8 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 --- .../engine/audio/openAL/OpenALManager.java | 5 ++-- .../audio/openAL/staticSound/OpenALSound.java | 2 +- .../streamingSound/OpenALStreamingSound.java | 2 +- .../config/flexible/AutoConfigManager.java | 4 +-- .../constraints/LocaleConstraint.java | 11 +++---- .../engine/core/TerasologyEngine.java | 2 +- .../engine/core/module/ModuleInstaller.java | 2 +- .../common/ConfigurationSubsystem.java | 2 +- .../event/internal/EventSystemImpl.java | 8 ++--- .../entitySystem/metadata/EventLibrary.java | 3 +- .../entitySystem/metadata/EventMetadata.java | 3 +- .../actions/conditions/ConditionAction.java | 11 ++++--- .../logic/behavior/core/ActionNode.java | 6 ++-- .../logic/behavior/core/DecoratorNode.java | 6 ++-- .../characters/CharacterSoundSystem.java | 2 +- .../ClientCharacterPredictionSystem.java | 5 ++-- .../engine/logic/console/ConsoleImpl.java | 2 +- .../console/commands/ServerCommands.java | 4 +-- .../logic/debug/ChunkEventErrorLogger.java | 4 +-- .../inventory/ItemPickupAuthoritySystem.java | 2 +- .../engine/logic/players/PlayerSystem.java | 2 +- .../network/internal/NetworkSystemImpl.java | 7 ++--- .../engine/network/internal/ServerImpl.java | 2 +- .../updating/ParticleUpdaterImpl.java | 3 +- .../internal/GlobalStoreLoader.java | 2 +- .../serializers/EventSerializer.java | 2 +- .../serializers/PrefabSerializer.java | 3 +- .../serializers/WorldSerializerImpl.java | 2 +- .../engine/physics/bullet/BulletPhysics.java | 6 ++-- .../recording/EventSystemReplayImpl.java | 11 ++++--- .../engine/rendering/dag/AbstractNode.java | 6 ++-- .../engine/rendering/dag/RenderGraph.java | 25 +++++++--------- .../dag/RenderTaskListGenerator.java | 30 ++++++++----------- .../rendering/logic/FloatingTextRenderer.java | 2 +- .../rendering/logic/SkeletonRenderer.java | 2 +- .../engine/rendering/nui/asset/UIFormat.java | 5 ++-- .../utils/NUIEditorMenuTreeBuilder.java | 2 +- .../nui/internal/NUIManagerInternal.java | 6 ++-- .../videoSettings/VideoSettingsScreen.java | 2 +- .../nui/widgets/UIButtonWebBrowser.java | 6 ++-- .../engine/rendering/opengl/GLSLMaterial.java | 5 ++-- .../engine/rendering/opengl/GLSLShader.java | 9 +++--- .../engine/rendering/opengl/OpenGLMesh.java | 4 +-- .../rendering/opengl/OpenGLSkeletalMesh.java | 2 +- .../rendering/opengl/OpenGLTexture.java | 3 +- .../utilities/concurrency/TaskProcessor.java | 2 +- .../block/family/BlockFamilyLibrary.java | 4 +-- .../block/internal/BlockManagerImpl.java | 8 ++--- .../LocalChunkProvider.java | 4 +-- 49 files changed, 112 insertions(+), 141 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..573d8192338 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 @@ -65,8 +65,7 @@ public OpenALManager(AudioConfig config) throws OpenALException { ALCCapabilities alcCapabilities = ALC.createCapabilities(device); AL.createCapabilities(alcCapabilities); - logger.atInfo().addArgument(() -> AL10.alGetString(AL10.AL_VERSION)).log("OpenAL {} initialized!"); - + logger.info("OpenAL {} initialized!", AL10.alGetString(AL10.AL_VERSION)); logger.info("Using OpenAL: {} by {}", AL10.alGetString(AL10.AL_RENDERER), AL10.alGetString(AL10.AL_VENDOR)); logger.info("Using device: {}", ALC10.alcGetString(device, ALC10.ALC_DEVICE_SPECIFIER)); logger.info("Available AL extensions: {}", AL10.alGetString(AL10.AL_EXTENSIONS)); @@ -261,7 +260,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/config/flexible/constraints/LocaleConstraint.java b/engine/src/main/java/org/terasology/engine/config/flexible/constraints/LocaleConstraint.java index 7efc4891ef9..fabf90889b2 100644 --- a/engine/src/main/java/org/terasology/engine/config/flexible/constraints/LocaleConstraint.java +++ b/engine/src/main/java/org/terasology/engine/config/flexible/constraints/LocaleConstraint.java @@ -31,12 +31,13 @@ public boolean isSatisfiedBy(Locale value) { } @Override + @SuppressWarnings("PMD.GuardLogStatement") public void warnUnsatisfiedBy(Locale value) { - logger.atWarn(). - addArgument(value). - addArgument(() -> locales.stream() + logger.warn("Locale {} should be one of {}", + value, + locales.stream() .map(Locale::getLanguage) - .collect(Collectors.joining(",", "[", "]"))). - log("Locale {} should be one of {}"); + .collect(Collectors.joining(",", "[", "]")) + ); } } 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 7cb6964c88f..d3852f083ce 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 cffc6a9f17f..5f332ab5e54 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/event/internal/EventSystemImpl.java b/engine/src/main/java/org/terasology/engine/entitySystem/event/internal/EventSystemImpl.java index b4b7647485b..d64cb9be2f3 100644 --- a/engine/src/main/java/org/terasology/engine/entitySystem/event/internal/EventSystemImpl.java +++ b/engine/src/main/java/org/terasology/engine/entitySystem/event/internal/EventSystemImpl.java @@ -83,7 +83,7 @@ public void process() { @Override public void registerEvent(ResourceUrn uri, Class eventType) { eventIdMap.put(uri, eventType); - logger.atDebug().addArgument(() -> eventType.getSimpleName()).log("Registering event {}"); + logger.debug("Registering event {}", eventType.getSimpleName()); //NOPMD for (Class parent : ReflectionUtils.getAllSuperTypes(eventType, Predicates.subtypeOf(Event.class))) { if (!AbstractConsumableEvent.class.equals(parent) && !Event.class.equals(parent)) { childEvents.put(parent, eventType); @@ -95,11 +95,11 @@ public void registerEvent(ResourceUrn uri, Class eventType) { public void registerEventHandler(ComponentSystem handler) { Class handlerClass = handler.getClass(); if (!Modifier.isPublic(handlerClass.getModifiers())) { - logger.atError().addArgument(() -> handlerClass.getName()).log("Cannot register handler {}, must be public"); + logger.error("Cannot register handler {}, must be public", handlerClass.getName()); //NOPMD return; } - logger.atDebug().addArgument(() -> handlerClass.getName()).log("Registering event handler {}"); + logger.debug("Registering event handler {}", handlerClass.getName()); //NOPMD for (Method method : handlerClass.getMethods()) { ReceiveEvent receiveEventAnnotation = method.getAnnotation(ReceiveEvent.class); if (receiveEventAnnotation != null) { @@ -129,7 +129,7 @@ public void registerEventHandler(ComponentSystem handler) { logger.debug("Found method: {}", method); if (!Event.class.isAssignableFrom(types[0]) || !EntityRef.class.isAssignableFrom(types[1])) { - logger.atError().addArgument(() -> method.getName()).log("Invalid event handler method: {}"); + logger.error("Invalid event handler method: {}", method.getName()); //NOPMD return; } diff --git a/engine/src/main/java/org/terasology/engine/entitySystem/metadata/EventLibrary.java b/engine/src/main/java/org/terasology/engine/entitySystem/metadata/EventLibrary.java index 4a6397c1896..91a0f8e83a8 100644 --- a/engine/src/main/java/org/terasology/engine/entitySystem/metadata/EventLibrary.java +++ b/engine/src/main/java/org/terasology/engine/entitySystem/metadata/EventLibrary.java @@ -30,8 +30,7 @@ public EventLibrary(ModuleEnvironment environment, ReflectFactory reflectFactory try { return new EventMetadata<>(type, copyStrategies, factory, uri); } catch (NoSuchMethodException e) { - logger.atError().addArgument(() -> type.getSimpleName()).addArgument(() -> e). - log("Unable to register class {}: Default Constructor Required"); + logger.error("Unable to register class {}: Default Constructor Required", type.getSimpleName(), e); //NOPMD return null; } } 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/behavior/actions/conditions/ConditionAction.java b/engine/src/main/java/org/terasology/engine/logic/behavior/actions/conditions/ConditionAction.java index 9f9e13d44b8..62aa7df2904 100644 --- a/engine/src/main/java/org/terasology/engine/logic/behavior/actions/conditions/ConditionAction.java +++ b/engine/src/main/java/org/terasology/engine/logic/behavior/actions/conditions/ConditionAction.java @@ -98,7 +98,7 @@ protected boolean condition(Actor actor) throws ClassNotFoundException, NoSuchFi secondValue = ""; break; default: - logger.atError().addArgument(() -> tokens[0]).log("Unsupported guard value type: {}"); + logger.error("Unsupported guard value type: {}", tokens[0]); //NOPMD secondValue = ""; } @@ -115,7 +115,7 @@ protected boolean condition(Actor actor) throws ClassNotFoundException, NoSuchFi passing = (Boolean) fieldValue != Boolean.parseBoolean(secondValue); break; default: - logger.atError().addArgument(() -> tokens[2]).log("Unsupported operation for boolean values: {}"); + logger.error("Unsupported operation for boolean values: {}", tokens[2]); //NOPMD } @@ -142,7 +142,7 @@ protected boolean condition(Actor actor) throws ClassNotFoundException, NoSuchFi passing = ((Number) fieldValue).doubleValue() < Double.parseDouble(secondValue); break; default: - logger.atError().addArgument(() -> tokens[2]).log("Unsupported operation for numeric values: {}"); + logger.error("Unsupported operation for numeric values: {}", tokens[2]); //NOPMD } @@ -157,7 +157,7 @@ protected boolean condition(Actor actor) throws ClassNotFoundException, NoSuchFi passing = !fieldValue.equals(secondValue); break; default: - logger.atError().addArgument(() -> tokens[2]).log("Unsupported operation for strings: {}"); + logger.error("Unsupported operation for strings: {}", tokens[2]); //NOPMD } } else { @@ -190,8 +190,7 @@ protected boolean condition(Actor actor) throws ClassNotFoundException, NoSuchFi break; default: - logger.atError().addArgument(() -> fieldValue.getClass()).addArgument(() -> tokens[2]). - log("Unknown field type or operation: {} {}"); + logger.error("Unknown field type or operation: {} {}", fieldValue.getClass(), tokens[2]); //NOPMD } } } diff --git a/engine/src/main/java/org/terasology/engine/logic/behavior/core/ActionNode.java b/engine/src/main/java/org/terasology/engine/logic/behavior/core/ActionNode.java index 65df48d3c42..a9a0301760b 100644 --- a/engine/src/main/java/org/terasology/engine/logic/behavior/core/ActionNode.java +++ b/engine/src/main/java/org/terasology/engine/logic/behavior/core/ActionNode.java @@ -56,8 +56,7 @@ public void construct(Actor actor) { try { action.construct(actor); } catch (Exception e) { - logger.atDebug().addArgument(() -> action).addArgument(() -> actor.getEntity()).addArgument(() -> e). - log("Exception while running construct() of action {} from entity {}: "); + logger.debug("Exception while running construct() of action {} from entity {}: ", action, actor.getEntity(), e); //NOPMD } } } @@ -68,8 +67,7 @@ public BehaviorState execute(Actor actor) { try { return action.modify(actor, BehaviorState.UNDEFINED); } catch (Exception e) { - logger.atDebug().addArgument(() -> action).addArgument(() -> actor.getEntity()).addArgument(() -> e). - log("Exception while running action {} from entity {}: "); + logger.debug("Exception while running action {} from entity {}: ", action, actor.getEntity(), e); //NOPMD // TODO maybe returning UNDEFINED would be more fitting? return BehaviorState.FAILURE; } diff --git a/engine/src/main/java/org/terasology/engine/logic/behavior/core/DecoratorNode.java b/engine/src/main/java/org/terasology/engine/logic/behavior/core/DecoratorNode.java index 29cc0c133e5..39c51b200c3 100644 --- a/engine/src/main/java/org/terasology/engine/logic/behavior/core/DecoratorNode.java +++ b/engine/src/main/java/org/terasology/engine/logic/behavior/core/DecoratorNode.java @@ -48,8 +48,7 @@ public void construct(Actor actor) { try { action.construct(actor); } catch (Exception e) { - logger.atInfo().addArgument(() -> action).addArgument(() -> actor.getEntity()). - log("Exception while running construct() of action {} from entity {}:"); + logger.info("Exception while running construct() of action {} from entity {}:", action, actor.getEntity()); //NOPMD } } } @@ -81,8 +80,7 @@ public BehaviorState execute(Actor actor) { try { modifiedState = action.modify(actor, lastState); } catch (Exception e) { - logger.atInfo().addArgument(() -> action).addArgument(() -> actor.getEntity()).addArgument(() -> e.getStackTrace()). - log("Exception while running action {} from entity {}: {}"); + logger.info("Exception while running action {} from entity {}: {}", action, actor.getEntity(), e.getStackTrace()); //NOPMD // TODO maybe returning UNDEFINED would be more canonical? return BehaviorState.FAILURE; } 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/logic/characters/ClientCharacterPredictionSystem.java b/engine/src/main/java/org/terasology/engine/logic/characters/ClientCharacterPredictionSystem.java index 678f050baf8..640390f9849 100644 --- a/engine/src/main/java/org/terasology/engine/logic/characters/ClientCharacterPredictionSystem.java +++ b/engine/src/main/java/org/terasology/engine/logic/characters/ClientCharacterPredictionSystem.java @@ -84,8 +84,7 @@ public void onDestroy(final BeforeDeactivateComponent event, final EntityRef ent @ReceiveEvent(components = {CharacterMovementComponent.class, LocationComponent.class, AliveCharacterComponent.class}) public void onCharacterStateReceived(CharacterStateEvent state, EntityRef entity) { if (entity.equals(localPlayer.getCharacterEntity())) { - logger.atTrace().addArgument(() -> state.getSequenceNumber()).addArgument(() -> inputs.size()). - log("Received new state, sequence number: {}, buffered input size {}"); + logger.trace("Received new state, sequence number: {}, buffered input size {}", state.getSequenceNumber(), inputs.size()); //NOPMD playerStates.remove(entity); authoritiveState = state; @@ -99,7 +98,7 @@ public void onCharacterStateReceived(CharacterStateEvent state, EntityRef entity newState = stepState(input, newState, entity); } } - logger.atTrace().addArgument(() -> inputs.size()).log("Resultant input size {}"); + logger.trace("Resultant input size {}", inputs.size()); //NOPMD characterMovementSystemUtility.setToState(entity, newState); // TODO: soft correct predicted state predictedState = newState; diff --git a/engine/src/main/java/org/terasology/engine/logic/console/ConsoleImpl.java b/engine/src/main/java/org/terasology/engine/logic/console/ConsoleImpl.java index d613363f3fa..04b66b74479 100644 --- a/engine/src/main/java/org/terasology/engine/logic/console/ConsoleImpl.java +++ b/engine/src/main/java/org/terasology/engine/logic/console/ConsoleImpl.java @@ -139,7 +139,7 @@ public void addMessage(String message, MessageType type, boolean newLine) { @Override public void addMessage(Message message) { String uncoloredText = FontUnderline.strip(FontColor.stripColor(message.getMessage())); - logger.atInfo().addArgument(() -> message.getType()).addArgument(() -> uncoloredText).log("[{}] {}"); + logger.info("[{}] {}", message.getType(), uncoloredText); //NOPMD messageHistory.add(message); for (ConsoleSubscriber subscriber : messageSubscribers) { subscriber.onNewConsoleMessage(message); diff --git a/engine/src/main/java/org/terasology/engine/logic/console/commands/ServerCommands.java b/engine/src/main/java/org/terasology/engine/logic/console/commands/ServerCommands.java index 78617b27008..41945385d18 100644 --- a/engine/src/main/java/org/terasology/engine/logic/console/commands/ServerCommands.java +++ b/engine/src/main/java/org/terasology/engine/logic/console/commands/ServerCommands.java @@ -68,7 +68,7 @@ public String shutdownServer(@Sender EntityRef sender) { EntityRef clientInfo = sender.getComponent(ClientComponent.class).clientInfo; DisplayNameComponent name = clientInfo.getComponent(DisplayNameComponent.class); - logger.atInfo().addArgument(() -> name.name).log("Shutdown triggered by {}"); + logger.info("Shutdown triggered by {}", name.name); //NOPMD gameEngine.shutdown(); @@ -165,7 +165,7 @@ private String kick(EntityRef clientEntity) { EntityRef clientInfo = clientEntity.getComponent(ClientComponent.class).clientInfo; DisplayNameComponent name = clientInfo.getComponent(DisplayNameComponent.class); - logger.atInfo().addArgument(() -> name.name).log("Kicking user {}"); + logger.info("Kicking user {}", name.name); //NOPMD networkSystem.forceDisconnect(client); return "User kick triggered for '" + name.name + "'"; diff --git a/engine/src/main/java/org/terasology/engine/logic/debug/ChunkEventErrorLogger.java b/engine/src/main/java/org/terasology/engine/logic/debug/ChunkEventErrorLogger.java index a611ec1d200..50e1e633693 100644 --- a/engine/src/main/java/org/terasology/engine/logic/debug/ChunkEventErrorLogger.java +++ b/engine/src/main/java/org/terasology/engine/logic/debug/ChunkEventErrorLogger.java @@ -25,14 +25,14 @@ public class ChunkEventErrorLogger extends BaseComponentSystem { @ReceiveEvent(components = WorldComponent.class) public void onNewChunk(OnChunkLoaded chunkAvailable, EntityRef worldEntity) { if (!loadedChunks.add(chunkAvailable.getChunkPos())) { - logger.atError().addArgument(() -> chunkAvailable.getChunkPos()).log("Multiple loads of chunk {}"); + logger.error("Multiple loads of chunk {}", chunkAvailable.getChunkPos()); //NOPMD } } @ReceiveEvent(components = WorldComponent.class) public void onRemoveChunk(BeforeChunkUnload chunkUnload, EntityRef worldEntity) { if (!loadedChunks.remove(chunkUnload.getChunkPos())) { - logger.atError().addArgument(() -> chunkUnload.getChunkPos()).log("Unload event for not loaded chunk {}"); + logger.error("Unload event for not loaded chunk {}", chunkUnload.getChunkPos()); //NOPMD } } } diff --git a/engine/src/main/java/org/terasology/engine/logic/inventory/ItemPickupAuthoritySystem.java b/engine/src/main/java/org/terasology/engine/logic/inventory/ItemPickupAuthoritySystem.java index b61a26f07b3..27c02d19ead 100644 --- a/engine/src/main/java/org/terasology/engine/logic/inventory/ItemPickupAuthoritySystem.java +++ b/engine/src/main/java/org/terasology/engine/logic/inventory/ItemPickupAuthoritySystem.java @@ -82,7 +82,7 @@ public void updateExtentsOnBlockItemBoxShape(OnAddedComponent event, EntityRef i BlockFamily blockFamily = blockItemComponent.blockFamily; if (blockFamily == null) { - LOGGER.atWarn().addArgument(() -> itemEntity.getParentPrefab().getName()).log("Prefab {} does not have a block family"); + LOGGER.warn("Prefab {} does not have a block family", itemEntity.getParentPrefab().getName()); //NOPMD return; } diff --git a/engine/src/main/java/org/terasology/engine/logic/players/PlayerSystem.java b/engine/src/main/java/org/terasology/engine/logic/players/PlayerSystem.java index 627ce16a9bd..9515194137d 100644 --- a/engine/src/main/java/org/terasology/engine/logic/players/PlayerSystem.java +++ b/engine/src/main/java/org/terasology/engine/logic/players/PlayerSystem.java @@ -155,7 +155,7 @@ public void onConnect(ConnectedEvent connected, EntityRef entity) { private void restoreCharacter(EntityRef entity, EntityRef character) { Client clientListener = networkSystem.getOwner(entity); - LOGGER.atInfo().addArgument(() -> clientListener.toString()).log("{}"); + LOGGER.info("{}", clientListener); updateRelevanceEntity(entity, clientListener.getViewDistance().getChunkDistance()); ClientComponent client = entity.getComponent(ClientComponent.class); diff --git a/engine/src/main/java/org/terasology/engine/network/internal/NetworkSystemImpl.java b/engine/src/main/java/org/terasology/engine/network/internal/NetworkSystemImpl.java index 84fadef009b..4eee38115d5 100644 --- a/engine/src/main/java/org/terasology/engine/network/internal/NetworkSystemImpl.java +++ b/engine/src/main/java/org/terasology/engine/network/internal/NetworkSystemImpl.java @@ -827,7 +827,7 @@ private void processRemovedClient(Client client) { } clientList.remove(client); clientPlayerLookup.remove(client.getEntity()); - logger.atInfo().addArgument(() -> client.getName()).log("Client disconnected: {}"); + logger.info("Client disconnected: {}", client.getName()); //NOPMD storageManager.deactivatePlayer(client); client.getEntity().send(new DisconnectedEvent()); client.disconnect(); @@ -856,7 +856,7 @@ private void processNewClient(NetClient client) { connectClient(client); // log after connect so that the name has been set: - logger.atInfo().addArgument(() -> client.getEntity()).log("New client entity: {}"); + logger.info("New client entity: {}", client.getEntity()); //NOPMD for (EntityRef netEntity : entityManager.getEntitiesWith(NetworkComponent.class)) { NetworkComponent netComp = netEntity.getComponent(NetworkComponent.class); if (netComp.getNetworkId() != NULL_NET_ID) { @@ -973,8 +973,7 @@ private Map, Integer> generateIds(ClassLibrary classLi int fieldId = 0; for (FieldMetadata field : metadata.getFields()) { if (fieldId >= 256) { - logger.atError().addArgument(() -> metadata.getId()). - log("Class {} has too many fields (>255), serialization will be incomplete"); + logger.error("Class {} has too many fields (>255), serialization will be incomplete", metadata.getId()); //NOPMD break; } field.setId((byte) fieldId); diff --git a/engine/src/main/java/org/terasology/engine/network/internal/ServerImpl.java b/engine/src/main/java/org/terasology/engine/network/internal/ServerImpl.java index a56a21ccb05..6ae75e4a1b9 100644 --- a/engine/src/main/java/org/terasology/engine/network/internal/ServerImpl.java +++ b/engine/src/main/java/org/terasology/engine/network/internal/ServerImpl.java @@ -349,7 +349,7 @@ private void processBlockRegistrations(NetData.NetMessage message) { } blockManager.receiveFamilyRegistration(family, registrationMap); } catch (BlockUriParseException e) { - logger.atError().addArgument(() -> blockFamily.getBlockUri(0)).log("Received invalid block uri {}"); + logger.error("Received invalid block uri {}", blockFamily.getBlockUri(0)); //NOPMD } } } 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/internal/GlobalStoreLoader.java b/engine/src/main/java/org/terasology/engine/persistence/internal/GlobalStoreLoader.java index b7c58fba2a6..911bd471427 100644 --- a/engine/src/main/java/org/terasology/engine/persistence/internal/GlobalStoreLoader.java +++ b/engine/src/main/java/org/terasology/engine/persistence/internal/GlobalStoreLoader.java @@ -93,7 +93,7 @@ private Prefab loadPrefab(EntityData.Prefab prefabData, Map prefabData.getParentName()).addArgument(e).log("Failed to load prefab {}"); + logger.error("Failed to load prefab {}", prefabData.getParentName(), e); //NOPMD return null; } } 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/persistence/serializers/WorldSerializerImpl.java b/engine/src/main/java/org/terasology/engine/persistence/serializers/WorldSerializerImpl.java index 514efd4cd19..d39a46fbc53 100644 --- a/engine/src/main/java/org/terasology/engine/persistence/serializers/WorldSerializerImpl.java +++ b/engine/src/main/java/org/terasology/engine/persistence/serializers/WorldSerializerImpl.java @@ -157,7 +157,7 @@ private void createPrefab(EntityData.Prefab prefabData) { PrefabData protoPrefab = prefabSerializer.deserialize(prefabData); Assets.generateAsset(new ResourceUrn(prefabData.getName()), protoPrefab, Prefab.class); } catch (Exception e) { - logger.atError().addArgument(() -> prefabData.getName()).log("Failed to create prefab {}"); + logger.error("Failed to create prefab {}", prefabData.getName()); //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/recording/EventSystemReplayImpl.java b/engine/src/main/java/org/terasology/engine/recording/EventSystemReplayImpl.java index b502e278468..7cb4f798495 100644 --- a/engine/src/main/java/org/terasology/engine/recording/EventSystemReplayImpl.java +++ b/engine/src/main/java/org/terasology/engine/recording/EventSystemReplayImpl.java @@ -276,7 +276,7 @@ private EntityRef getEntityRef(RecordedEvent recordedEvent) { @Override public void registerEvent(ResourceUrn uri, Class eventType) { eventIdMap.put(uri, eventType); - logger.atDebug().addArgument(() -> eventType.getSimpleName()).log("Registering event {}"); + logger.debug("Registering event {}", eventType.getSimpleName()); //NOPMD for (Class parent : ReflectionUtils.getAllSuperTypes(eventType, Predicates.subtypeOf(Event.class))) { if (!AbstractConsumableEvent.class.equals(parent) && !Event.class.equals(parent)) { childEvents.put(parent, eventType); @@ -303,11 +303,11 @@ private boolean shouldAddToLibrary(Class eventType) { public void registerEventHandler(ComponentSystem handler) { Class handlerClass = handler.getClass(); if (!Modifier.isPublic(handlerClass.getModifiers())) { - logger.atError().addArgument(() -> handlerClass.getName()).log("Cannot register handler {}, must be public"); + logger.error("Cannot register handler {}, must be public", handlerClass.getName()); //NOPMD return; } - logger.atDebug().addArgument(() -> handlerClass.getName()).log("Registering event handler {}"); + logger.debug("Registering event handler {}", handlerClass.getName()); //NOPMD for (Method method : handlerClass.getMethods()) { ReceiveEvent receiveEventAnnotation = method.getAnnotation(ReceiveEvent.class); if (receiveEventAnnotation != null) { @@ -336,7 +336,7 @@ public void registerEventHandler(ComponentSystem handler) { logger.debug("Found method: {}", method); if (!Event.class.isAssignableFrom(types[0]) || !EntityRef.class.isAssignableFrom(types[1])) { - logger.atError().addArgument(() -> method.getName()).log("Invalid event handler method: {}"); + logger.error("Invalid event handler method: {}", method.getName()); //NOPMD return; } @@ -344,8 +344,7 @@ public void registerEventHandler(ComponentSystem handler) { List> componentParams = Lists.newArrayList(); for (int i = 2; i < types.length; ++i) { if (!Component.class.isAssignableFrom(types[i])) { - logger.atError().addArgument(() -> method.getName()).addArgument(types[i]). - log("Invalid event handler method: {} - {} is not a component class"); + logger.error("Invalid event handler method: {} - {} is not a component class", method.getName(), types[i]); //NOPMD return; } requiredComponents.add((Class) types[i]); diff --git a/engine/src/main/java/org/terasology/engine/rendering/dag/AbstractNode.java b/engine/src/main/java/org/terasology/engine/rendering/dag/AbstractNode.java index 3a3265dfce3..64b8adcdab0 100644 --- a/engine/src/main/java/org/terasology/engine/rendering/dag/AbstractNode.java +++ b/engine/src/main/java/org/terasology/engine/rendering/dag/AbstractNode.java @@ -474,7 +474,7 @@ public List getOutputConnectionsList() { } public void disconnectInputFbo(int inputId) { - logger.atInfo().addArgument(() -> this.getUri()).addArgument(inputId).log("Disconnecting {} input Fbo number {}"); + logger.info("Disconnecting {} input Fbo number {}", this.getUri(), inputId); //NOPMD DependencyConnection connectionToDisconnect = this.inputConnections.get(FboConnection.getConnectionName(inputId, this.nodeUri)); if (connectionToDisconnect != null) { // TODO make it reconnectInputFboToOutput @@ -549,8 +549,8 @@ public void dispose() { */ protected void addDesiredStateChange(StateChange stateChange) { if (stateChange.isTheDefaultInstance()) { - logger.atError().addArgument(() -> stateChange.getClass().getSimpleName()).addArgument(this). - log("Attempted to add default state change {} to the set of desired state changes. (Node: {})"); + logger.error("Attempted to add default state change {} to the set of desired state changes. (Node: {})", + stateChange.getClass().getSimpleName(), this); //NOPMD } desiredStateChanges.add(stateChange); } diff --git a/engine/src/main/java/org/terasology/engine/rendering/dag/RenderGraph.java b/engine/src/main/java/org/terasology/engine/rendering/dag/RenderGraph.java index 9e1e37951e4..b80d2a58eaa 100644 --- a/engine/src/main/java/org/terasology/engine/rendering/dag/RenderGraph.java +++ b/engine/src/main/java/org/terasology/engine/rendering/dag/RenderGraph.java @@ -52,8 +52,8 @@ public void addNode(Node node) { } if (akaNodeMap.containsKey(nodeAka)) { Node aNode = akaNodeMap.get(nodeAka); - logger.atInfo().addArgument(nodeUri).addArgument(nodeAka).addArgument(() -> aNode.getUri()). - log("Node {} also known as {} already matches existing node with uri {} - attempting replacing..."); + logger.info("Node {} also known as {} already matches existing node with uri {} - attempting replacing...", + nodeUri, nodeAka, aNode.getUri()); //NOPMD replaceNode(aNode, node); } else { nodeMap.put(nodeUri, node); @@ -149,8 +149,7 @@ private void connect(Node... nodeList) { if (!graph.hasEdgeConnecting(fromNode, toNode)) { graph.putEdge(fromNode, toNode); } else { - logger.atWarn().addArgument(fromNode.getUri()).addArgument(toNode.getUri()). - log("Trying to connect two already connected nodes, {} and {}", fromNode.getUri(), toNode.getUri()); + logger.warn("Trying to connect two already connected nodes, {} and {}", fromNode.getUri(), toNode.getUri()); //NOPMD } } @@ -170,8 +169,7 @@ public void disconnect(Node fromNode, Node toNode) { Preconditions.checkNotNull(toNode, "toNode cannot be null!"); if (!graph.hasEdgeConnecting(fromNode, toNode)) { - logger.atWarn().addArgument(() -> fromNode.getUri()).addArgument(() -> toNode.getUri()). - log("Trying to disconnect two nodes that aren't connected, {} and {}"); + logger.warn("Trying to disconnect two nodes that aren't connected, {} and {}", fromNode.getUri(), toNode.getUri()); //NOPMD } graph.removeEdge(fromNode, toNode); @@ -277,8 +275,8 @@ private void connectFbo(Node toNode, int inputFboId, DependencyConnection fromCo } else { // if adding new input failed, it already existed - check for connections //TODO update - logger.atInfo().addArgument(() -> toNode.getUri()).addArgument(inputFboId).addArgument(() -> fromConnection.getName()). - log("{}.connectFbo({}, {}): Connection already existed. Testing for its connections.."); + logger.info("{}.connectFbo({}, {}): Connection already existed. Testing for its connections..", + toNode.getUri(), inputFboId, fromConnection.getName()); //NOPMD DependencyConnection localConnection = toNode.getInputFboConnection(inputFboId); // DependencyConnection localConnectionConnectedTo = localConnection.getConnectedConnections(); // if our input is connected @@ -342,8 +340,8 @@ private void connectBufferPair(Node toNode, int inputConnectionId, DependencyCon } else { // if adding new input failed, it already existed - check for connections //TODO update - logger.atInfo().addArgument(() -> toNode.getUri()).addArgument(inputConnectionId).addArgument(() -> fromConnection.getName()). - log("{}.connectFbo({}, {}): Connection already existed. Testing for its connections.."); + logger.info("{}.connectFbo({}, {}): Connection already existed. Testing for its connections..", + toNode.getUri(), inputConnectionId, fromConnection.getName()); //NOPMD DependencyConnection localConnection = toNode.getInputBufferPairConnection(inputConnectionId); // DependencyConnection localConnectionConnectedTo = localConnection.getConnectedConnections(); // if our input is connected @@ -533,14 +531,13 @@ public void reconnectInputToOutput(String fromNodeUri, int outputId, Node toNode */ private void reconnectInputToOutput(Node toNode, int inputId, DependencyConnection fromConnection, ConnectionType connectionType, boolean disconnectPrevious) { - logger.atDebug().addArgument(() -> toNode.getUri()).addArgument(() -> fromConnection.getParentNode()). - log("Attempting reconnection of {} to {}'s output."); + logger.debug("Attempting reconnection of {} to {}'s output.", toNode.getUri(), fromConnection.getParentNode()); //NOPMD Node fromNode; fromNode = findNode(fromConnection.getParentNode()); if (!fromConnection.getConnectedConnections().isEmpty()) { - logger.atWarn().addArgument(fromConnection).addArgument(() -> fromConnection.getConnectedConnections()). - log("WARNING: destination connection ({}) is already connected to ({})"); + logger.warn("WARNING: destination connection ({}) is already connected to ({})", + fromConnection, fromConnection.getConnectedConnections()); //NOPMD // TODO update the hashmap to string to be pretty // throw new RuntimeException("Could not reconnect, destination connection (" + fromConnection + ") is already connected to (" // + fromConnection.getConnectedConnections() + "). Remove connection first."); diff --git a/engine/src/main/java/org/terasology/engine/rendering/dag/RenderTaskListGenerator.java b/engine/src/main/java/org/terasology/engine/rendering/dag/RenderTaskListGenerator.java index d00ad950fde..a3f99a95a74 100644 --- a/engine/src/main/java/org/terasology/engine/rendering/dag/RenderTaskListGenerator.java +++ b/engine/src/main/java/org/terasology/engine/rendering/dag/RenderTaskListGenerator.java @@ -42,21 +42,22 @@ public RenderTaskListGenerator() { taskList = Lists.newArrayList(); } + @SuppressWarnings("PMD.GuardLogStatement") private void logIntermediateRendererListForDebugging(List orderedNodes) { for (Node node : orderedNodes) { if (node.isEnabled()) { // printing out node name - logger.atInfo().addArgument(() -> node.getClass().getSimpleName()).log("----- {}"); + logger.info("----- {}", node.getClass().getSimpleName()); // printing out individual desired state changes for (StateChange desiredStateChange : node.getDesiredStateChanges()) { - logger.atInfo().addArgument(desiredStateChange).log("{}"); + logger.info("{}", desiredStateChange); } // printing out process() statement - logger.atInfo().addArgument(node).log("{}: process()"); + logger.info("{}: process()", node); } } } @@ -166,22 +167,17 @@ public List generateFrom(List orderedNodes) { long endTimeInNanoSeconds = System.nanoTime(); - // if (logger.isDebugEnabled()) { - logger.atDebug().log("===== INTERMEDIATE RENDERER LIST ========================="); + if (logger.isDebugEnabled()) { + logger.debug("===== INTERMEDIATE RENDERER LIST ========================="); logIntermediateRendererListForDebugging(orderedNodes); - logger.atDebug().log("===== RENDERER TASK LIST ================================="); + logger.debug("===== RENDERER TASK LIST ================================="); logList(taskList); - logger.atDebug().log("----------------------------------------------------------"); - logger.atDebug().addArgument(() -> String.format("%.3f", (endTimeInNanoSeconds - startTimeInNanoSeconds) / 1000000f)). - log("Task list generated in {} ms"); - logger.atDebug(). - addArgument(() -> nodeList.size()). - addArgument(enabledNodes). - addArgument(taskList.size() - enabledNodes). - addArgument(potentialTasks). - log("{} nodes, {} enabled - {} tasks (excluding marker tasks) out of {} potential tasks."); - logger.atDebug().log("----------------------------------------------------------"); - // } + logger.debug("----------------------------------------------------------"); + logger.debug(String.format("Task list generated in %.3f ms", (endTimeInNanoSeconds - startTimeInNanoSeconds) / 1000000f)); + logger.debug(String.format("%s nodes, %s enabled - %s tasks (excluding marker tasks) out of %s potential tasks.", + nodeList.size(), enabledNodes, taskList.size() - enabledNodes, potentialTasks)); + logger.debug("----------------------------------------------------------"); + } return taskList; } diff --git a/engine/src/main/java/org/terasology/engine/rendering/logic/FloatingTextRenderer.java b/engine/src/main/java/org/terasology/engine/rendering/logic/FloatingTextRenderer.java index c8abc1a308f..22f04f084f8 100644 --- a/engine/src/main/java/org/terasology/engine/rendering/logic/FloatingTextRenderer.java +++ b/engine/src/main/java/org/terasology/engine/rendering/logic/FloatingTextRenderer.java @@ -77,7 +77,7 @@ private void render(Iterable floatingTextEntities) { LocationComponent location = entity.getComponent(LocationComponent.class); if (location == null) { - logger.atWarn().addArgument(() -> floatingText.text).log("location component is not defined can't render text: {}"); + logger.warn("location component is not defined can't render text: {}", floatingText.text); //NOPMD continue; } diff --git a/engine/src/main/java/org/terasology/engine/rendering/logic/SkeletonRenderer.java b/engine/src/main/java/org/terasology/engine/rendering/logic/SkeletonRenderer.java index 845edd2c6ff..0c2eac17b21 100644 --- a/engine/src/main/java/org/terasology/engine/rendering/logic/SkeletonRenderer.java +++ b/engine/src/main/java/org/terasology/engine/rendering/logic/SkeletonRenderer.java @@ -307,7 +307,7 @@ public void renderOpaque() { boneTransform.mul(bone.getInverseBindMatrix()); boneTransforms[bone.getIndex()] = boneTransform.transpose(); } else { - logger.atWarn().addArgument(() -> bone.getName()).log("Unable to resolve bone \"{}\""); + logger.warn("Unable to resolve bone \"{}\"", bone.getName()); //NOPMD boneTransforms[bone.getIndex()] = new Matrix4f(); } } diff --git a/engine/src/main/java/org/terasology/engine/rendering/nui/asset/UIFormat.java b/engine/src/main/java/org/terasology/engine/rendering/nui/asset/UIFormat.java index 37b30f544ce..fc74d07caf3 100644 --- a/engine/src/main/java/org/terasology/engine/rendering/nui/asset/UIFormat.java +++ b/engine/src/main/java/org/terasology/engine/rendering/nui/asset/UIFormat.java @@ -175,7 +175,7 @@ public UIWidget deserialize(JsonElement json, Type typeOfT, JsonDeserializationC if (id != null) { FieldMetadata fieldMetadata = elementMetadata.getField(ID_FIELD); if (fieldMetadata == null) { - logger.atWarn().addArgument(() -> elementMetadata.getId()).log("UIWidget type {} lacks id field"); + logger.warn("UIWidget type {} lacks id field", elementMetadata.getId()); //NOPMD } else { fieldMetadata.setValue(element, id); } @@ -218,8 +218,7 @@ public UIWidget deserialize(JsonElement json, Type typeOfT, JsonDeserializationC field.setValue(element, context.deserialize(jsonObject.get(field.getSerializationName()), field.getType())); } } catch (RuntimeException e) { - logger.atError().addArgument(() -> field.getName()).addArgument(type).addArgument(e). - log("Failed to deserialize field {} of {}"); + logger.error("Failed to deserialize field {} of {}", field.getName(), type, e); //NOPMD } } } diff --git a/engine/src/main/java/org/terasology/engine/rendering/nui/editor/utils/NUIEditorMenuTreeBuilder.java b/engine/src/main/java/org/terasology/engine/rendering/nui/editor/utils/NUIEditorMenuTreeBuilder.java index 016b40dec37..e13f2a6d7b1 100644 --- a/engine/src/main/java/org/terasology/engine/rendering/nui/editor/utils/NUIEditorMenuTreeBuilder.java +++ b/engine/src/main/java/org/terasology/engine/rendering/nui/editor/utils/NUIEditorMenuTreeBuilder.java @@ -259,7 +259,7 @@ private void populateContextMenu(JsonTree node, MenuTree addTree, boolean isSkin } } } else { - logger.atWarn().addArgument(() -> node.getValue()).log("Could not get class for node {}"); + logger.warn("Could not get class for node {}", node.getValue()); //NOPMD } } diff --git a/engine/src/main/java/org/terasology/engine/rendering/nui/internal/NUIManagerInternal.java b/engine/src/main/java/org/terasology/engine/rendering/nui/internal/NUIManagerInternal.java index af2ee4ce3e9..579e1f90b35 100644 --- a/engine/src/main/java/org/terasology/engine/rendering/nui/internal/NUIManagerInternal.java +++ b/engine/src/main/java/org/terasology/engine/rendering/nui/internal/NUIManagerInternal.java @@ -365,8 +365,7 @@ public T createScreen(ResourceUrn screenUri, Class root.getClass()).addArgument(expectedType). - log("Screen '{}' is a '{}' and not a '{}'"); + logger.error("Screen '{}' is a '{}' and not a '{}'", screenUri, root.getClass(), expectedType); //NOPMD } } return null; @@ -491,8 +490,7 @@ public T addOverlay(ResourceUrn overlayUri, Class e addOverlay(overlay, overlayUri); return overlay; } else { - logger.atError().addArgument(overlayUri).addArgument(() -> root.getClass()).addArgument(expectedType). - log("Screen '{}' is a '{}' and not a '{}'"); + logger.error("Screen '{}' is a '{}' and not a '{}'", overlayUri, root.getClass(), expectedType); //NOPMD } } return null; diff --git a/engine/src/main/java/org/terasology/engine/rendering/nui/layers/mainMenu/videoSettings/VideoSettingsScreen.java b/engine/src/main/java/org/terasology/engine/rendering/nui/layers/mainMenu/videoSettings/VideoSettingsScreen.java index 347065d85aa..746baa7ced4 100644 --- a/engine/src/main/java/org/terasology/engine/rendering/nui/layers/mainMenu/videoSettings/VideoSettingsScreen.java +++ b/engine/src/main/java/org/terasology/engine/rendering/nui/layers/mainMenu/videoSettings/VideoSettingsScreen.java @@ -328,7 +328,7 @@ public boolean onKeyEvent(NUIKeyEvent event) { } public void saveSettings() { - logger.atInfo().addArgument(() -> config.renderConfigAsJson(config.getRendering())).log("Video Settings: {}"); + logger.info("Video Settings: {}", config.renderConfigAsJson(config.getRendering())); //NOPMD // TODO: add a dirty flag that checks if recompiling is needed CoreRegistry.get(ShaderManager.class).recompileAllShaders(); triggerBackAnimation(); diff --git a/engine/src/main/java/org/terasology/engine/rendering/nui/widgets/UIButtonWebBrowser.java b/engine/src/main/java/org/terasology/engine/rendering/nui/widgets/UIButtonWebBrowser.java index 8a32043ca2b..340dc90b7c6 100644 --- a/engine/src/main/java/org/terasology/engine/rendering/nui/widgets/UIButtonWebBrowser.java +++ b/engine/src/main/java/org/terasology/engine/rendering/nui/widgets/UIButtonWebBrowser.java @@ -68,7 +68,7 @@ public class UIButtonWebBrowser extends UIButton { try { desktop.browse(new URI(this.url)); } catch (IOException | URISyntaxException e) { - logger.atWarn().addArgument(() -> this.url).log("Can't open {} in default browser of your system."); + logger.warn("Can't open {} in default browser of your system.", this.url); //NOPMD showErrorPopup("Can't open " + this.url + " in default browser of your system."); } } else { @@ -83,7 +83,7 @@ public class UIButtonWebBrowser extends UIButton { runtime.exec(createCommand("xdg-open", this.url)); } } catch (IOException e) { - logger.atWarn().addArgument(() -> this.url).log("Can't recognize your OS and open the url {}."); + logger.warn("Can't recognize your OS and open the url {}.", this.url); //NOPMD showErrorPopup("Can't recognize your OS and open the url " + this.url); } } @@ -125,7 +125,7 @@ private void showConfirmationPopup() { confirmUrlPopup.setCheckbox(webBrowserConfig, this.url); } } catch (MalformedURLException e) { - logger.atError().addArgument(() -> this.url).addArgument(e).log("{} is malformed"); + logger.error("{} is malformed", this.url, e); //NOPMD } } diff --git a/engine/src/main/java/org/terasology/engine/rendering/opengl/GLSLMaterial.java b/engine/src/main/java/org/terasology/engine/rendering/opengl/GLSLMaterial.java index 090cf99d3ed..ab45466732d 100644 --- a/engine/src/main/java/org/terasology/engine/rendering/opengl/GLSLMaterial.java +++ b/engine/src/main/java/org/terasology/engine/rendering/opengl/GLSLMaterial.java @@ -156,7 +156,7 @@ public final void doReload(MaterialData data) { rebindVariables(data); }); } catch (InterruptedException e) { - logger.atError().addArgument(() -> getUrn()).addArgument(e).log("Failed to reload {}"); + logger.error("Failed to reload {}", getUrn(), e); //NOPMD } } @@ -228,8 +228,7 @@ public void activateFeature(ShaderProgramFeature feature) { activeFeaturesMask = ShaderProgramFeature.getBitset(activeFeatures); activeFeaturesChanged = true; } else { - logger.atError().addArgument(feature).addArgument(() -> getUrn()).addArgument(() -> shader.getUrn()). - log("Attempt to activate unsupported feature {} for material {} using shader {}", feature, getUrn(), shader.getUrn()); + logger.error("Attempt to activate unsupported feature {} for material {} using shader {}", feature, getUrn(), shader.getUrn()); //NOPMD } } diff --git a/engine/src/main/java/org/terasology/engine/rendering/opengl/GLSLShader.java b/engine/src/main/java/org/terasology/engine/rendering/opengl/GLSLShader.java index 749fb9e072e..6f0ffe48ab6 100644 --- a/engine/src/main/java/org/terasology/engine/rendering/opengl/GLSLShader.java +++ b/engine/src/main/java/org/terasology/engine/rendering/opengl/GLSLShader.java @@ -278,8 +278,7 @@ private void registerAllShaderPermutations() { disposalAction.vertexPrograms.put(featureHash, vertShaderId); } - logger.atDebug().addArgument(() -> allPermutations.size()).addArgument(() -> getUrn()). - log("Compiled {} permutations for {}."); + logger.debug("Compiled {} permutations for {}.", allPermutations.size(), getUrn()); //NOPMD } private String assembleShader(int type, Set features) { @@ -365,7 +364,7 @@ private int compileShader(int type, Set features) { protected void doReload(ShaderData data) { try { GameThread.synch(() -> { - logger.atDebug().addArgument(() -> getUrn()).log("Recompiling shader {}."); + logger.debug("Recompiling shader {}.", getUrn()); //NOPMD disposalAction.disposeData(); shaderProgramBase = data; @@ -377,11 +376,11 @@ protected void doReload(ShaderData data) { try { registerAllShaderPermutations(); } catch (RuntimeException e) { - logger.atWarn().addArgument(() -> e.getMessage()).log("{}"); + logger.warn("{}", e.getMessage()); //NOPMD } }); } 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/rendering/opengl/OpenGLMesh.java b/engine/src/main/java/org/terasology/engine/rendering/opengl/OpenGLMesh.java index 833a1bc589f..303d6712d1d 100644 --- a/engine/src/main/java/org/terasology/engine/rendering/opengl/OpenGLMesh.java +++ b/engine/src/main/java/org/terasology/engine/rendering/opengl/OpenGLMesh.java @@ -54,7 +54,7 @@ protected void doReload(MeshData newData) { try { GameThread.synch(() -> buildMesh(newData)); } catch (InterruptedException e) { - logger.atError().addArgument(() -> getUrn()).addArgument(e).log("Failed to reload {}"); + logger.error("Failed to reload {}", getUrn(), e); //NOPMD } } @@ -86,7 +86,7 @@ public void render() { } GL30.glBindVertexArray(0); } else { - logger.atError().addArgument(() -> getUrn()).log("Attempted to render disposed mesh: {}"); + logger.error("Attempted to render disposed mesh: {}", getUrn()); //NOPMD } } diff --git a/engine/src/main/java/org/terasology/engine/rendering/opengl/OpenGLSkeletalMesh.java b/engine/src/main/java/org/terasology/engine/rendering/opengl/OpenGLSkeletalMesh.java index 2e53f93539c..a50cd945214 100644 --- a/engine/src/main/java/org/terasology/engine/rendering/opengl/OpenGLSkeletalMesh.java +++ b/engine/src/main/java/org/terasology/engine/rendering/opengl/OpenGLSkeletalMesh.java @@ -112,7 +112,7 @@ protected void doReload(SkeletalMeshData newData) { GL30.glBindVertexArray(0); }); } 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/rendering/opengl/OpenGLTexture.java b/engine/src/main/java/org/terasology/engine/rendering/opengl/OpenGLTexture.java index 049304ee9be..e74ccafd27c 100644 --- a/engine/src/main/java/org/terasology/engine/rendering/opengl/OpenGLTexture.java +++ b/engine/src/main/java/org/terasology/engine/rendering/opengl/OpenGLTexture.java @@ -82,8 +82,7 @@ protected void doReload(TextureData data) { resources.graphicsManager.disposeTexture(newId); } else { resources.id = newId; - logger.atDebug().addArgument(() -> getUrn()).addArgument(resources.id). - log("Bound texture '{}' - {}"); + logger.debug("Bound texture '{}' - {}", getUrn(), resources.id); //NOPMD } } }); diff --git a/engine/src/main/java/org/terasology/engine/utilities/concurrency/TaskProcessor.java b/engine/src/main/java/org/terasology/engine/utilities/concurrency/TaskProcessor.java index 5b41d908a35..5e16b2f0c7b 100644 --- a/engine/src/main/java/org/terasology/engine/utilities/concurrency/TaskProcessor.java +++ b/engine/src/main/java/org/terasology/engine/utilities/concurrency/TaskProcessor.java @@ -42,7 +42,7 @@ public void run() { logger.error("Thread interrupted", e); } catch (RuntimeException e) { ThreadMonitor.addError(e); - logger.atError().addArgument(Thread.currentThread().getName()).addArgument(e).log("Error in thread {}"); + logger.error("Error in thread {}", Thread.currentThread().getName(), e); //NOPMD } catch (Error e) { GameThread.asynch(() -> { throw e; // re-throw on game thread to terminate the entire application 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 8f55f529166..c088902376d 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.atError().addArgument(() -> entry.getSimpleName()).log("Cannot load {}, must be a subclass of BlockFamily"); + logger.error("Cannot load {}, must be a subclass of BlockFamily", entry.getSimpleName()); //NOPMD continue; } RegisterBlockFamily registerInfo = entry.getAnnotation(RegisterBlockFamily.class); @@ -96,7 +96,7 @@ public Optional get(Class type) { return result; } catch (Exception e) { - logger.atError().addArgument(blockFamily).addArgument(e).log("Failed to load blockFamily {}"); + logger.error("Failed to load blockFamily {}", blockFamily, e); //NOPMD } 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 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 { 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 b6c3bd88c06..eae24bab56e 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.atError().addArgument(() -> chunk.getPosition()).addArgument(e).log("Failed to enqueue unload request for {}"); + logger.error("Failed to enqueue unload request for {}", chunk.getPosition(), e); //NOPMD } return true; @@ -299,7 +299,7 @@ void gatherBlockPositionsForDeactivate(Chunk chunk) { try { deactivateBlocksQueue.put(createBatchBlockEventMappings(chunk)); } catch (InterruptedException e) { - logger.atError().addArgument(() -> chunk.getPosition()).log("Failed to queue deactivation of blocks for {}"); + logger.error("Failed to queue deactivation of blocks for {}", chunk.getPosition()); //NOPMD } }