Class DebugTagger
- java.lang.Object
-
- com.norconex.importer.handler.AbstractImporterHandler
-
- com.norconex.importer.handler.tagger.AbstractDocumentTagger
-
- com.norconex.importer.handler.tagger.impl.DebugTagger
-
- All Implemented Interfaces:
IXMLConfigurable,IImporterHandler,IDocumentTagger
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.
XML configuration usage:
<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>(field-matching expression)</fieldMatcher> <valueMatcher>(value-matching expression)</valueMatcher> </restrictTo> </handler>XML usage example:
<handler class="DebugTagger" logFields="title,author" logLevel="INFO"/>The above logs the value of any "title" and "author" document metadata fields.
- Since:
- 2.0.0
- Author:
- Pascal Essiembre
-
-
Constructor Summary
Constructors Constructor Description DebugTagger()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object other)List<String>getLogFields()StringgetLogLevel()StringgetPrefix()Gets the prefix to print before the actual log message.inthashCode()booleanisLogContent()protected voidloadHandlerFromXML(XML xml)Loads configuration settings specific to the implementing class.protected voidsaveHandlerToXML(XML xml)Saves configuration settings specific to the implementing class.voidsetLogContent(boolean logContent)voidsetLogFields(List<String> logFields)voidsetLogLevel(String logLevel)voidsetPrefix(String prefix)Sets the prefix to print before the actual log message.voidtagApplicableDocument(HandlerDoc doc, InputStream document, ParseState parseState)StringtoString()-
Methods inherited from class com.norconex.importer.handler.tagger.AbstractDocumentTagger
tagDocument
-
Methods inherited from class com.norconex.importer.handler.AbstractImporterHandler
addRestriction, addRestriction, addRestrictions, clearRestrictions, detectCharsetIfBlank, getRestrictions, isApplicable, loadFromXML, removeRestriction, removeRestriction, saveToXML
-
-
-
-
Method Detail
-
tagApplicableDocument
public void tagApplicableDocument(HandlerDoc doc, InputStream document, ParseState parseState) throws ImporterHandlerException
- Specified by:
tagApplicableDocumentin classAbstractDocumentTagger- Throws:
ImporterHandlerException
-
isLogContent
public boolean isLogContent()
-
setLogContent
public void setLogContent(boolean logContent)
-
getLogLevel
public String getLogLevel()
-
setLogLevel
public void setLogLevel(String logLevel)
-
getPrefix
public String getPrefix()
Gets the prefix to print before the actual log message.- Returns:
- log entry prefix
- Since:
- 3.0.0
-
setPrefix
public void setPrefix(String prefix)
Sets the prefix to print before the actual log message.- Parameters:
prefix- log entry prefix- Since:
- 3.0.0
-
loadHandlerFromXML
protected void loadHandlerFromXML(XML xml)
Description copied from class:AbstractImporterHandlerLoads configuration settings specific to the implementing class.- Specified by:
loadHandlerFromXMLin classAbstractImporterHandler- Parameters:
xml- XML configuration
-
saveHandlerToXML
protected void saveHandlerToXML(XML xml)
Description copied from class:AbstractImporterHandlerSaves configuration settings specific to the implementing class.- Specified by:
saveHandlerToXMLin classAbstractImporterHandler- Parameters:
xml- the XML
-
equals
public boolean equals(Object other)
- Overrides:
equalsin classAbstractImporterHandler
-
hashCode
public int hashCode()
- Overrides:
hashCodein classAbstractImporterHandler
-
toString
public String toString()
- Overrides:
toStringin classAbstractImporterHandler
-
-