View Javadoc

1   // Copyright 2006-2007, by the California Institute of Technology.
2   // ALL RIGHTS RESERVED. United States Government Sponsorship acknowledged.
3   // Any commercial use must be negotiated with the Office of Technology Transfer
4   // at the California Institute of Technology.
5   //
6   // This software is subject to U. S. export control laws and regulations
7   // (22 C.F.R. 120-130 and 15 C.F.R. 730-774). To the extent that the software
8   // is subject to U.S. export control laws and regulations, the recipient has
9   // the responsibility to obtain export licenses or other export authority as
10  // may be required before exporting such information to foreign countries or
11  // providing access to foreign nationals.
12  //
13  
14  package gov.nasa.pds.tools.handler;
15  
16  import java.io.IOException;
17  import java.util.logging.FileHandler;
18  import java.util.logging.Formatter;
19  import java.util.logging.Level;
20  
21  /***
22   * Class to setup a file handler for the tools logging capability.
23   * 
24   * @author mcayanan
25   *
26   */
27  public class ToolsFileHandler extends FileHandler {
28  	
29  	/***
30  	 * Constructor that does not append to a file and automatically
31  	 * sets the log level to 'ALL'.
32  	 * 
33  	 * @param file A file name to store the logging messages. If the file 
34  	 * exists, it will overwrite the existing contents.
35  	 * @param formatter Formatter to be used to format the log messages.
36  	 * 
37  	 * @throws SecurityException
38  	 * @throws IOException
39  	 */
40  	public ToolsFileHandler(String file, Formatter formatter) throws SecurityException, IOException {
41  		this(file, false, Level.ALL, formatter);
42  	}
43  	
44  	/***
45  	 * Constructor that does not append to a file.
46  	 * 
47  	 * @param file A file name to store the logging messages.
48  	 * @param level Sets the logging level.
49  	 * @param formatter Formatter to be used to format the log messages.
50  	 * 
51  	 * @throws SecurityException
52  	 * @throws IOException
53  	 */
54  	public ToolsFileHandler(String file, Level level, Formatter formatter) throws SecurityException, IOException {
55  		this(file, false, level, formatter);
56  	}
57  	
58  	/***
59  	 * Constructor.
60  	 * 
61  	 * @param file A file name to store the logging messages.
62  	 * @param append A flag to tell the handler to append to the file or
63  	 * to overwrite the existing contents.
64  	 * @param level Sets the logging level.
65  	 * @param formatter Formatter to be used to format the log messages.
66  	 * 
67  	 * @throws SecurityException
68  	 * @throws IOException
69  	 */
70  	public ToolsFileHandler(String file, boolean append, Level level, Formatter formatter) throws SecurityException, IOException {
71  		super(file, append);
72  		setLevel(level);
73  		setFormatter(formatter);
74  	}
75  
76  }