Skip to content

Commit

Permalink
Merge pull request #869 from b00lean/master
Browse files Browse the repository at this point in the history
BATM-5644 - added logging into extension template
  • Loading branch information
generalbytes authored Nov 26, 2023
2 parents b5f0aac + e9f33e2 commit c5b711d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions server_extensions_template/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ artifacts {
}

dependencies {
implementation("org.slf4j:slf4j-api:1.7.28")
implementation project(":server_extensions_api")
implementation project(":currencies")
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,29 @@
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;
}

@Override
public Map<String, String> 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<String, String> 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;
}
}

0 comments on commit c5b711d

Please sign in to comment.