Skip to content

Commit

Permalink
refactor: rename value loggers
Browse files Browse the repository at this point in the history
Renamed value loggers from log*Record to log*RecordValue. This makes it more clear that we are logging the value of the record in these functions.
  • Loading branch information
remcowesterhoud committed Feb 25, 2022
1 parent 954bc99 commit 5fe8c0f
Showing 1 changed file with 34 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,26 @@ public class RecordStreamLogger {

public RecordStreamLogger(final RecordStreamSource recordStreamSource) {
this.recordStream = RecordStream.of(recordStreamSource);
valueTypeLoggers.put(ValueType.JOB, this::logJobRecord);
valueTypeLoggers.put(ValueType.DEPLOYMENT, this::logDeploymentRecord);
valueTypeLoggers.put(ValueType.PROCESS_INSTANCE, this::logProcessInstanceRecord);
valueTypeLoggers.put(ValueType.INCIDENT, this::logIncidentRecord);
valueTypeLoggers.put(ValueType.MESSAGE, this::logMessageRecord);
valueTypeLoggers.put(ValueType.MESSAGE_SUBSCRIPTION, this::logMessageSubscriptionRecord);
valueTypeLoggers.put(ValueType.JOB, this::logJobRecordValue);
valueTypeLoggers.put(ValueType.DEPLOYMENT, this::logDeploymentRecordValue);
valueTypeLoggers.put(ValueType.PROCESS_INSTANCE, this::logProcessInstanceRecordValue);
valueTypeLoggers.put(ValueType.INCIDENT, this::logIncidentRecordValue);
valueTypeLoggers.put(ValueType.MESSAGE, this::logMessageRecordValue);
valueTypeLoggers.put(ValueType.MESSAGE_SUBSCRIPTION, this::logMessageSubscriptionRecordValue);
valueTypeLoggers.put(
ValueType.PROCESS_MESSAGE_SUBSCRIPTION, this::logProcessMessageSubscriptionRecord);
valueTypeLoggers.put(ValueType.JOB_BATCH, this::logJobBatchRecord);
valueTypeLoggers.put(ValueType.TIMER, this::logTimerRecord);
ValueType.PROCESS_MESSAGE_SUBSCRIPTION, this::logProcessMessageSubscriptionRecordValue);
valueTypeLoggers.put(ValueType.JOB_BATCH, this::logJobBatchRecordValue);
valueTypeLoggers.put(ValueType.TIMER, this::logTimerRecordValue);
valueTypeLoggers.put(
ValueType.MESSAGE_START_EVENT_SUBSCRIPTION, this::logMessageStartEventSubscriptionRecord);
valueTypeLoggers.put(ValueType.VARIABLE, this::logVariableRecord);
valueTypeLoggers.put(ValueType.VARIABLE_DOCUMENT, this::logVariableDocumentRecord);
ValueType.MESSAGE_START_EVENT_SUBSCRIPTION, this::logMessageStartEventSubscriptionRecordValue);
valueTypeLoggers.put(ValueType.VARIABLE, this::logVariableRecordValue);
valueTypeLoggers.put(ValueType.VARIABLE_DOCUMENT, this::logVariableDocumentRecordValue);
valueTypeLoggers.put(
ValueType.PROCESS_INSTANCE_CREATION, this::logProcessInstanceCreationRecord);
valueTypeLoggers.put(ValueType.ERROR, this::logErrorRecord);
valueTypeLoggers.put(ValueType.PROCESS_INSTANCE_RESULT, this::logProcessInstanceResultRecord);
valueTypeLoggers.put(ValueType.PROCESS, this::logProcessRecord);
valueTypeLoggers.put(ValueType.PROCESS_EVENT, this::logProcessEventRecord);
ValueType.PROCESS_INSTANCE_CREATION, this::logProcessInstanceCreationRecordValue);
valueTypeLoggers.put(ValueType.ERROR, this::logErrorRecordValue);
valueTypeLoggers.put(ValueType.PROCESS_INSTANCE_RESULT, this::logProcessInstanceResultRecordValue);
valueTypeLoggers.put(ValueType.PROCESS, this::logProcessRecordValue);
valueTypeLoggers.put(ValueType.PROCESS_EVENT, this::logProcessEventRecordValue);

