Provided example for hands-off command handler logging, and documented
it's constraints.
diff --git a/service/src/main/java/io/mifos/template/service/internal/command/InitializeServiceCommand.java b/service/src/main/java/io/mifos/template/service/internal/command/InitializeServiceCommand.java
index db85b9d..e02d2d0 100644
--- a/service/src/main/java/io/mifos/template/service/internal/command/InitializeServiceCommand.java
+++ b/service/src/main/java/io/mifos/template/service/internal/command/InitializeServiceCommand.java
@@ -20,4 +20,9 @@
public InitializeServiceCommand() {
super();
}
+
+ @Override
+ public String toString() {
+ return "InitializeServiceCommand{}";
+ }
}
diff --git a/service/src/main/java/io/mifos/template/service/internal/command/SampleCommand.java b/service/src/main/java/io/mifos/template/service/internal/command/SampleCommand.java
index 8ee6d92..5957f1b 100644
--- a/service/src/main/java/io/mifos/template/service/internal/command/SampleCommand.java
+++ b/service/src/main/java/io/mifos/template/service/internal/command/SampleCommand.java
@@ -29,4 +29,11 @@
public Sample sample() {
return this.sample;
}
+
+ @Override
+ public String toString() {
+ return "SampleCommand{" +
+ "sample=" + sample.getIdentifier() +
+ '}';
+ }
}
diff --git a/service/src/main/java/io/mifos/template/service/internal/command/handler/MigrationAggregate.java b/service/src/main/java/io/mifos/template/service/internal/command/handler/MigrationAggregate.java
index 083513c..920465a 100644
--- a/service/src/main/java/io/mifos/template/service/internal/command/handler/MigrationAggregate.java
+++ b/service/src/main/java/io/mifos/template/service/internal/command/handler/MigrationAggregate.java
@@ -50,7 +50,7 @@
this.flywayFactoryBean = flywayFactoryBean;
}
- @CommandHandler
+ @CommandHandler(logStart = CommandLogLevel.INFO, logFinish = CommandLogLevel.INFO)
@Transactional
@EventEmitter(selectorName = EventConstants.SELECTOR_NAME, selectorValue = EventConstants.INITIALIZE)
public String initialize(final InitializeServiceCommand initializeServiceCommand) {
diff --git a/service/src/main/java/io/mifos/template/service/internal/command/handler/SampleAggregate.java b/service/src/main/java/io/mifos/template/service/internal/command/handler/SampleAggregate.java
index b2e8d5d..9a7c572 100644
--- a/service/src/main/java/io/mifos/template/service/internal/command/handler/SampleAggregate.java
+++ b/service/src/main/java/io/mifos/template/service/internal/command/handler/SampleAggregate.java
@@ -17,6 +17,7 @@
import io.mifos.core.command.annotation.Aggregate;
import io.mifos.core.command.annotation.CommandHandler;
+import io.mifos.core.command.annotation.CommandLogLevel;
import io.mifos.core.command.annotation.EventEmitter;
import io.mifos.template.api.v1.events.EventConstants;
import io.mifos.template.service.internal.command.SampleCommand;
@@ -37,7 +38,19 @@
this.sampleJpaEntityRepository = sampleJpaEntityRepository;
}
- @CommandHandler
+ //TODO: Think about your command handler logging, then delete this comment.
+ // The log levels provided in the command handler cause log messages to be emitted each time this
+ // command handler is called before and after the call. Before the call, the command is logged
+ // using its toString() method, and after the call, the emitted event is logged via its toString()
+ // method.
+ //
+ // If you wish to adjust the information in the log messages, do so via the toString() methods.
+ // Financial transactions, passwords, and customer address data are examples of information which
+ // should not be placed in the logs.
+ //
+ // If a command handler should not emit a log message, change logStart and logFinish to:
+ // CommandLogLevel.NONE.
+ @CommandHandler(logStart = CommandLogLevel.INFO, logFinish = CommandLogLevel.INFO)
@Transactional
@EventEmitter(selectorName = EventConstants.SELECTOR_NAME, selectorValue = EventConstants.POST_SAMPLE)
public String sample(final SampleCommand sampleCommand) {