KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > archive > crawler > io > LocalErrorFormatter


1 /* Copyright (C) 2003 Internet Archive.
2  *
3  * This file is part of the Heritrix web crawler (crawler.archive.org).
4  *
5  * Heritrix is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser Public License as published by
7  * the Free Software Foundation; either version 2.1 of the License, or
8  * any later version.
9  *
10  * Heritrix is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser Public License
16  * along with Heritrix; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * CrawlErrorFormatter.java
20  * Created on Jul 7, 2003
21  *
22  * $Header: /cvsroot/archive-crawler/ArchiveOpenCrawler/src/java/org/archive/crawler/io/LocalErrorFormatter.java,v 1.4 2005/09/22 23:03:11 gojomo Exp $
23  */

24 package org.archive.crawler.io;
25
26 import java.io.PrintWriter JavaDoc;
27 import java.io.StringWriter JavaDoc;
28 import java.util.logging.LogRecord JavaDoc;
29
30 import org.archive.crawler.datamodel.CoreAttributeConstants;
31 import org.archive.crawler.datamodel.LocalizedError;
32
33 /**
34  * @author gojomo
35  *
36  */

37 public class LocalErrorFormatter extends UriProcessingFormatter implements CoreAttributeConstants {
38
39     /* (non-Javadoc)
40      * @see java.util.logging.Formatter#format(java.util.logging.LogRecord)
41      */

42     public String JavaDoc format(LogRecord JavaDoc lr) {
43         LocalizedError err = (LocalizedError) lr.getParameters()[1];
44         Throwable JavaDoc ex = (Throwable JavaDoc)err.exception;
45         StringWriter JavaDoc sw = new StringWriter JavaDoc();
46         ex.printStackTrace(new PrintWriter JavaDoc(sw));
47
48         return super.format(lr) + " " + sw.toString();
49     }
50 }
51
52
53
Popular Tags