// These records don't have any interesting extra information for the user to log
valueTypeLoggers.put(ValueType.DEPLOYMENT_DISTRIBUTION, record -> "");
Expand Down Expand Up @@ -94,7 +94,7 @@ private String logGenericRecord(final Record<?> record) {
+ String.format("%-30s| ", record.getIntent());
}

private String logJobRecord(final Record<?> record) {
private String logJobRecordValue(final Record<?> record) {
final JobRecordValue value = (JobRecordValue) record.getValue();
final StringJoiner joiner = new StringJoiner(", ", "", "");
// These fields are empty for commands
Expand All @@ -106,7 +106,7 @@ private String logJobRecord(final Record<?> record) {
return joiner.toString();
}

private String logDeploymentRecord(final Record<?> record) {
private String logDeploymentRecordValue(final Record<?> record) {
final DeploymentRecordValue value = (DeploymentRecordValue) record.getValue();
final StringBuilder stringBuilder = new StringBuilder();
if (!value.getResources().isEmpty()) {
Expand All @@ -117,7 +117,7 @@ private String logDeploymentRecord(final Record<?> record) {
return stringBuilder.toString();
}

private String logProcessInstanceRecord(final Record<?> record) {
private String logProcessInstanceRecordValue(final Record<?> record) {
final ProcessInstanceRecordValue value = (ProcessInstanceRecordValue) record.getValue();
final StringJoiner joiner = new StringJoiner(", ", "", "");
joiner.add(String.format("(Element id: %s)", value.getElementId()));
Expand All @@ -126,7 +126,7 @@ private String logProcessInstanceRecord(final Record<?> record) {
return joiner.toString();
}

private String logIncidentRecord(final Record<?> record) {
private String logIncidentRecordValue(final Record<?> record) {
final IncidentRecordValue value = (IncidentRecordValue) record.getValue();
final StringJoiner joiner = new StringJoiner(", ", "", "");
if (record.getRecordType().equals(RecordType.EVENT)) {
Expand All @@ -136,7 +136,7 @@ private String logIncidentRecord(final Record<?> record) {
return joiner.toString();
}

private String logMessageRecord(final Record<?> record) {
private String logMessageRecordValue(final Record<?> record) {
final MessageRecordValue value = (MessageRecordValue) record.getValue();
final StringJoiner joiner = new StringJoiner(", ", "", "");
joiner.add(String.format("(Message name: %s)", value.getName()));
Expand All @@ -145,7 +145,7 @@ private String logMessageRecord(final Record<?> record) {
return joiner.toString();
}

private String logMessageSubscriptionRecord(final Record<?> record) {
private String logMessageSubscriptionRecordValue(final Record<?> record) {
final MessageSubscriptionRecordValue value = (MessageSubscriptionRecordValue) record.getValue();
final StringJoiner joiner = new StringJoiner(", ", "", "");
joiner.add(String.format("(Message name: %s)", value.getMessageName()));
Expand All @@ -154,7 +154,7 @@ private String logMessageSubscriptionRecord(final Record<?> record) {
return joiner.toString();
}

private String logProcessMessageSubscriptionRecord(final Record<?> record) {
private String logProcessMessageSubscriptionRecordValue(final Record<?> record) {
final ProcessMessageSubscriptionRecordValue value =
(ProcessMessageSubscriptionRecordValue) record.getValue();
final StringJoiner joiner = new StringJoiner(", ", "", "");
Expand All @@ -170,23 +170,23 @@ private String logProcessMessageSubscriptionRecord(final Record<?> record) {
return joiner.toString();
}

private String logJobBatchRecord(final Record<?> record) {
private String logJobBatchRecordValue(final Record<?> record) {
final JobBatchRecordValue value = (JobBatchRecordValue) record.getValue();
final StringJoiner joiner = new StringJoiner(", ", "", "");
joiner.add(String.format("(Worker: %s)", value.getWorker()));
joiner.add(String.format("(Job type: %s)", value.getType()));
return joiner.toString();
}

private String logTimerRecord(final Record<?> record) {
private String logTimerRecordValue(final Record<?> record) {
final TimerRecordValue value = (TimerRecordValue) record.getValue();
final StringJoiner joiner = new StringJoiner(", ", "", "");
joiner.add(String.format("(Element id: %s)", value.getTargetElementId()));
joiner.add(String.format("(Due date: %s)", new Date(value.getDueDate())));
return joiner.toString();
}

private String logMessageStartEventSubscriptionRecord(final Record<?> record) {
private String logMessageStartEventSubscriptionRecordValue(final Record<?> record) {
final MessageStartEventSubscriptionRecordValue value =
(MessageStartEventSubscriptionRecordValue) record.getValue();
final StringJoiner joiner = new StringJoiner(", ", "", "");
Expand All @@ -197,20 +197,20 @@ private String logMessageStartEventSubscriptionRecord(final Record<?> record) {
return joiner.toString();
}

private String logVariableRecord(final Record<?> record) {
private String logVariableRecordValue(final Record<?> record) {
final VariableRecordValue value = (VariableRecordValue) record.getValue();
final StringJoiner joiner = new StringJoiner(", ", "", "");
joiner.add(String.format("(Name: %s)", value.getName()));
joiner.add(String.format("(Value: %s)", value.getValue()));
return joiner.toString();
}

private String logVariableDocumentRecord(final Record<?> record) {
private String logVariableDocumentRecordValue(final Record<?> record) {
final VariableDocumentRecordValue value = (VariableDocumentRecordValue) record.getValue();
return logVariables(value.getVariables());
}

private String logProcessInstanceCreationRecord(final Record<?> record) {
private String logProcessInstanceCreationRecordValue(final Record<?> record) {
final ProcessInstanceCreationRecordValue value =
(ProcessInstanceCreationRecordValue) record.getValue();
final StringJoiner joiner = new StringJoiner(", ", "", "");
Expand All @@ -219,12 +219,12 @@ private String logProcessInstanceCreationRecord(final Record<?> record) {
return joiner.toString();
}

private String logErrorRecord(final Record<?> record) {
private String logErrorRecordValue(final Record<?> record) {
final ErrorRecordValue value = (ErrorRecordValue) record.getValue();
return String.format("(Exception message: %s)", value.getExceptionMessage());
}

private String logProcessInstanceResultRecord(final Record<?> record) {
private String logProcessInstanceResultRecordValue(final Record<?> record) {
final ProcessInstanceResultRecordValue value =
(ProcessInstanceResultRecordValue) record.getValue();
final StringJoiner joiner = new StringJoiner(", ", "", "");
Expand All @@ -233,12 +233,12 @@ private String logProcessInstanceResultRecord(final Record<?> record) {
return joiner.toString();
}

private String logProcessRecord(final Record<?> record) {
private String logProcessRecordValue(final Record<?> record) {
final ProcessMetadataValue value = (ProcessMetadataValue) record.getValue();
return String.format("(Process: %s)", value.getResourceName());
}

private String logProcessEventRecord(final Record<?> record) {
private String logProcessEventRecordValue(final Record<?> record) {
final ProcessEventRecordValue value = (ProcessEventRecordValue) record.getValue();
final StringJoiner joiner = new StringJoiner(", ", "", "");
joiner.add(String.format("(Target element id: %s)", value.getTargetElementId()));
Expand Down

0 comments on commit 5fe8c0f

Please sign in to comment.