From 55af37bfee680d784bcbbb990f23a31320062c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hasan=20Demirta=C5=9F?= Date: Tue, 15 Oct 2024 15:56:15 +0300 Subject: [PATCH] log. --- .../net/infumia/frame/state/StateImpl.java | 8 ++++++ .../infumia/frame/state/StateInitialImpl.java | 9 ++++++ .../frame/state/value/StateValueHostImpl.java | 28 +++++++++++++------ .../frame/state/value/StateValueHostRich.java | 4 --- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/net/infumia/frame/state/StateImpl.java b/core/src/main/java/net/infumia/frame/state/StateImpl.java index ef44464..e2fe346 100644 --- a/core/src/main/java/net/infumia/frame/state/StateImpl.java +++ b/core/src/main/java/net/infumia/frame/state/StateImpl.java @@ -1,6 +1,7 @@ package net.infumia.frame.state; import java.util.Objects; +import java.util.StringJoiner; import java.util.concurrent.CompletableFuture; import net.infumia.frame.state.value.StateValue; import net.infumia.frame.state.value.StateValueFactory; @@ -97,6 +98,13 @@ public void watchUpdate( ((StateValueHostRich) host.stateValueHost()).watchStateUpdate(this, watcher); } + @Override + public String toString() { + return new StringJoiner(", ", StateImpl.class.getSimpleName() + "[", "]") + .add("id=" + this.id) + .toString(); + } + @Override public int hashCode() { return Objects.hashCode(this.id); diff --git a/core/src/main/java/net/infumia/frame/state/StateInitialImpl.java b/core/src/main/java/net/infumia/frame/state/StateInitialImpl.java index 97581d9..e51cac7 100644 --- a/core/src/main/java/net/infumia/frame/state/StateInitialImpl.java +++ b/core/src/main/java/net/infumia/frame/state/StateInitialImpl.java @@ -1,5 +1,6 @@ package net.infumia.frame.state; +import java.util.StringJoiner; import net.infumia.frame.state.value.StateValueFactory; import org.jetbrains.annotations.NotNull; @@ -16,6 +17,14 @@ public StateInitialImpl( this.key = key; } + @Override + public String toString() { + return new StringJoiner(", ", StateInitialImpl.class.getSimpleName() + "[", "]") + .add("id='" + this.id() + "'") + .add("key='" + this.key + "'") + .toString(); + } + @Override public String key() { return this.key; diff --git a/core/src/main/java/net/infumia/frame/state/value/StateValueHostImpl.java b/core/src/main/java/net/infumia/frame/state/value/StateValueHostImpl.java index 295b9a2..fca2844 100644 --- a/core/src/main/java/net/infumia/frame/state/value/StateValueHostImpl.java +++ b/core/src/main/java/net/infumia/frame/state/value/StateValueHostImpl.java @@ -5,6 +5,7 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; import net.infumia.frame.context.ContextBase; +import net.infumia.frame.extension.CompletableFutureExtensions; import net.infumia.frame.pipeline.PipelineServiceConsumer; import net.infumia.frame.pipeline.context.PipelineContextState; import net.infumia.frame.pipeline.executor.PipelineExecutorState; @@ -28,12 +29,6 @@ public StateValueHostImpl(@NotNull final ContextBase context) { this.pipelines = new PipelineExecutorStateImpl(context); } - @NotNull - @Override - public PipelineExecutorState statePipelines() { - return this.pipelines; - } - @NotNull @Override public Map, StateValue> stateValues() { @@ -57,7 +52,12 @@ public StateValue accessStateValue(@NotNull final StateRich state) { .debug("State '%s' not found in '%s'!", state, this.values); return null; } - this.pipelines.executeAccess(state, value); + CompletableFutureExtensions.logError( + this.pipelines.executeAccess(state, value), + this.context.frame().logger(), + "An error occurred while accessing state '%s'!", + state + ); return (StateValue) value; } @@ -73,7 +73,12 @@ public StateValue updateStateValue( } final T oldValue = stateValue.value(); stateValue.value(value); - this.pipelines.executeUpdate(state, oldValue, stateValue); + CompletableFutureExtensions.logError( + this.pipelines.executeUpdate(state, oldValue, stateValue), + this.context.frame().logger(), + "An error occurred while updating state '%s'!", + state + ); return stateValue; } @@ -84,7 +89,12 @@ public StateValue updateStateValue(@NotNull final StateRich state) { if (stateValue == null) { return null; } - this.pipelines.executeUpdate(state, stateValue.value(), stateValue); + CompletableFutureExtensions.logError( + this.pipelines.executeUpdate(state, stateValue.value(), stateValue), + this.context.frame().logger(), + "An error occurred while updating state '%s'!", + state + ); return stateValue; } diff --git a/core/src/main/java/net/infumia/frame/state/value/StateValueHostRich.java b/core/src/main/java/net/infumia/frame/state/value/StateValueHostRich.java index a579199..c01dec1 100644 --- a/core/src/main/java/net/infumia/frame/state/value/StateValueHostRich.java +++ b/core/src/main/java/net/infumia/frame/state/value/StateValueHostRich.java @@ -2,7 +2,6 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; -import net.infumia.frame.pipeline.executor.PipelineExecutorState; import net.infumia.frame.state.StateMutableRich; import net.infumia.frame.state.StateRich; import net.infumia.frame.state.watcher.StateWatcherAccess; @@ -11,9 +10,6 @@ import org.jetbrains.annotations.Nullable; public interface StateValueHostRich extends StateValueHost { - @NotNull - PipelineExecutorState statePipelines(); - @NotNull Map, StateValue> stateValues();