public class DebugTagger extends AbstractDocumentTagger
A utility tagger to help with troubleshooting of document importing. Place this tagger anywhere in your handler configuration to print to the log stream the metadata fields or content so far when this handler gets invoked. This handler does not impact the data being imported at all (it only reads it).
The default behavior logs all metadata fields using the DEBUG log level. You can optionally set which fields to log and whether to also log the document content or not, as well as specifying a different log level.
Be careful: Logging the content when you deal with very large content can result in memory exceptions.
Can be used both as a pre-parse or post-parse handler.
<handler
class="com.norconex.importer.handler.tagger.impl.DebugTagger"
logFields="(CSV list of fields to log)"
logContent="[false|true]"
logLevel="[ERROR|WARN|INFO|DEBUG|TRACE]"
prefix="(optional log prefix to further help you locate it)">
<!-- multiple "restrictTo" tags allowed (only one needs to match) -->
<restrictTo>
<fieldMatcher
method="[basic|csv|wildcard|regex]"
ignoreCase="[false|true]"
ignoreDiacritic="[false|true]"
partial="[false|true]">
(field-matching expression)
</fieldMatcher>
<valueMatcher
method="[basic|csv|wildcard|regex]"
ignoreCase="[false|true]"
ignoreDiacritic="[false|true]"
partial="[false|true]">
(value-matching expression)
</valueMatcher>
</restrictTo>
</handler>
<handler
class="DebugTagger"
logFields="title,author"
logLevel="INFO"/>
The above logs the value of any "title" and "author" document metadata fields.
Constructor and Description |
---|
DebugTagger() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other) |
List<String> |
getLogFields() |
String |
getLogLevel() |
String |
getPrefix()
Gets the prefix to print before the actual log message.
|
int |
hashCode() |
boolean |
isLogContent() |
protected void |
loadHandlerFromXML(XML xml)
Loads configuration settings specific to the implementing class.
|
protected void |
saveHandlerToXML(XML xml)
Saves configuration settings specific to the implementing class.
|
void |
setLogContent(boolean logContent) |
void |
setLogFields(List<String> logFields) |
void |
setLogLevel(String logLevel) |
void |
setPrefix(String prefix)
Sets the prefix to print before the actual log message.
|
void |
tagApplicableDocument(HandlerDoc doc,
InputStream document,
ParseState parseState) |
String |
toString() |
tagDocument
addRestriction, addRestriction, addRestrictions, clearRestrictions, detectCharsetIfBlank, getRestrictions, isApplicable, loadFromXML, removeRestriction, removeRestriction, saveToXML
public void tagApplicableDocument(HandlerDoc doc, InputStream document, ParseState parseState) throws ImporterHandlerException
tagApplicableDocument
in class AbstractDocumentTagger
ImporterHandlerException
public boolean isLogContent()
public void setLogContent(boolean logContent)
public String getLogLevel()
public void setLogLevel(String logLevel)
public String getPrefix()
public void setPrefix(String prefix)
prefix
- log entry prefixprotected void loadHandlerFromXML(XML xml)
AbstractImporterHandler
loadHandlerFromXML
in class AbstractImporterHandler
xml
- XML configurationprotected void saveHandlerToXML(XML xml)
AbstractImporterHandler
saveHandlerToXML
in class AbstractImporterHandler
xml
- the XMLpublic boolean equals(Object other)
equals
in class AbstractImporterHandler
public int hashCode()
hashCode
in class AbstractImporterHandler
public String toString()
toString
in class AbstractImporterHandler
Copyright © 2009–2023 Norconex Inc.. All rights reserved.