Skip to content

Commit

Permalink
log.
Browse files Browse the repository at this point in the history
  • Loading branch information
portlek committed Oct 15, 2024
1 parent 9e12b4c commit 55af37b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
8 changes: 8 additions & 0 deletions core/src/main/java/net/infumia/frame/state/StateImpl.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<StateRich<Object>, StateValue<Object>> stateValues() {
Expand All @@ -57,7 +52,12 @@ public <T> StateValue<T> accessStateValue(@NotNull final StateRich<T> 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<T>) value;
}

Expand All @@ -73,7 +73,12 @@ public <T> StateValue<T> 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;
}

Expand All @@ -84,7 +89,12 @@ public <T> StateValue<T> updateStateValue(@NotNull final StateRich<T> 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -11,9 +10,6 @@
import org.jetbrains.annotations.Nullable;

public interface StateValueHostRich extends StateValueHost {
@NotNull
PipelineExecutorState statePipelines();

@NotNull
Map<StateRich<Object>, StateValue<Object>> stateValues();

Expand Down

0 comments on commit 55af37b

Please sign in to comment.