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  // $Id: ToolsFileHandler.java 3461 2008-08-07 17:43:26Z pramirez $
14  
15  package gov.nasa.pds.tools.handler;
16  
17  import java.io.IOException;
18  import java.util.logging.FileHandler;
19  import java.util.logging.Formatter;
20  import java.util.logging.Level;
21  
22  /***
23   * Class to setup a file handler for the tools logging capability.
24   * 
25   * @author mcayanan
26   *
27   */
28  public class ToolsFileHandler extends FileHandler {
29  	
30  	/***
31  	 * Constructor that does not append to a file and automatically
32  	 * sets the log level to 'ALL'.
33  	 * 
34  	 * @param file A file name to store the logging messages. If the file 
35  	 * exists, it will overwrite the existing contents.
36  	 * @param formatter Formatter to be used to format the log messages.
37  	 * 
38  	 * @throws SecurityException
39  	 * @throws IOException
40  	 */
41  	public ToolsFileHandler(String file, Formatter formatter) throws SecurityException, IOException {
42  		this(file, false, Level.ALL, formatter);
43  	}
44  	
45  	/***
46  	 * Constructor that does not append to a file.
47  	 * 
48  	 * @param file A file name to store the logging messages.
49  	 * @param level Sets the logging level.
50  	 * @param formatter Formatter to be used to format the log messages.
51  	 * 
52  	 * @throws SecurityException
53  	 * @throws IOException
54  	 */
55  	public ToolsFileHandler(String file, Level level, Formatter formatter) throws SecurityException, IOException {
56  		this(file, false, level, formatter);
57  	}
58  	
59  	/***
60  	 * Constructor.
61  	 * 
62  	 * @param file A file name to store the logging messages.
63  	 * @param append A flag to tell the handler to append to the file or
64  	 * to overwrite the existing contents.
65  	 * @param level Sets the logging level.
66  	 * @param formatter Formatter to be used to format the log messages.
67  	 * 
68  	 * @throws SecurityException
69  	 * @throws IOException
70  	 */
71  	public ToolsFileHandler(String file, boolean append, Level level, Formatter formatter) throws SecurityException, IOException {
72  		super(file, append);
73  		setLevel(level);
74  		setFormatter(formatter);
75  	}
76  
77  }