01: /* Copyright (C) 2003 Internet Archive.
02: *
03: * This file is part of the Heritrix web crawler (crawler.archive.org).
04: *
05: * Heritrix is free software; you can redistribute it and/or modify
06: * it under the terms of the GNU Lesser Public License as published by
07: * the Free Software Foundation; either version 2.1 of the License, or
08: * any later version.
09: *
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: * UriErrorFormatter.java
20: * Created on Jul 7, 2003
21: *
22: * $Header$
23: */
24: package org.archive.crawler.io;
25:
26: import java.util.logging.Formatter;
27: import java.util.logging.LogRecord;
28:
29: import org.archive.crawler.datamodel.CoreAttributeConstants;
30: import org.archive.net.UURI;
31: import org.archive.util.ArchiveUtils;
32:
33: /**
34: * Formatter for 'uri-errors.log', of URIs so malformed they could
35: * not be instantiated.
36: *
37: * @author gojomo
38: *
39: */
40: public class UriErrorFormatter extends Formatter implements
41: CoreAttributeConstants {
42:
43: /* (non-Javadoc)
44: * @see java.util.logging.Formatter#format(java.util.logging.LogRecord)
45: */
46: public String format(LogRecord lr) {
47: UURI uuri = (UURI) lr.getParameters()[0];
48: String problem = (String) lr.getParameters()[1];
49:
50: return ArchiveUtils.getLog17Date() + " "
51: + ((uuri == null) ? "n/a" : uuri.toString()) + " \""
52: + lr.getMessage() + "\" " + problem + "\n";
53: }
54: }
|