Skip to content

Commit

Permalink
Add log function #319
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasNx committed Sep 18, 2024
1 parent 19bbe2c commit f1405ea
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions metafix/src/main/java/org/metafacture/metafix/FixMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public enum FixMethod implements FixFunction { // checkstyle-disable-line ClassDataAbstractionCoupling|ClassFanOutComplexity

// SCRIPT-LEVEL METHODS:
Expand All @@ -62,6 +65,23 @@ public void apply(final Metafix metafix, final Record record, final List<String>
metafix.getRecordTransformer(includePath).transform(record, options);
}
},
log {
@Override
public void apply(final Metafix metafix, final Record record, final List<String> params, final Map<String, String> options) {
final String logMessage = params.get(0);
final String logLevel = options.get("level"); // does not support Catmandu lop level option FATAL

if (logLevel.equals("WARN")) {
LOG.warn(logMessage);
}
else if (logLevel.equals("ERROR")) {
LOG.error(logMessage);
}
else {
LOG.info(logMessage);
}
}
},
nothing {
@Override
public void apply(final Metafix metafix, final Record record, final List<String> params, final Map<String, String> options) {
Expand Down Expand Up @@ -691,4 +711,6 @@ public void apply(final Metafix metafix, final Record record, final List<String>

private static final Random RANDOM = new Random();

private static final Logger LOG = LoggerFactory.getLogger(FixMethod.class);

}

0 comments on commit f1405ea

Please sign in to comment.