From 389343130d60f65238e2429b7add17660e1debb8 Mon Sep 17 00:00:00 2001 From: kkyovsky Date: Sun, 26 Nov 2023 15:30:01 +0100 Subject: [PATCH] BATM-5644 - added logging into extension template --- server_extensions_template/build.gradle | 1 + .../extensions/myfirstextension/MyFirstExtension.java | 7 +++++++ .../myfirstextension/MyTransactionListener.java | 8 ++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/server_extensions_template/build.gradle b/server_extensions_template/build.gradle index 76f878e57..b13228751 100644 --- a/server_extensions_template/build.gradle +++ b/server_extensions_template/build.gradle @@ -28,6 +28,7 @@ artifacts { } dependencies { + implementation("org.slf4j:slf4j-api:1.7.28") implementation project(":server_extensions_api") implementation project(":currencies") } \ No newline at end of file diff --git a/server_extensions_template/src/main/java/com/mygreatcompany/batm/server/extensions/myfirstextension/MyFirstExtension.java b/server_extensions_template/src/main/java/com/mygreatcompany/batm/server/extensions/myfirstextension/MyFirstExtension.java index 1baefc5f7..446451dee 100644 --- a/server_extensions_template/src/main/java/com/mygreatcompany/batm/server/extensions/myfirstextension/MyFirstExtension.java +++ b/server_extensions_template/src/main/java/com/mygreatcompany/batm/server/extensions/myfirstextension/MyFirstExtension.java @@ -2,17 +2,24 @@ import com.generalbytes.batm.server.extensions.AbstractExtension; import com.generalbytes.batm.server.extensions.IExtensionContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MyFirstExtension extends AbstractExtension { + protected final Logger log = LoggerFactory.getLogger("batm.master.myextension"); + + @Override public String getName() { return "My first extension"; } + @Override public void init(IExtensionContext ctx) { super.init(ctx); + log.debug("MyFirst extension initialized. Adding listener"); ctx.addTransactionListener(new MyTransactionListener(ctx)); } } diff --git a/server_extensions_template/src/main/java/com/mygreatcompany/batm/server/extensions/myfirstextension/MyTransactionListener.java b/server_extensions_template/src/main/java/com/mygreatcompany/batm/server/extensions/myfirstextension/MyTransactionListener.java index a9f053b89..274645f0c 100644 --- a/server_extensions_template/src/main/java/com/mygreatcompany/batm/server/extensions/myfirstextension/MyTransactionListener.java +++ b/server_extensions_template/src/main/java/com/mygreatcompany/batm/server/extensions/myfirstextension/MyTransactionListener.java @@ -3,11 +3,15 @@ import com.generalbytes.batm.server.extensions.IExtensionContext; import com.generalbytes.batm.server.extensions.ITransactionDetails; import com.generalbytes.batm.server.extensions.ITransactionListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.Map; public class MyTransactionListener implements ITransactionListener { private IExtensionContext ctx; + protected final Logger log = LoggerFactory.getLogger("batm.master.myextension"); + public MyTransactionListener(IExtensionContext ctx) { this.ctx = ctx; @@ -15,13 +19,13 @@ public MyTransactionListener(IExtensionContext ctx) { @Override public Map onTransactionCreated(ITransactionDetails transactionDetails) { - System.out.println("Bravo! Transaction has been created! Here are the details: = " + transactionDetails); + log.info("Bravo! Transaction has been created! Here are the details: = " + transactionDetails); return null; } @Override public Map onTransactionUpdated(ITransactionDetails transactionDetails) { - System.out.println("Hey! Transaction has been updated! Here are the details: " + transactionDetails); + log.info("Hey! Transaction has been updated! Here are the details: " + transactionDetails); return null; } }