This is an automated email from the ASF dual-hosted git repository. awasum pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/fineract-cn-payroll.git
commit 9e03ed87002217cca55d8d91823f95254432f75b Author: Myrle Krantz <[email protected]> AuthorDate: Mon Jul 10 12:05:02 2017 +0200 Provided example for hands-off command handler logging, and documented it's constraints. --- .../internal/command/InitializeServiceCommand.java | 5 +++++ .../template/service/internal/command/SampleCommand.java | 7 +++++++ .../internal/command/handler/MigrationAggregate.java | 2 +- .../service/internal/command/handler/SampleAggregate.java | 15 ++++++++++++++- 4 files changed, 27 insertions(+), 2 deletions(-) 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 class InitializeServiceCommand { 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 class SampleCommand { 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 @@ public class MigrationAggregate { 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 @@ package io.mifos.template.service.internal.command.handler; 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 @@ public class SampleAggregate { 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) {
