Skip to content

Commit

Permalink
Merge pull request metafacture#364 from metafacture/useLoggerOnHtmlDe…
Browse files Browse the repository at this point in the history
…codeer

Log exception using logger
  • Loading branch information
fsteeg authored May 3, 2021
2 parents e132278 + 6da63b8 commit a3cac40
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import org.metafacture.framework.annotations.In;
import org.metafacture.framework.annotations.Out;
import org.metafacture.framework.helpers.DefaultObjectPipe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Decode HTML to metadata events. Each input document represents one record.
Expand All @@ -60,6 +62,8 @@ public class HtmlDecoder extends DefaultObjectPipe<Reader, StreamReceiver> {
private static final String DEFAULT_ATTR_VALS_AS_SUBFIELDS = //
"meta.name=content&meta.property=content&link.rel=href&a.rel=href";
private Map<String, String> attrValsAsSubfields;
private static final Logger LOG =
LoggerFactory.getLogger(HtmlDecoder.class);

public HtmlDecoder() {
setAttrValsAsSubfields(DEFAULT_ATTR_VALS_AS_SUBFIELDS);
Expand All @@ -74,7 +78,7 @@ public void process(final Reader reader) {
process(document, receiver);
receiver.endRecord();
} catch (IOException e) {
e.printStackTrace();
LOG.error(e.getMessage(), e);
}
}

Expand Down Expand Up @@ -127,7 +131,7 @@ public void setAttrValsAsSubfields(String mapString) {
String val = nameValue.length > 1 ? URLDecoder.decode(nameValue[1], utf8) : "";
attrValsAsSubfields.put(key, val);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
LOG.error(e.getMessage(), e);
}
}
}
Expand Down

0 comments on commit a3cac40

Please sign in to comment.