Skip to content

Commit

Permalink
FSDProtectedLogListener now supports a parameter to optionally print …
Browse files Browse the repository at this point in the history
…ellipsis for truncated fields
  • Loading branch information
sumeetphadnis committed Apr 16, 2024
1 parent 75c2637 commit 53f084f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions jpos/src/main/java/org/jpos/util/FSDProtectedLogListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.jpos.core.Configuration;
import org.jpos.core.ConfigurationException;
import org.jpos.iso.FSDISOMsg;
import org.jpos.iso.ISOException;
import org.jpos.iso.ISOUtil;
import java.util.List;

Expand Down Expand Up @@ -68,6 +67,7 @@ public class FSDProtectedLogListener implements LogListener, Configurable
String[] protectFields = null;
String[] wipeFields = null;
String[] truncateFields = null;
boolean truncateAddEllipsis = false;
Configuration cfg = null;
public static final String WIPED = "[WIPED]";
public static final byte[] BINARY_WIPED = ISOUtil.hex2byte ("AA55AA55");
Expand All @@ -94,6 +94,7 @@ public void setConfiguration (Configuration cfg)
truncateFields = ISOUtil.toStringArray (cfg.get ("truncate", ""));
protectFields = ISOUtil.toStringArray (cfg.get ("protect", ""));
wipeFields = ISOUtil.toStringArray (cfg.get ("wipe", ""));
truncateAddEllipsis = cfg.getBoolean("truncate-add-ellipsis", false);
}
public synchronized LogEvent log (LogEvent ev) {
synchronized (ev.getPayLoad()) {
Expand Down Expand Up @@ -133,7 +134,7 @@ private void checkTruncated(FSDISOMsg m) {

private void checkTruncated(FSDMsg m) {
for (String truncateField : truncateFields) {
String truncate[] = truncateField.split(":");
String [] truncate = truncateField.split(":");
if (truncate.length == 2) {
String f = truncate[0];
int len = Integer.parseInt(truncate[1]);
Expand All @@ -144,7 +145,7 @@ private void checkTruncated(FSDMsg m) {
// NOPMD: NOP
}
if (v != null && v.length() > len) {
m.set(f, v.substring(0, len));
m.set(f, v.substring(0, len) + (truncateAddEllipsis ? "...":""));
}
}
}
Expand Down

0 comments on commit 53f084f

Please sign in to comment.