Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BATM-5644 - added logging into extension template #869

Merged
merged 2 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
Loading