1
2
3
4
5
6
7
8
9
10
11
12
13
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 }