Skip to content

Commit

Permalink
Merge pull request #1224 from camunda/add-missing-valuetypes
Browse files Browse the repository at this point in the history
Add USER and CLOCK ValueTypes to the RecordStreamLogger
  • Loading branch information
remcowesterhoud authored Aug 16, 2024
2 parents 29c38e4 + 51d7bd6 commit 4d972fb
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.camunda.zeebe.protocol.record.Record;
import io.camunda.zeebe.protocol.record.RecordType;
import io.camunda.zeebe.protocol.record.ValueType;
import io.camunda.zeebe.protocol.record.value.ClockRecordValue;
import io.camunda.zeebe.protocol.record.value.CommandDistributionRecordValue;
import io.camunda.zeebe.protocol.record.value.CompensationSubscriptionRecordValue;
import io.camunda.zeebe.protocol.record.value.DeploymentRecordValue;
Expand Down Expand Up @@ -48,6 +49,7 @@
import io.camunda.zeebe.protocol.record.value.SignalRecordValue;
import io.camunda.zeebe.protocol.record.value.SignalSubscriptionRecordValue;
import io.camunda.zeebe.protocol.record.value.TimerRecordValue;
import io.camunda.zeebe.protocol.record.value.UserRecordValue;
import io.camunda.zeebe.protocol.record.value.UserTaskRecordValue;
import io.camunda.zeebe.protocol.record.value.VariableDocumentRecordValue;
import io.camunda.zeebe.protocol.record.value.VariableRecordValue;
Expand Down Expand Up @@ -127,6 +129,8 @@ public RecordStreamLogger(final RecordStreamSource recordStreamSource) {
valueTypeLoggers.put(
ValueType.COMPENSATION_SUBSCRIPTION, this::logCompensationSubscriptionRecordValue);
valueTypeLoggers.put(ValueType.MESSAGE_CORRELATION, this::logMessageCorrelationRecordValue);
valueTypeLoggers.put(ValueType.USER, this::logUsersRecordValue);
valueTypeLoggers.put(ValueType.CLOCK, this::logClockRecordValue);
}

public void log() {
Expand Down Expand Up @@ -502,4 +506,21 @@ private String logMessageCorrelationRecordValue(final Record<?> record) {
protected Map<ValueType, Function<Record<?>, String>> getValueTypeLoggers() {
return valueTypeLoggers;
}

private String logUsersRecordValue(final Record<?> record) {
final UserRecordValue value = (UserRecordValue) record.getValue();
final StringJoiner joiner = new StringJoiner(", ", "", "");
joiner.add(String.format("(Username: %s)", value.getUsername()));
joiner.add(String.format("(Name: %s)", value.getName()));
joiner.add(String.format("(Email: %s)", value.getEmail()));
joiner.add(String.format("(Password: %s)", value.getPassword()));
return joiner.toString();
}

private String logClockRecordValue(final Record<?> record) {
final ClockRecordValue value = (ClockRecordValue) record.getValue();
final StringJoiner joiner = new StringJoiner(", ", "", "");
joiner.add(String.format("(Time: %d", value.getTime()));
return joiner.toString();
}
}

0 comments on commit 4d972fb

Please sign in to comment.