Re: [Htmlparser-developer] Automatic debug output
Brought to you by:
derrickoswald
|
From: Sam J. <ga...@yh...> - 2002-12-11 03:03:00
|
Hi Somik
Somik wrote:
>>Most importantly I seem to get a lot of debug output
>>text that I would
>>prefer to avoid, see the examples below. Perhaps I'm
>>mistaken but this
>>seems to be output by default. Is there some way for
>>me to avoid getting
>>this debug output?
>>
>>
>
>Of course - HTMLParser now takes in a logging object -
>HTMLParserFeedback. All you have to do is to implement
>this interface and pass your object in to the parser.
>If you don't, a DefaultHTMLParserFeedback object is
>created - and its function is to send log data to
>System.out.
>
Well I wrote the following:
private class BlankHTMLParserFeedback
implements HTMLParserFeedback
{
public void info(String message)
{
//System.out.println("INFO: " + message);
}
public void warning(String message)
{
//System.out.println("WARNING: " + message);
}
public void error(String message, HTMLParserException e)
{
//System.out.println("ERROR: " + message);
e.printStackTrace();
}
}
/**
* parse the page
*/
public final void parse()
throws Exception
{
if (o_parser==null)
o_parser = new HTMLParser(o_url, new BlankHTMLParserFeedback());
o_parser.addScanner(new HTMLMetaTagScanner("-t"));
o_parser.addScanner(new HTMLLinkScanner("-l"));
o_parser.addScanner(new HTMLTitleScanner("-a"));
parseURLForData();
o_summary = createSummary();
}
However I still seem to be getting the same debug output. Can you see
what I am doing wrong?
Have you considered using log4j? With log4j you have a log4j properties
file and you can specify the debug level on a class by class basis
within the properties file, and debug output can be formatted to give
you useful info such as the line number of the code where the debug
statement is.
Thanks in advance.
CHEERS> SAM
p.s. is there some operation for picking up HTML comments using the
HTMLParser (<!-- a comment -->) or are they automatically ignored?
|