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 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()
-
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:
tagApplicableDocument
in 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:AbstractImporterHandler
Loads configuration settings specific to the implementing class.- Specified by:
loadHandlerFromXML
in classAbstractImporterHandler
- Parameters:
xml
- XML configuration
-
saveHandlerToXML
protected void saveHandlerToXML(XML xml)
Description copied from class:AbstractImporterHandler
Saves configuration settings specific to the implementing class.- Specified by:
saveHandlerToXML
in classAbstractImporterHandler
- Parameters:
xml
- the XML
-
equals
public boolean equals(Object other)
- Overrides:
equals
in classAbstractImporterHandler
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classAbstractImporterHandler
-
toString
public String toString()
- Overrides:
toString
in classAbstractImporterHandler
-
-